Skip to contentSkip to conversation

Xorg modprobe denials

DISCUSSION Eamon Walsh 6 participants 9 messages Dec 18, 2007 – May 22, 2008 SELinux security module

lore
Share & tools
lore
#0 lore raw

Attached are some denials that modprobe is encountering while loading Xorg DRI kernel modules while X server is starting up. tty7 is the terminal where the X server is being launched (Ctrl-Alt-F7). I'm aware that the Xorg.0.log file is supposed to be labeled xserver_log_t, but my guess is that would be denied as well. Think this may be log messages except for the renicing stuff.

This is xselinux branch of refpolicy running in enforcing mode.

Signature · 2 lines
Eamon Walsh <[email protected]>
National Security Agency
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.892:71): avc:  denied  { read write } for  pid=2220 comm="modprobe" name="tty7" dev=tmpfs ino=240 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.893:72): avc:  denied  { write } for  pid=2220 comm="modprobe" path="/usr/local/var/log/Xorg.0.log" dev=dm-0 ino=5701638 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:usr_t:s0 tclass=file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.893:73): avc:  denied  { read write } for  pid=2220 comm="modprobe" path="/dev/tty7" dev=tmpfs ino=240 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.926:74): avc:  denied  { sys_nice } for  pid=2220 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tclass=capability
Dec 17 21:25:34 moss-charon kernel: [drm] Initialized drm 1.1.0 20060810
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.932:75): avc:  denied  { sys_nice } for  pid=2220 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tclass=capability
Dec 17 21:25:34 moss-charon kernel: ACPI: PCI Interrupt 0000:00:02.0[A] -> GSI 16 (level, low) -> IRQ 16
Dec 17 21:25:34 moss-charon kernel: [drm] Initialized i915 1.11.0 20071122 on minor 0
Dec 17 21:25:34 moss-charon kernel: mtrr: type mismatch for c0000000,10000000 old: write-back new: write-combining
Dec 17 21:25:40 moss-charon kernel: mtrr: type mismatch for c0000000,10000000 old: write-back new: write-combining
#1 lore raw
Quoted 8 lines · Eamon Walsh

Attached are some denials that modprobe is encountering while loading Xorg DRI kernel modules while X server is starting up. tty7 is the terminal where the X server is being launched (Ctrl-Alt-F7). I'm aware that the Xorg.0.log file is supposed to be labeled xserver_log_t, but my guess is that would be denied as well. Think this may be log messages except for the renicing stuff.

This is xselinux branch of refpolicy running in enforcing mode.

Based on the other kernel messages, I'm guessing that the insmod succeeded despite the tty and capability denials? If so I suppose we can dontaudit it.

Quoted 12 lines

plain text document attachment (audit_x.txt)

Dec 17 21:25:34 moss-charon kernel: audit(1197944734.892:71): avc:  denied  { read write } for  pid=2220 comm="modprobe" name="tty7" dev=tmpfs ino=240 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.893:72): avc:  denied  { write } for  pid=2220 comm="modprobe" path="/usr/local/var/log/Xorg.0.log" dev=dm-0 ino=5701638 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:usr_t:s0 tclass=file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.893:73): avc:  denied  { read write } for  pid=2220 comm="modprobe" path="/dev/tty7" dev=tmpfs ino=240 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.926:74): avc:  denied  { sys_nice } for  pid=2220 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tclass=capability
Dec 17 21:25:34 moss-charon kernel: [drm] Initialized drm 1.1.0 20060810
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.932:75): avc:  denied  { sys_nice } for  pid=2220 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tclass=capability
Dec 17 21:25:34 moss-charon kernel: ACPI: PCI Interrupt 0000:00:02.0[A] -> GSI 16 (level, low) -> IRQ 16
Dec 17 21:25:34 moss-charon kernel: [drm] Initialized i915 1.11.0 20071122 on minor 0
Dec 17 21:25:34 moss-charon kernel: mtrr: type mismatch for c0000000,10000000 old: write-back new: write-combining
Dec 17 21:25:40 moss-charon kernel: mtrr: type mismatch for c0000000,10000000 old: write-back new: write-combining
Signature · 7 lines
Chris PeBenito
<[email protected]>
Developer,
Hardened Gentoo Linux
 
Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243
Key fingerprint = B0E6 877A 883F A57A 8E6A  CB00 BC8E E42D E6AF 9243
#2 lore raw
Quoted 8 lines · Chris PeBenito
Quoted 7 lines · Eamon Walsh

