Bug 1279251

Summary: unprivileged user can freeze journald
Product: [Fedora] Fedora Reporter: Guillaume Knispel <xilun0>
Component: systemdAssignee: systemd-maint
Status: CLOSED EOL QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 23CC: carnil, johannbg, jsynacek, lnykryn, msekleta, s, systemd-maint, zbyszek
Target Milestone: ---Keywords: Security
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
: 1501017 (view as bug list) Environment:
Last Closed: 2016-12-20 15:32:40 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1280234, 1501017    
Attachments:
Description Flags
program to freeze journald none

Description Guillaume Knispel 2015-11-08 21:15:00 UTC
Created attachment 1091441 [details]
program to freeze journald

Description of problem:

On default installs of Fedora 23 an unprivileged user can freeze journald using the attached program. (Journald is then eventually killed and restarted by systemd after a 1 min timeout is detected - but nothing prevent the unprivileged user to DOS in a loop if he feels so inclined.)

The reason is that journald uses inappropriate rules to decide if a file descriptor sent by a user is safe to read.

[ IMO that such a "feature" (passing messages to log to journald by fd to regular files) exists at all should be questioned anyway, given the kind of impacts it can have on various aspects of the whole system (e.g.: the fd is completely read in a malloc'ed area, up to 750 MB) ]

Version-Release number of selected component (if applicable):

systemd-222-8.fc23.x86_64

How reproducible:

100%

Steps to Reproduce:

1. gcc -O2 -Wall -Wextra -std=gnu99 -o lol lol.c
2. ./lol

Actual results:

journald freezes on a pread system call trying to read the mandatory locked regular file. It won't be unblocked until killed or the "./lol" program is stopped.

Expected results:

journald does not freeze.

Additional info:

Bug affects several distro. My POC requires unshare(CLONE_NEWNS | CLONE_NEWUSER) allowed for users, which is the case by default at least on Ubuntu and Fedora, but maybe it is possible to use other methods to bypass the checks that try to test if the file is in /tmp and other allowed dirs. Without even bypassing anything, the system could have been configured with the mand mount option on tmp by an administrator not aware of the security implication on journald. Also maybe other things than mandatory locking can affect the syscall of journald on the fd. Also given that /proc/self/fd/<n> does not seems intended for security purposes (otherwise it would have change the symlink when crossing the unshared FS bondary, somehow), maybe there exist or there will exist in the future other ways to affect its content.
Also I've not audited all systemd source code. Maybe others of its components are affected by the same class of bugs.

Comment 1 Guillaume Knispel 2015-11-10 02:16:00 UTC
OpenSUSE 42.1 bug: https://bugzilla.opensuse.org/show_bug.cgi?id=954374
upstream bug: https://github.com/systemd/systemd/issues/1822

Comment 2 Lennart Poettering 2016-02-10 13:59:19 UTC
Fixed upstream a while back.

Comment 3 Mike McCune 2016-03-28 23:38:32 UTC
This bug was accidentally moved from POST to MODIFIED via an error in automation, please see mmccune with any questions

Comment 4 Fedora End Of Life 2016-11-24 13:13:10 UTC
This message is a reminder that Fedora 23 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 23. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as EOL if it remains open with a Fedora  'version'
of '23'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version.

Thank you for reporting this issue and we are sorry that we were not 
able to fix it before Fedora 23 is end of life. If you would still like 
to see this bug fixed and are able to reproduce it against a later version 
of Fedora, you are encouraged  change the 'version' to a later Fedora 
version prior this bug is closed as described in the policy above.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events. Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

Comment 5 Fedora End Of Life 2016-12-20 15:32:40 UTC
Fedora 23 changed to end-of-life (EOL) status on 2016-12-20. Fedora 23 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version. If you
are unable to reopen this bug, please file a new report against the
current release. If you experience problems, please add a comment to this
bug.

Thank you for reporting this bug and we are sorry it could not be fixed.