context trouble with 2.5 bits
Hi,
I think I'm pretty close to getting my Debian system running with the SELinux 2.5 bits. However, I can't seem to get either the patched sshd or login to give me the correct context. When I login (using login) as root, I see:
Warning! Could not get new context for tty1, not relabeling.
...followed by a bunch of avc denials about tty1 and /root, and then my context is:
meta:~# id uid=0(root) gid=0(root) groups=0(root) context:system_u:system_r:user_t
Now, since Debian uses the login in shadow-utils (not the one in util-linux), I had to port over the patch, but I'm fairly sure that's not the problem, because I get the exact same symptoms when logging in over the patched ssh.
Does anyone have any ideas for what could be going wrong?
--
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.
Quoted 1 line · Colin Walters
Warning! Could not get new context for tty1, not relabeling.
Which may mean that the original type for the device node is not one that is expected. Please tell me what "ls --context /dev/tty1" reports.
However this should have nothing to do with the ability to login and run a session in the correct context.
Quoted 5 lines
...followed by a bunch of avc denials about tty1 and /root, and then my context is:
meta:~# id uid=0(root) gid=0(root) groups=0(root) context:system_u:system_r:user_t
This is wrong. There's a domain_auto_trans() rule to transition to user_t for when using a login program that is not aware of SE Linux. So it looks like the target context is not being set.
Under the new scheme I believe that some file is supposed to be written under /proc for this. Make sure that the right stuff is mounted under /proc, the file is available, etc.
Also while in permissive mode do some tests at the command line, do:
# echo user_u:user_r:user_t > /proc/whatever-it-is # id
Then id should report a context of user_u:user_r:user_t if the context change is working correctly.
Quoted 6 lines
Now, since Debian uses the login in shadow-utils (not the one in util-linux), I had to port over the patch, but I'm fairly sure that's not the problem, because I get the exact same symptoms when logging in over the patched ssh.
Does anyone have any ideas for what could be going wrong?
Does the NSA supplied patch for 2.5.x do the same things as the patch for 2.4.x? Maybe there's something new in the NSA tree that's necessary and that merely calling execve_secure() is not enough.
Does your /etc/security/default_contexts have the right stuff?
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.
Quoted 5 lines · Russell Coker
Quoted 1 line · Colin Walters
Warning! Could not get new context for tty1, not relabeling.
Which may mean that the original type for the device node is not one that is expected. Please tell me what "ls --context
/dev/tty1" reports.
meta:/var/log# ls --context /dev/tty1 crw------- root tty system_u:object_r:tty_device_t /dev/tty1 meta:/var/log#
Quoted 2 lines
However this should have nothing to do with the ability to login and run a session in the correct context.
Yeah.
Quoted 3 lines
This is wrong. There's a
domain_auto_trans()rule to transition touser_tfor when using a login program that is not aware of SE Linux. So it looks like the target context is not being set.
Well this is embarassing, but apparently HAVE_SELINUX wasn't getting defined by my openssh build (the debian/rules file was overriding CFLAGS). Now that I've fixed that, I get:
Jul 8 21:41:52 meta sshd[642]: Accepted password for root from ::ffff:192.168.1.100 port 36286 ssh2 Jul 8 21:41:52 meta sshd[642]: fatal: Failed to get default security context for root.
The same thing happens with a normal user.
Quoted 10 lines
Under the new scheme I believe that some file is supposed to be written under /proc for this. Make sure that the right stuff is mounted under /proc, the file is available, etc.
Also while in permissive mode do some tests at the command line, do:
# echo user_u:user_r:user_t > /proc/whatever-it-is # idThen id should report a context of user_u:user_r:user_t if the context change is working correctly.
Here's what I get:
meta:/var/log# cat /proc/self/attr/current && echo system_u:system_r:user_t meta:/var/log# echo root:system_r:sysadm_r > /proc/self/attr/current meta:/var/log# cat /proc/self/attr/current && echo system_u:system_r:user_t meta:/var/log#
Quoted 3 lines
Does the NSA supplied patch for 2.5.x do the same things as the patch for 2.4.x? Maybe there's something new in the NSA tree that's necessary and that merely calling
execve_secure()is not enough.
Well, there is no execve_secure() anymore; now you have to call setexeccon. But their patch does appear to be doing the right things, at least according to their PORTING document.
Quoted 1 line
Does your
/etc/security/default_contextshave the right stuff?
It looks like this:
system_r:local_login_t user_r:user_t staff_r:staff_t system_r:sshd_t user_r:user_t staff_r:staff_t system_r:crond_t user_r:user_crond_t staff_r:staff_crond_t system_r:system_crond_t
--
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.
Quoted 5 lines · Colin Walters
Quoted 1 line
is expected. Please tell me what "ls --context
/dev/tty1" reports.meta:/var/log# ls --context /dev/tty1 crw------- root tty system_u:object_r:tty_device_t /dev/tty1 meta:/var/log#
That's what we want to see.
Quoted 5 lines
Jul 8 21:41:52 meta sshd[642]: Accepted password for root from::ffff:192.168.1.100 port 36286 ssh2 Jul 8 21:41:52 meta sshd[642]: fatal:
Failed to get default security context for root.The same thing happens with a normal user.
What is the line in the "users" file for root? Is there a line in the "users" file for the non-root user you tried? If not is there a line for user_u?
Quoted 7 lines
Quoted 6 lines
Also while in permissive mode do some tests at the command line, do:
# echo user_u:user_r:user_t > /proc/whatever-it-is # idThen id should report a context of user_u:user_r:user_t if the context change is working correctly.
Quoted 8 lines
Here's what I get:
meta:/var/log# cat /proc/self/attr/current && echo system_u:system_r:user_t meta:/var/log# echo root:system_r:sysadm_r > /proc/self/attr/current meta:/var/log# cat /proc/self/attr/current && echo system_u:system_r:user_t meta:/var/log#
Sorry, you misunderstood my message.
I mean to echo a value to the file that specifies the context for the child process (you can't change the context of a running process, not even in permissive mode).
Quoted 8 lines
Quoted 1 line
Does your
/etc/security/default_contextshave the right stuff?It looks like this:
system_r:local_login_t user_r:user_t staff_r:staff_t system_r:sshd_t user_r:user_t staff_r:staff_t system_r:crond_t user_r:user_crond_t staff_r:staff_crond_tsystem_r:system_crond_t
Have you checked that sshd is running as system_u:system_r:sshd_t and that the "users" file permits the contexts user_r:user_t or staff_r:staff_t? If you configured "root" to only be permitted the context sysadm_r:sysadm_t then it will be impossible to login as root via ssh (I have intentionally configured it this way on my laptop).
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.
Quoted 6 lines · Colin Walters
I think I'm pretty close to getting my Debian system running with the SELinux 2.5 bits. However, I can't seem to get either the patched sshd or login to give me the correct context. When I login (using login) as root, I see:
Warning! Could not get new context for tty1, not relabeling.
Did you remember to mount selinuxfs on /selinux, as described in the selinux-doc README? Otherwise, the daemons cannot obtain security policy decisions from the kernel, such as the new label for the tty.
Quoted 5 lines
...followed by a bunch of avc denials about tty1 and /root, and then my context is:
meta:~# id uid=0(root) gid=0(root) groups=0(root) context:system_u:system_r:user_t
Verify that execcon or runcon work for you, e.g.
execcon root:sysadm_r:sysadm_t bash
If so, then you need to verify that your login patch is properly calling setexeccon() with a legitimate user context prior to exec'ing the shell and that the call is not failing.
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.
Quoted 6 lines · Colin Walters
Hi,
I think I'm pretty close to getting my Debian system running with the SELinux 2.5 bits. However, I can't seem to get either the patched sshd or login to give me the correct context. When I login (using login) as root, I see:
Also, make sure that the login process is running in the correct domain, i.e. local_login_t. You need to relabel /bin/login to login_exec_t after updating it.
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.
Quoted 6 lines · Russell Coker
Also while in permissive mode do some tests at the command line, do:
# echo user_u:user_r:user_t > /proc/whatever-it-is # idThen id should report a context of user_u:user_r:user_t if the context change is working correctly.
You can't change your context on-the-fly like this, since we only permit context transitions upon exec, and you cannot effectively test /proc/self/attr/exec from the shell, as the attribute is per-process and automatically cleared upon exec. You can use the 'execcon' utility from libselinux or 'runcon' (formerly runas) from the patched coreutils to try it, e.g. 'execcon root:sysadm_r:sysadm_t /bin/bash'.
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.
Quoted 3 lines · Stephen Smalley
Did you remember to mount selinuxfs on /selinux, as described in the selinux-doc README? Otherwise, the daemons cannot obtain security policy decisions from the kernel, such as the new label for the tty.
Yes, I've done that.
Quoted 2 lines
Verify that execcon or runcon work for you, e.g.
execcon root:sysadm_r:sysadm_t bash
It seems to work fine; my context is correct afterwards.
Quoted 3 lines
If so, then you need to verify that your login patch is properly calling
setexeccon()with a legitimate user context prior to exec'ing the shell and that the call is not failing.
Ok, thanks for the hint, I'll double check that.
--
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.
Quoted 7 lines · Colin Walters
Quoted 3 lines · Stephen Smalley
Did you remember to mount selinuxfs on /selinux, as described in the selinux-doc README? Otherwise, the daemons cannot obtain security policy decisions from the kernel, such as the new label for the tty.
Yes, I've done that.
Try running the compute_relabel utility from libselinux, e.g.:
$ compute_relabel root:sysadm_r:sysadm_t system_u:object_r:tty_device_t chr_file
It should display something like:
root:object_r:sysadm_tty_device_t
If that works, then check what login is actually passing to security_compute_relabel, e.g. is the user context a valid context? is the tty context that is being passed correct?
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.
Quoted 2 lines
Have you checked that sshd is running as system_u:system_r:sshd_t
Ah hah! That was exactly the problem. After fixing that it works fine.
--
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.