Attached are some denials that modprobe is encountering while loading Xorg DRI kernel modules while X server is starting up. tty7 is the terminal where the X server is being launched (Ctrl-Alt-F7). I'm aware that the Xorg.0.log file is supposed to be labeled xserver_log_t, but my guess is that would be denied as well. Think this may be log messages except for the renicing stuff.

Quoted 5 lines
Quoted 1 line

This is xselinux branch of refpolicy running in enforcing mode.

Based on the other kernel messages, I'm guessing that the insmod succeeded despite the tty and capability denials? If so I suppose we can dontaudit it.

I don't think we want to dontaudit the capability denials.

Quoted 13 lines
Quoted 12 lines

plain text document attachment (audit_x.txt)

Dec 17 21:25:34 moss-charon kernel: audit(1197944734.892:71): avc:  denied  { read write } for  pid=2220 comm="modprobe" name="tty7" dev=tmpfs ino=240 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.893:72): avc:  denied  { write } for  pid=2220 comm="modprobe" path="/usr/local/var/log/Xorg.0.log" dev=dm-0 ino=5701638 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:usr_t:s0 tclass=file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.893:73): avc:  denied  { read write } for  pid=2220 comm="modprobe" path="/dev/tty7" dev=tmpfs ino=240 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.926:74): avc:  denied  { sys_nice } for  pid=2220 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tclass=capability
Dec 17 21:25:34 moss-charon kernel: [drm] Initialized drm 1.1.0 20060810
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.932:75): avc:  denied  { sys_nice } for  pid=2220 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tclass=capability
Dec 17 21:25:34 moss-charon kernel: ACPI: PCI Interrupt 0000:00:02.0[A] -> GSI 16 (level, low) -> IRQ 16
Dec 17 21:25:34 moss-charon kernel: [drm] Initialized i915 1.11.0 20071122 on minor 0
Dec 17 21:25:34 moss-charon kernel: mtrr: type mismatch for c0000000,10000000 old: write-back new: write-combining
Dec 17 21:25:40 moss-charon kernel: mtrr: type mismatch for c0000000,10000000 old: write-back new: write-combining
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#3 lore raw
Quoted 9 lines · Stephen Smalley
Quoted 8 lines · Chris PeBenito
Quoted 7 lines · Eamon Walsh

Attached are some denials that modprobe is encountering while loading Xorg DRI kernel modules while X server is starting up. tty7 is the terminal where the X server is being launched (Ctrl-Alt-F7). I'm aware that the Xorg.0.log file is supposed to be labeled xserver_log_t, but my guess is that would be denied as well. Think this may be log messages except for the renicing stuff.

Quoted 7 lines
Quoted 5 lines
Quoted 1 line

This is xselinux branch of refpolicy running in enforcing mode.

Based on the other kernel messages, I'm guessing that the insmod succeeded despite the tty and capability denials? If so I suppose we can dontaudit it.

I don't think we want to dontaudit the capability denials.

And just to note, denials from insmod can be triggered either by userspace activity of insmod or by the module initialization code of the loaded module.

Quoted 13 lines
Quoted 13 lines
Quoted 12 lines

plain text document attachment (audit_x.txt)

