]> git.ipfire.org Git - thirdparty/libvirt.git/commit
security_selinux: Don't relabel /dev/net/tun
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 7 Oct 2014 14:22:17 +0000 (16:22 +0200)
committerCole Robinson <crobinso@redhat.com>
Sat, 15 Nov 2014 20:20:42 +0000 (15:20 -0500)
commitd72e79ed2792e1e8937feee3b5480b9199094006
tree49dc03f13f7b0473227edfcd0419a59054acaf64
parent7caed3d4c5264d5004c00c025637d14db2b1758c
security_selinux: Don't relabel /dev/net/tun

https://bugzilla.redhat.com/show_bug.cgi?id=1147057

The code for relabelling the TAP FD is there due to a race. When
libvirt creates a /dev/tapN device it's labeled as
'system_u:object_r:device_t:s0' by default. Later, when
udev/systemd reacts to this device, it's relabelled to the
expected label 'system_u:object_r:tun_tap_device_t:s0'. Hence, we
have a code that relabels the device, to cut the race down. For
more info see ae368ebfcc4.

But the problem is, the relabel function is called on all TUN/TAP
devices. Yes, on /dev/net/tun too. This is however a special kind
of device - other processes uses it too. We shouldn't touch it's
label then.

Ideally, there would an API in SELinux that would label just the
passed FD and not the underlying path. That way, we wouldn't need
to care as we would be not labeling /dev/net/tun but the FD
passed to the domain. Unfortunately, there's no such API so we
have to workaround until then.

Tested-by: Richard W.M. Jones <rjones@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit ebc05263960f41065fa7d882959ea754b9281ab1)
src/security/security_selinux.c