Skip to contentSkip to conversation

insmod

DISCUSSION Russell Coker 2 participants 4 messages Nov 8, 2003 – Nov 14, 2003 SELinux security module

lore
Share & tools
lore
#0 lore raw

We have been discussing some potential changes to make insmod work better with SE Linux.

Insmod runs with the security domain insmod_t, and so does the initialisation phase of the kernel code it runs. When kernel code is blocked by SE Linux the usual result is an Oops (buggy code, but even if it handles the error correctly it won't be operational unless access is granted). To prevent Oopsen and modules failing to operate we need to either have the code always run in kernel_t by having the process that loads the module be in kernel_t or we have to give insmod_t the same access as kernel_t (which essentially means running the insmod program in kernel_t).

So it seems that we need have insmod run in kernel_t and have modprobe run in it's own domain modprobe_t.

This means that we can't have insmod and modprobe be the same binary.

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
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.
#1 lore raw
Quoted 2 lines · Russell Coker

So it seems that we need have insmod run in kernel_t and have modprobe run in it's own domain modprobe_t.

There should be no userland entrypoints into kernel_t. Grant insmod_t additional permissions if necessary, but keep it separate from kernel_t.

Signature · 8 lines
Stephen Smalley <[email protected]>
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.
#2 lore raw
Quoted 6 lines · Stephen Smalley
Quoted 2 lines · Russell Coker

So it seems that we need have insmod run in kernel_t and have modprobe run in it's own domain modprobe_t.

There should be no userland entrypoints into kernel_t. Grant insmod_t additional permissions if necessary, but keep it separate from kernel_t.

If we do that then insmod_t will require all capabilities, ability to create all types of socket, and full access to sysfs and other resources. Kernel code will run as insmod_t. When the kernel code can't do what it wants an Oops is to be expected and a module load failure is the best result you can hope for (it seems that most kernel code does not correctly handle all possible error conditions).

The distinction between kernel_t and insmod_t seems artificial with the way things work at the moment.

Are there plans to change the kernel code related to module loading to have the kernel code run as kernel_t? Without kernel changes there does not seem to be any benefit in a insmod_t/kernel_t split.

Signature · 10 lines
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page


--
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 7 lines · Russell Coker

If we do that then insmod_t will require all capabilities, ability to create all types of socket, and full access to sysfs and other resources. Kernel code will run as insmod_t. When the kernel code can't do what it wants an Oops is to be expected and a module load failure is the best result you can hope for (it seems that most kernel code does not correctly handle all possible error conditions).

Quoted 6 lines

The distinction between kernel_t and insmod_t seems artificial with the way things work at the moment.

Are there plans to change the kernel code related to module loading to have the kernel code run as kernel_t? Without kernel changes there does not seem to be any benefit in a insmod_t/kernel_t split.

It is already the case that any kernel thread that calls reparent_to_init (or any of its callers, such as daemonize), will be switched to the kernel SID. Hence, kernel threads launched by a module will run with the kernel SID (if they use reparent_to_init, which they should). However, that doesn't address module initialization code, which typically just runs in the context of the process that inserted the module.

I understand that module initialization code expects full privileges, and that you may need to grant many permissions to insmod_t. Nonetheless, I would still recommend against merging it with kernel_t. There are permissions required by kernel_t that are not required by insmod_t (e.g. ability to load policy, ability to transition to init_t) and there are permissions required by insmod_t that are not required by kernel_t.

Also, the domain transition from kernel_t to insmod_t for kernel module requests has served a useful purpose in the past, as you might recall...

Signature · 8 lines
Stephen Smalley <[email protected]>
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.