Dec 17 21:25:34 moss-charon kernel: audit(1197944734.892:71): avc:  denied  { read write } for  pid=2220 comm="modprobe" name="tty7" dev=tmpfs ino=240 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.893:72): avc:  denied  { write } for  pid=2220 comm="modprobe" path="/usr/local/var/log/Xorg.0.log" dev=dm-0 ino=5701638 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:usr_t:s0 tclass=file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.893:73): avc:  denied  { read write } for  pid=2220 comm="modprobe" path="/dev/tty7" dev=tmpfs ino=240 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:object_r:tty_device_t:s0 tclass=chr_file
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.926:74): avc:  denied  { sys_nice } for  pid=2220 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tclass=capability
Dec 17 21:25:34 moss-charon kernel: [drm] Initialized drm 1.1.0 20060810
Dec 17 21:25:34 moss-charon kernel: audit(1197944734.932:75): avc:  denied  { sys_nice } for  pid=2220 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c255 tclass=capability
Dec 17 21:25:34 moss-charon kernel: ACPI: PCI Interrupt 0000:00:02.0[A] -> GSI 16 (level, low) -> IRQ 16
Dec 17 21:25:34 moss-charon kernel: [drm] Initialized i915 1.11.0 20071122 on minor 0
Dec 17 21:25:34 moss-charon kernel: mtrr: type mismatch for c0000000,10000000 old: write-back new: write-combining
Dec 17 21:25:40 moss-charon kernel: mtrr: type mismatch for c0000000,10000000 old: write-back new: write-combining
Signature · 8 lines
Stephen Smalley
National Security Agency


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#4 lore raw
Quoted 10 lines · Stephen Smalley
Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Chris PeBenito

Based on the other kernel messages, I'm guessing that the insmod succeeded despite the tty and capability denials? If so I suppose we can dontaudit it.

I don't think we want to dontaudit the capability denials.

And just to note, denials from insmod can be triggered either by userspace activity of insmod or by the module initialization code of the loaded module.

I find that on an SMP machine I need both the sys_nice capabability and setsched on kernel_t to load modules.

This is because stop_machine() is called by sys_init_module(), so it makes sense to me to add these to kernel_load_module().

modules/kernel/kernel.if +3 -0
Index: policy/modules/kernel/kernel.if
===================================================================
@@ -330,6 +330,9 @@
 
 	allow $1 self:capability sys_module;
 	typeattribute $1 can_load_kernmodule;
+
+	allow $1 self:capability sys_nice;
+	kernel_setsched($1)
 ')
 
 ########################################
Signature · 1 line
Martin Orr
#5 lore raw
Quoted 23 lines · Martin Orr
Quoted 10 lines · Stephen Smalley
Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Chris PeBenito

Based on the other kernel messages, I'm guessing that the insmod succeeded despite the tty and capability denials? If so I suppose we can dontaudit it.

I don't think we want to dontaudit the capability denials.

And just to note, denials from insmod can be triggered either by userspace activity of insmod or by the module initialization code of the loaded module.

I find that on an SMP machine I need both the sys_nice capabability and setsched on kernel_t to load modules.

This is because stop_machine() is called by sys_init_module(), so it makes sense to me to add these to kernel_load_module().

Index: policy/modules/kernel/kernel.if
===================================================================

modules/kernel/kernel.if line 336

Quoted 7 lines
modules/kernel/kernel.if +3 -0
@@ -330,6 +330,9 @@
 
 	allow $1 self:capability sys_module;
 	typeattribute $1 can_load_kernmodule;
+
+	allow $1 self:capability sys_nice;
+	kernel_setsched($1)
 ')

Are these rules are inherent to anything that loads a module or specific to insmod? This patch only makes sense if its the former.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#6 lore raw
Quoted 23 lines · Christopher J. PeBenito
Quoted 22 lines · Martin Orr
Quoted 9 lines · Stephen Smalley
Quoted 5 lines · Stephen Smalley
Quoted 3 lines · Chris PeBenito

Based on the other kernel messages, I'm guessing that the insmod succeeded despite the tty and capability denials? If so I suppose we can dontaudit it.

I don't think we want to dontaudit the capability denials.

And just to note, denials from insmod can be triggered either by userspace activity of insmod or by the module initialization code of the loaded module.

I find that on an SMP machine I need both the sys_nice capabability and setsched on kernel_t to load modules.

This is because stop_machine() is called by sys_init_module(), so it makes sense to me to add these to kernel_load_module().

Index: policy/modules/kernel/kernel.if
===================================================================

modules/kernel/kernel.if +0 -0
@@ -330,6 +330,9 @@
 
Quoted 10 lines

modules/kernel/kernel.if line 336

Quoted 6 lines
modules/kernel/kernel.if +3 -0
 	allow $1 self:capability sys_module;
 	typeattribute $1 can_load_kernmodule;
+
+	allow $1 self:capability sys_nice;
+	kernel_setsched($1)
 ')

Are these rules are inherent to anything that loads a module or specific to insmod? This patch only makes sense if its the former.

It happens inside the init_module system call in the kernel, so anything that loads a module needs it.

Signature · 6 lines
Martin Orr

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.
#7 lore raw

refpolicy: syscall init_module needs sys_nice & setsched

Hi,
while playing with current Debian Sid, Linux 2.6.25 I noticed, denials on modprobe:

May 22 07:26:11 sid kernel: [    9.195474] type=1400 audit(1211433957.144:3): avc:  denied  { sys_nice } for  pid=801 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=capability
May 22 07:26:11 sid kernel: [    9.198362] type=1400 audit(1211433957.144:3): avc:  denied  { setsched } for  pid=801 comm="modprobe" scontext=system_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=system_u:system_r:kernel_t:s0 tclass=process

After a longer investigation with git-bisect I found, that above denials appeared after kernel commit:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=85653af7d488702165eba72c6c1dd0250fae4e70
A function stop_machine() (from kernel/stop_machine.c) was changed in this commit in such a way, that system calls init_module() & delete_module() needs sys_nice & setsched. I did'n try to understand code too much (consequences of this commit).

I found in the history of SE Linux mailing list Martin Orr sent a patch already. (The correspondence attached.)
The Martins patch is available at URL:
http://www.martinorr.name/selinux/patches/151_module_setsched

Can be Martins patch merged?
Thanks

Signature · 1 line
Zito
#8 lore raw

Re: refpolicy: syscall init_module needs sys_nice & setsched

Quoted 14 lines · Václav Ovsík

while playing with current Debian Sid, Linux 2.6.25 I noticed, denials on modprobe:

May 22 07:26:11 sid kernel: [    9.195474] type=1400 audit(1211433957.144:3): avc:  denied  { sys_nice } for  pid=801 comm="modprobe" capability=23 scontext=system_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=system_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=capability
May 22 07:26:11 sid kernel: [    9.198362] type=1400 audit(1211433957.144:3): avc:  denied  { setsched } for  pid=801 comm="modprobe" scontext=system_u:system_r:insmod_t:s0-s0:c0.c1023 tcontext=system_u:system_r:kernel_t:s0 tclass=process

After a longer investigation with git-bisect I found, that above denials appeared after kernel commit:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=85653af7d488702165eba72c6c1dd0250fae4e70
A function stop_machine() (from kernel/stop_machine.c) was changed in this commit in such a way, that system calls init_module() & delete_module() needs sys_nice & setsched. I did'n try to understand code too much (consequences of this commit).

Quoted 4 lines

I found in the history of SE Linux mailing list Martin Orr sent a patch already. (The correspondence attached.)
The Martins patch is available at URL:
http://www.martinorr.name/selinux/patches/151_module_setsched

I added that and comments as to why its needed.

Signature · 10 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150



--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to [email protected] with
the words "unsubscribe selinux" without quotes as the message.