-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Description
systemd version the issue has been seen with
Used distribution
Fedora
Expected behaviour you didn't see
Systemd seems to not create "dummy bind-mount files" without device node labels .
Unexpected behaviour you saw
Systemd seems to create "dummy bind-mount file" with device node labels.
Steps to reproduce the problem
https://bugzilla.redhat.com/show_bug.cgi?id=1746413#c30
The faillback code starting at core/namespace.c line 625 seems to cause systemd to create the "dummy bind-mount file" with the device node label:
type=AVC msg=audit(1567152101.123:147): avc: denied { create } for pid=1291 comm="(r-launch)" name="random" scontext=system_u:system_r:init_t:s0 tcontext=system_u:object_r:random_device_t:s0 tclass=file permissive=1
As you can see the target is a file. /dev/random (or any device) is a character file. And so systemd should not create this dummy bind-mount target file with a device node type like "random_device_t". Because there shouldnt be any "files" with device node types (theres only char files and block files for storage devices).
The argument is:
First, with the mode stat()ed from the actual device node (before the call to mknod()),
and then with mode==0, before creating a dummy mount target. So the "dummy bind mount target"
should not be labelled as a device node, but as a normal file. Or at least systemd passes
this metadata to selabel_lookup_raw().
But if that is the case then why call mac_selinux_create_file_prepare(d, 0); on line 627 in the first place.
The issue is that according to the bug reports attached avc denials, systemd is creating dummy bind-mount target files with device node contexts, and it should not do that. Because files with device node contexts should not exist.