Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On 5.8 kernels unprivileged whiteout creation is allowed #16721

Closed
brauner opened this issue Aug 13, 2020 · 4 comments · Fixed by #16734
Closed

On 5.8 kernels unprivileged whiteout creation is allowed #16721

brauner opened this issue Aug 13, 2020 · 4 comments · Fixed by #16734
Labels
Milestone

Comments

@brauner
Copy link
Contributor

brauner commented Aug 13, 2020

@poettering one of your colleagues made it possible to create unprivileged whiteouts in newer kernels:

commit a3c751a50fe6bbe50eb7622a14b18b361804ee0c
Author: Miklos Szeredi <mszeredi@redhat.com>
Date:   Thu May 14 16:44:23 2020 +0200

    vfs: allow unprivileged whiteout creation

    Whiteouts, unlike real device node should not require privileges to create.

    The general concern with device nodes is that opening them can have side
    effects.  The kernel already avoids zero major (see
    Documentation/admin-guide/devices.txt).  To be on the safe side the patch
    explicitly forbids registering a char device with 0/0 number (see
    cdev_add()).

    This guarantees that a non-O_PATH open on a whiteout will fail with ENODEV;
    i.e. it won't have any side effect.

    Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>

This means:

if (r < 0 && errno == EPERM && detect_container() > 0) {

should likely be adapted to test some other device. We've seen failures for this in our test-suites.

@brauner
Copy link
Contributor Author

brauner commented Aug 13, 2020

Probably also need to change:

if (is_device_node("/run/systemd/inaccessible/chr") > 0) {

because inaccessiable/{chr,blk} are whiteouts as well afaict.

@poettering
Copy link
Member

it would probably suffice to swap the order of the char vs. block device node testing, right? since block devices of zero major are still not allowed, right? it's only the char devices 0:0 that are now allowed, correct?

@poettering poettering added this to the v247 milestone Aug 14, 2020
@sforshee
Copy link

Yes, it's only the 0:0 char device that is now allowed, so testing the block device node first should be sufficient.

@poettering
Copy link
Member

fix pending in #16734

poettering added a commit to poettering/systemd that referenced this issue Aug 17, 2020
peckato1 pushed a commit to peckato1/systemd that referenced this issue Oct 1, 2020
vbatts pushed a commit to kinvolk/systemd that referenced this issue Nov 12, 2020
Fixes: systemd#16721
(cherry picked from commit 5b5ce62)
(cherry picked from commit f44ec1d)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants