Skip to contentSkip to conversation

fix /var/run/console bits

PATCH In review Colin Walters 5 participants 7 messages Aug 4, 2004 – Aug 5, 2004 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fix /var/run/console bits

Hi,

Currently /var/run/console is labeled as xdm_var_run_t, which is totally wrong, since it's actually owned by pam_console. I noticed this while I was trying to work on the D-BUS policy, which recently gained console user authentication.

Attached is a patch which creates a new type for it, grants the requisite permissions to login and xdm. I still think we need a nicer way of mapping the PAM permissions in policy. The only reason that login and xdm are granted these permissions is because they happen to ship with pam_console in their PAM stack on Fedora, presumably. (IIRC Debian doesn't use pam_console).

But this patch should work better in the short term at least; if it's accepted I'll post a little patch to update dbusd.te too.

file_contexts/program/pam.fc renamed from file_contexts/program/pam.fc~ +1 -0
@@ -1,3 +1,4 @@
 /var/run/sudo(/.*)?			system_u:object_r:pam_var_run_t
+/var/run/console.*			system_u:object_r:pam_var_console_t
 /sbin/pam_timestamp_check	 --	system_u:object_r:pam_exec_t
 /lib(64)?/security/pam_krb5/pam_krb5_storetmp -- system_u:object_r:pam_exec_t
file_contexts/program/xdm.fc renamed from file_contexts/program/xdm.fc~ +0 -1
@@ -16,7 +16,6 @@
 /etc/X11/[wx]dm/Xsession	--	system_u:object_r:xsession_exec_t
 /etc/kde/kdm/Xsession	--	system_u:object_r:xsession_exec_t
 /var/run/xdmctl(/.*)?		system_u:object_r:xdm_var_run_t
-/var/run/console.*		system_u:object_r:xdm_var_run_t
 /var/lib/[xkw]dm(/.*)?		system_u:object_r:xdm_var_lib_t
 /usr/lib/qt-3.3/etc/settings/qtrc(/.*)? system_u:object_r:xdm_var_lib_t
 
domains/program/unused/xdm.te renamed from domains/program/unused/xdm.te~ +3 -0
@@ -291,6 +291,9 @@
 allow xdm_t pam_var_run_t:file create_file_perms;
 allow pam_t xdm_t:fifo_file { getattr ioctl write };
 can_exec(xdm_t, pam_exec_t)
+# For pam_console
+rw_dir_create_file(xdm_t, var_run_t)
+rw_dir_create_file(xdm_t, pam_var_console_t)
 ')
 
 allow xdm_t var_log_t:file { read };
domains/program/unused/pam.te renamed from domains/program/unused/pam.te~ +2 -0
@@ -10,6 +10,8 @@
 allow pam_t pam_var_run_t:dir { search getattr read write remove_name };
 allow pam_t pam_var_run_t:file { getattr read unlink };
 
+type pam_var_console_t, file_type, sysadmfile;
+
 role system_r types pam_t;
 in_user_role(pam_t)
 domain_auto_trans(userdomain, pam_exec_t, pam_t)
domains/program/login.te renamed from domains/program/login.te~ +4 -8
@@ -62,6 +62,9 @@
 
 ifdef(`pam.te', `
 can_exec($1_login_t, pam_exec_t)
+# For pam_console
+rw_dir_create_file($1_login_t, var_run_t)
+rw_dir_create_file($1_login_t, pam_var_console_t)
 ')
 
 # Use capabilities
@@ -81,11 +84,8 @@
 r_dir_file($1_login_t, nfs_t)
 ')dnl end if nfs_home_dirs
 
-#
-# /var/run/console requires the following
-#
+# FIXME: what is this for?
 ifdef(`xdm.te', `
-create_dir_file($1_login_t, xdm_var_run_t)
 allow xdm_t $1_login_t:process { signull };
 ')
 
@@ -184,10 +184,6 @@
 # Allow setting of attributes on sound devices.
 allow local_login_t sound_device_t:chr_file { getattr setattr };
 
-# Allow access to /var/run/console and /var/run/console.lock.  Need a separate type?
-allow local_login_t var_run_t:dir rw_dir_perms;
-allow local_login_t var_run_t:file create_file_perms;
-
 #################################
 #
 # Rules for the remote_login_t domain.
#1 lore raw
Quoted 3 lines · Colin Walters

requisite permissions to login and xdm. I still think we need a nicer way of mapping the PAM permissions in policy. The only reason that

someone on advogato suggested porting bsd_auth to linux.

--
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
In reply to Colin Walters
Quoted 11 lines · Colin Walters

Currently /var/run/console is labeled as xdm_var_run_t, which is totally wrong, since it's actually owned by pam_console. I noticed this while I was trying to work on the D-BUS policy, which recently gained console user authentication.

Attached is a patch which creates a new type for it, grants the requisite permissions to login and xdm. I still think we need a nicer way of mapping the PAM permissions in policy. The only reason that login and xdm are granted these permissions is because they happen to ship with pam_console in their PAM stack on Fedora, presumably. (IIRC Debian doesn't use pam_console).

I think that perhaps the following would be good for the fc entry to keep the convention:
/var/run/console/(.*)? system_u:object_r:pam_var_console_t

This is not what we want. Ideally we will never have any files of type var_run_t.
rw_dir_create_file(xdm_t, var_run_t) rw_dir_create_file($1_login_t, var_run_t)

I guess that the following code is to allow the xdm to check which login processes are active when searching for an unused virtual console. If my guess is correct then signull access would need to be granted to getty_t and userdomain. Of course if you hard-code a VC in the config file then maybe this isn't needed.
# FIXME: what is this for?
ifdef(xdm.te',
allow xdm_t $1_login_t:process { signull };
')

Signature · 7 lines
http://apac.redhat.com/disclaimer
See above URL for disclaimer.

--
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 13 lines · Russell Coker
Quoted 11 lines · Colin Walters

Currently /var/run/console is labeled as xdm_var_run_t, which is totally wrong, since it's actually owned by pam_console. I noticed this while I was trying to work on the D-BUS policy, which recently gained console user authentication.

Attached is a patch which creates a new type for it, grants the requisite permissions to login and xdm. I still think we need a nicer way of mapping the PAM permissions in policy. The only reason that login and xdm are granted these permissions is because they happen to ship with pam_console in their PAM stack on Fedora, presumably. (IIRC Debian doesn't use pam_console).

Quoted 3 lines

I think that perhaps the following would be good for the fc entry to keep the convention:
/var/run/console/(.*)? system_u:object_r:pam_var_console_t

Sounds good.

Quoted 4 lines

This is not what we want. Ideally we will never have any files of type var_run_t.
rw_dir_create_file(xdm_t, var_run_t) rw_dir_create_file($1_login_t, var_run_t)

I agree, but unfortunately pam_console creates a lockfile named /var/run/console.lock. We should probably fix that.

Quoted 2 lines

I guess that the following code is to allow the xdm to check which login processes are active when searching for an unused virtual console.

Ok. I just thought it was weird at first glance, and worthy of a comment :)

#4 lore raw
Quoted 39 lines · Colin Walters
Quoted 16 lines · Russell Coker
Quoted 5 lines · Colin Walters

Currently /var/run/console is labeled as xdm_var_run_t, which is totally wrong, since it's actually owned by pam_console. I noticed this while I was trying to work on the D-BUS policy, which recently gained console user authentication.

Quoted 8 lines

Attached is a patch which creates a new type for it, grants the requisite permissions to login and xdm. I still think we need a nicer way of mapping the PAM permissions in policy. The only reason that login and xdm are granted these permissions is because they happen to ship with pam_console in their PAM stack on Fedora, presumably. (IIRC Debian doesn't use pam_console).

Quoted 4 lines

I think that perhaps the following would be good for the fc entry to keep the convention:
/var/run/console/(.*)? system_u:object_r:pam_var_console_t

Sounds good.

Quoted 5 lines

This is not what we want. Ideally we will never have any files of type var_run_t. rw_dir_create_file(xdm_t, var_run_t)
rw_dir_create_file($1_login_t, var_run_t)

I agree, but unfortunately pam_console creates a lockfile named /var/run/console.lock. We should probably fix that.

Quoted 9 lines
Quoted 3 lines

I guess that the following code is to allow the xdm to check which login processes are active when searching for an unused virtual console.

Ok. I just thought it was weird at first glance, and worthy of a comment :)

Ok I will change pam_console to put the lock file in /var/run/console directory. Then you should be able to change the rules to create files pam_var_console_t

Dan

--
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.

#5 lore raw
In reply to Colin Walters
Quoted 6 lines · Colin Walters
Quoted 4 lines

I think that perhaps the following would be good for the fc entry to keep the convention:
/var/run/console/(.*)?
system_u:object_r:pam_var_console_t

Sounds good.

Actually I did a typo, this is what is should be:
/var/run/console(/.*)? system_u:object_r:pam_var_console_t

Quoted 7 lines
Quoted 4 lines

This is not what we want. Ideally we will never have any files of type var_run_t.
rw_dir_create_file(xdm_t, var_run_t) rw_dir_create_file($1_login_t, var_run_t)

I agree, but unfortunately pam_console creates a lockfile named /var/run/console.lock. We should probably fix that.

Dan has just offered to fix that. But if it was not possible to change that then the solution would be to have a file_type_auto_trans() rule.

I've been thinking of adding neverallow rules to prevent any access to files of type var_run_t, tmp_t, and tmpfs_t...

Quoted 5 lines
Quoted 2 lines

I guess that the following code is to allow the xdm to check which login processes are active when searching for an unused virtual console.

Ok. I just thought it was weird at first glance, and worthy of a comment :)

It is weird, and probably something needs to be changed about it.

Signature · 7 lines
http://apac.redhat.com/disclaimer
See above URL for disclaimer.

--
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

Merged a modified form of this patch per the discussion on the list.

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.