TTY question
Hi,
I don't quite understand the difference between all the TTY/PTY devices on Linux - could you explain how this works a bit, so that I will know for the future.
Which of those rules would be required for stdin/stdout?
allow $1_$2_t tty_device_t:chr_file rw_file_perms; allow $1_$2_t $1_tty_device_t:chr_file rw_file_perms;
allow $1_$2_t devtty_t:chr_file rw_file_perms;
allow $1_$2_t devpts_t:dir r_dir_perms;
allow $1_$2_t $1_devpts_t:chr_file rw_file_perms;
What about proc permissions required?
Can some of those rules be put in a macro of some sort. I see tty rules all over the selinux policy, and perhaps they could be made more consistent with a macro.
Signature · 8 lines
Ivan Gyurdiev <[email protected]> Cornell University -- 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.
tty refers to the system console or virtual consoles accessable via terminal and keyboard. pty is the designation for any remote connections assignments, ie. ssh user shell. The main purpose is to
separate console user from the remote user for accountability. TTY's
are not able to generate the high volume load that a PTY would for physical reasons; unless you build a killer keyboard for it.
By setting up different rules for tty/pty on a user. Console access
could allow extended privileges, where in remote access from another
system would block that access. For the rest, I will have to check
on that later; or someone else may provide assistance. I am currently stuck in patching windows ...... again.
Jim McCullough
Quoted 30 lines · Ivan Gyurdiev
Hi,
I don't quite understand the difference between all the TTY/PTY devices on Linux - could you explain how this works a bit, so that I will know for the future.
Which of those rules would be required for stdin/stdout?
allow $1_$2_t tty_device_t:chr_file
rw_file_perms; allow $1_$2_t $1_tty_device_t:chr_filerw_file_perms;allow $1_$2_t devtty_t:chr_file
rw_file_perms;
allow $1_$2_t devpts_t:dirr_dir_perms;
allow $1_$2_t $1_devpts_t:chr_filerw_file_perms;What about proc permissions required?
Can some of those rules be put in a macro of some sort. I see tty rules all over the selinux policy, and perhaps they could be made more consistent with a macro.
--
Ivan Gyurdiev <[email protected]>
Cornell University--
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.
Signature · 6 lines
Jim McCullough -- 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 · Ivan Gyurdiev
Which of those rules would be required for stdin/stdout?
Depends on what your stdin/stdout references, naturally.
Quoted 1 line
allow $1_$2_t tty_device_t:chr_file
rw_file_perms;
This rule shouldn't be necessary. A user domain or associated program domain should only be acting upon a tty that has already been relabeled to one of the $1_tty_device_t types. Only processes that need to act upon ttys that are not necessarily associated with any session should have permissions to tty_device_t itself, e.g. system initialization processes, login, etc.
Quoted 1 line
allow $1_$2_t $1_tty_device_t:chr_file
rw_file_perms;
This rule allows access to a tty that has already been relabeled for your domain. I think it should only be needed for console sessions, although we typically haven't restricted it in the past for user domains and their associated program domains.
Quoted 1 line
allow $1_$2_t devtty_t:chr_file
rw_file_perms;
This rule allows access to the /dev/tty device that is always mapped to the controlling terminal of the process if any. Should be allowed.
Quoted 2 lines
allow $1_$2_t devpts_t:dir
r_dir_perms;
allow $1_$2_t $1_devpts_t:chr_filerw_file_perms;
This rule allows access to a pty that has already been relabeled for your domain or that was initially created by your domain. Necessary for X terminals, ssh sessions, etc. Should be allowed. Note that you also need permissions to ptmx_t if your domain needs to actually create ptys. This is typically covered by the can_create_pty macro.
Quoted 1 line
What about proc permissions required?
Sorry, what do you mean? Do you mean being able to access /proc/self/fd/n? If so, then you need to be able to search proc_t:dir, proc_t:lnk_file, self:dir, and read self:lnk_file.
Quoted 3 lines
Can some of those rules be put in a macro of some sort. I see tty rules all over the selinux policy, and perhaps they could be made more consistent with a macro.
Possibly.
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 5 lines
in a macro of some sort.
Quoted 2 lines
I see tty rules all over the selinux policy, and perhaps they could be made more consistent with a macro.
Possibly.
Maybe something like this:
# access_terminal(prefix, domain)
access_terminal(`
allow $1_$2_t $1_tty_device_t:chr_file rw_file_perms;
allow $1_$2_t devtty_t:chr_file rw_file_perms;
allow $1_$2_t devpts_t:dir r_dir_perms;
allow $1_$2_t $1_devpts_t:chr_file rw_file_perms;') dnl access_terminal
Then use this in:
- mplayer_macros
- mount_macros
- x_client_macros
- gpg_macros
- gpg_agent macros
- su_macros
- xauth_macros
- irc_macros
- chkpwd_macros
- cdrecord macros
other places?
Signature · 8 lines
Ivan Gyurdiev <[email protected]> Cornell University -- 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 · Ivan Gyurdiev
#
access_terminal(prefix, domain)
access_terminal(`allow $1_$2_t $1_tty_device_t:chr_file rw_file_perms; allow $1_$2_t devtty_t:chr_file rw_file_perms; allow $1_$2_t devpts_t:dir r_dir_perms; allow $1_$2_t $1_devpts_t:chr_file rw_file_perms;') dnl
access_terminal
Why not just:
# access_terminal(domain, typeprefix)
define(access_terminal',
allow $1 $2_tty_device_t:chr_file rw_file_perms;
allow $1 devtty_t:chr_file rw_file_perms;
allow $1 devpts_t:dir r_dir_perms;
allow $1 $2_devpts_t:chr_file rw_file_perms;
') dnl access_terminal
Then the usage in e.g. x_client_domain becomes:access_terminal($1_$2_t, $1)
whereas elsewhere it may just be:access_terminal($1_t, $1)
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 10 lines
Why not just:
#access_terminal(domain, typeprefix)define(access_terminal',
allow $1 $2_tty_device_t:chr_filerw_file_perms; allow $1 devtty_t:chr_filerw_file_perms; allow $1 devpts_t:dirr_dir_perms;
allow $1 $2_devpts_t:chr_filerw_file_perms; ') dnlaccess_terminal
Quoted 5 lines
Then the usage in e.g.
x_client_domainbecomes:access_terminal($1_$2_t, $1)whereas elsewhere it may just be:
access_terminal($1_t, $1)
That's better :)
I'll write some patches against dwalsh's repository.
Quoted 1 line
Signature · 8 lines
Ivan Gyurdiev <[email protected]> Cornell University -- 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 9 lines · Ivan Gyurdiev
Quoted 9 lines
Why not just:
#access_terminal(domain, typeprefix)define(access_terminal',
allow $1 $2_tty_device_t:chr_filerw_file_perms; allow $1 devtty_t:chr_filerw_file_perms; allow $1 devpts_t:dirr_dir_perms;
allow $1 $2_devpts_t:chr_filerw_file_perms; ') dnlaccess_terminal
Quoted 5 lines
Quoted 5 lines
Then the usage in e.g.
x_client_domainbecomes:access_terminal($1_$2_t, $1)whereas elsewhere it may just be:
access_terminal($1_t, $1)
Should
allow $1 privfd:fd use;
be in that macro?
What does that do?
I see it next to the other rules.
Signature · 8 lines
Ivan Gyurdiev <[email protected]> Cornell University -- 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 · Ivan Gyurdiev
Should
allow $1 privfd:fd use;
be in that macro?What does that do?
I see it next to the other rules.
In order to inherit, receive or use an open descriptor, a domain must have both use permission to the fd (which is labeled based on the domain that performed the open) and appropriate read/write permissions (depending on the fd flags) to the file itself. The privfd attribute was originally to allow marking of certain domains like login and sshd that handled opening of the tty/pty for use in allow rules enabling many other domains to inherit and use the descriptors from these domains. newrole actually closes and re-opens descriptors 0-2 in order to get them into its domain so that subsequent programs only need to inherit from it rather than from the original user domain. However, this proved problematic for su and sudo, and the current policy associates privfd with the user domains as well so that programs run from su'd shells or via sudo are able to inherit the descriptors as well. It would be preferable to introduce a proxy pty into su and sudo similar to what has been done recently by Manoj for run_init in order to properly isolate and protect the different domains.
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.
Does this look reasonable?
Signature · 2 lines
Ivan Gyurdiev <[email protected]> Cornell University
global_macros.new renamed from global_macros.te +13 -0
@@ -156,6 +156,19 @@ r_dir_file($1, locale_t) ') +################################### +# +# access_terminal(domain, typeprefix) +# +# Permissions for accessing the terminal +# +define(`access_terminal', ` +allow $1 $2_tty_device_t:chr_file rw_file_perms; +allow $1 devtty_t:chr_file rw_file_perms; +allow $1 devpts_t:dir r_dir_perms; +allow $1 $2_devpts_t:chr_file rw_file_perms; +') + # # general_proc_read_access(domain) #
cdrecord_macros.te +1 -2
@@ -17,8 +17,7 @@ allow $1_t $1_cdrecord_t:process signal; # write to the user domain tty. -allow $1_cdrecord_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_cdrecord_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_cdrecord_t, $1) allow $1_cdrecord_t privfd:fd use; allow $1_cdrecord_t $1_t:unix_stream_socket { getattr read write ioctl };
chkpwd_macros.te +1 -2
@@ -44,8 +44,7 @@ role system_r types sysadm_chkpwd_t; # Write to the user domain tty. -allow $1_chkpwd_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_chkpwd_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_chkpwd_t, $1) allow $1_chkpwd_t privfd:fd use;
clamav_macros.te +1 -2
@@ -48,8 +48,7 @@ clamscan_domain($1) role $1_r types $1_clamscan_t; domain_auto_trans($1_t, clamscan_exec_t, $1_clamscan_t) -allow $1_clamscan_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_clamscan_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_clamscan_t, $1) r_dir_file($1_clamscan_t,$1_home_t); r_dir_file($1_clamscan_t,$1_home_dir_t); allow $1_clamscan_t $1_home_t:file r_file_perms;
crontab_macros.te +1 -2
@@ -87,8 +87,7 @@ # Access terminals. allow $1_crontab_t device_t:dir search; -allow $1_crontab_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_crontab_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_crontab_t, $1); allow $1_crontab_t fs_t:filesystem getattr;
gpg_agent_macros.te +1 -3
@@ -25,9 +25,7 @@ allow $1_gpg_agent_t xdm_t:fd use; # Write to the user domain tty. -allow $1_gpg_agent_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_gpg_agent_t $1_devpts_t:chr_file rw_file_perms; -allow $1_gpg_agent_t devtty_t:chr_file { read write }; +access_terminal($1_gpg_agent_t, $1) # Allow the user shell to signal the gpg-agent program. allow $1_t $1_gpg_agent_t:process { signal sigkill };
gpg_macros.te +1 -3
@@ -43,8 +43,7 @@ allow $1_gpg_t self:unix_stream_socket create_stream_socket_perms; allow $1_gpg_t self:tcp_socket create_stream_socket_perms; -allow $1_gpg_t devpts_t:dir search; -allow $1_gpg_t { $1_devpts_t $1_tty_device_t }:chr_file rw_file_perms; +access_terminal($1_gpg_t, $1) ifdef(`gnome-pty-helper.te', `allow $1_gpg_t $1_gph_t:fd use;') # Inherit and use descriptors
@@ -84,7 +83,6 @@ } allow $1_gpg_t self:capability { ipc_lock setuid }; -allow $1_gpg_t devtty_t:chr_file rw_file_perms; rw_dir_create_file($1_gpg_t, $1_file_type) allow $1_gpg_t { etc_t usr_t }:dir r_dir_perms;
irc_macros.te +1 -6
@@ -47,14 +47,13 @@ allow $1_irc_t usr_t:file { getattr read }; +access_terminal($1_irc_t, $1) uses_shlib($1_irc_t) allow $1_irc_t etc_t:file { read getattr }; read_locale($1_irc_t) allow $1_irc_t fs_t:filesystem getattr; allow $1_irc_t var_t:dir search; -allow $1_irc_t devpts_t:dir { getattr read search }; allow $1_irc_t device_t:dir search; -allow $1_irc_t devtty_t:chr_file rw_file_perms; allow $1_irc_t self:unix_stream_socket create_stream_socket_perms; allow $1_irc_t privfd:fd use; allow $1_irc_t proc_t:dir search;
@@ -62,10 +61,6 @@ allow $1_irc_t self:dir search; dontaudit $1_irc_t var_run_t:dir search; -# Write to the user domain tty. -allow $1_irc_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_irc_t $1_devpts_t:chr_file rw_file_perms; - # allow utmp access allow $1_irc_t initrc_var_run_t:file read; dontaudit $1_irc_t initrc_var_run_t:file lock;
java_macros.te +1 -3
@@ -86,6 +86,7 @@ legacy_domain($1_java) +access_terminal($1_java_t, $2) uses_shlib($1_java_t) read_locale($1_java_t) rw_dir_file($1_java_t, $1_rw_t)
@@ -108,9 +109,6 @@ dontaudit $1_java_t fonts_t:file execute; dontaudit $1_java_t sound_device_t:chr_file execute; -dontaudit $1_java_t $2_devpts_t:chr_file { read write }; -dontaudit $1_java_t sysadm_devpts_t:chr_file { read write }; -dontaudit $1_java_t devtty_t:chr_file { read write }; dontaudit $1_java_t tmpfs_t:file { execute read write }; dontaudit $1_java_t $1_rw_t:file { execute setattr };
lockdev_macros.te +1 -1
@@ -36,7 +36,7 @@ allow $1_lockdev_t device_t:dir search; allow $1_lockdev_t null_device_t:chr_file rw_file_perms; -allow $1_lockdev_t { $1_tty_device_t $1_devpts_t }:chr_file rw_file_perms; +access_terminal($1_lockdev_t, $1) dontaudit $1_lockdev_t root_t:dir search; uses_shlib($1_lockdev_t)
lpr_macros.te +1 -2
@@ -64,8 +64,7 @@ allow $1_lpr_t device_t:dir search; # Access the terminal. -allow $1_lpr_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_lpr_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_lpr_t, $1) # Inherit and use descriptors from gnome-pty-helper. ifdef(`gnome-pty-helper.te', `allow $1_lpr_t $1_gph_t:fd use;')
mount_macros.te +1 -2
@@ -63,8 +63,7 @@ allow $2_t sbin_t:lnk_file read; # Access the terminal. -allow $2_t $1_tty_device_t:chr_file { getattr read write ioctl }; -allow $2_t $1_devpts_t:chr_file { getattr read write }; +access_terminal($2_t, $1) ifdef(`gnome-pty-helper.te', `allow $2_t $1_gph_t:fd use;') allow $2_t var_t:dir search; allow $2_t var_run_t:dir search;
mplayer_macros.te +2 -12
@@ -40,19 +40,11 @@ allow $1_$2_t sysctl_kernel_t:dir search; allow $1_$2_t sysctl_kernel_t:file { getattr read }; -# allow ps +# Allow ps, shared libs, locale, terminal access can_ps($1_t, $1_$2_t) - -# uses shared libraries uses_shlib($1_$2_t) - -# localization read_locale($1_$2_t) - -# Access the terminal. -allow $1_$2_t devpts_t:dir { search }; -allow $1_$2_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_$2_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_$2_t, $1) # Required for win32 binary loader allow $1_$2_t zero_device_t:chr_file { read write execute };
@@ -64,8 +56,6 @@ allow $1_$2_t zero_device_t:chr_file execmod; } - - # Access to DVD/CD/V4L allow $1_$2_t device_t:dir r_dir_perms; allow $1_$2_t device_t:lnk_file { getattr read };
mta_macros.te +2 -3
@@ -87,10 +87,9 @@ allow mta_user_agent $1_tmp_t:file { read getattr }; -allow mta_user_agent { $1_devpts_t $1_tty_device_t }:chr_file { getattr read write }; - # Write to the user domain tty. -allow $1_mail_t { $1_tty_device_t $1_devpts_t devtty_t }:chr_file rw_file_perms; +access_terminal(mta_user_agent, $1) +access_terminal($1_mail_t, $1) # Inherit and use descriptors from gnome-pty-helper. ifdef(`gnome-pty-helper.te', `allow $1_mail_t $1_gph_t:fd use;')
slocate_macros.te +1 -4
@@ -47,10 +47,7 @@ allow $1_t $1_locate_t:process signal; uses_shlib($1_locate_t) - -# Write to the user domain tty. -allow $1_locate_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_locate_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_locate_t, $1) allow $1_locate_t { home_root_t $1_home_dir_t $1_file_type }:dir { getattr search }; allow $1_locate_t $1_file_type:{ file lnk_file } { getattr read };
ssh_agent_macros.te +1 -3
@@ -27,9 +27,7 @@ allow $1_ssh_agent_t privfd:fd use; # Write to the user domain tty. -allow $1_ssh_agent_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_ssh_agent_t $1_devpts_t:chr_file rw_file_perms; -allow $1_ssh_agent_t devtty_t:chr_file { read write }; +access_terminal($1_ssh_agent_t, $1) # Allow the user shell to signal the ssh program. allow $1_t $1_ssh_agent_t:process signal;
ssh_macros.te +2 -7
@@ -52,9 +52,6 @@ base_file_read_access($1_ssh_t) -# Read the devpts root directory. -allow $1_ssh_t devpts_t:dir r_dir_perms; - # Read /var. allow $1_ssh_t var_t:dir r_dir_perms; allow $1_ssh_t var_t:notdevfile_class_set r_file_perms;
@@ -77,8 +74,7 @@ # Read /dev/urandom. allow $1_ssh_t urandom_device_t:chr_file r_file_perms; -# Read and write /dev/tty and /dev/null. -allow $1_ssh_t devtty_t:chr_file rw_file_perms; +# Read and write /dev/null. allow $1_ssh_t { null_device_t zero_device_t }:chr_file rw_file_perms; # Grant permissions needed to create TCP and UDP sockets and
@@ -127,8 +123,7 @@ ifdef(`gnome-pty-helper.te', `allow $1_ssh_t $1_gph_t:fd use;') # Write to the user domain tty. -allow $1_ssh_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_ssh_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_ssh_t, $1) # Allow the user shell to signal the ssh program. allow $1_t $1_ssh_t:process signal;
su_macros.te +2 -4
@@ -99,7 +99,7 @@ } # Relabel ttys and ptys. -allow $1_su_t { device_t devpts_t }:dir { getattr read search }; +allow $1_su_t device_t:dir { getattr read search }; allow $1_su_t { ttyfile ptyfile }:chr_file { relabelfrom relabelto }; # Close and re-open ttys and ptys to get the fd into the correct domain.
@@ -121,9 +121,7 @@ role $1_r types $1_su_t; # Write to the user domain tty. -allow $1_su_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_su_t $1_devpts_t:chr_file rw_file_perms; -allow $1_su_t { sysadm_tty_device_t sysadm_devpts_t }:chr_file { getattr ioctl }; +access_terminal($1_su_t, $1) allow $1_su_t { home_root_t $1_home_dir_t }:dir search; allow $1_su_t $1_home_t:file create_file_perms;
uml_macros.te +1 -3
@@ -110,7 +110,6 @@ dontaudit $1_uml_t initrc_var_run_t:file { write lock }; allow $1_uml_t device_t:dir search; -allow $1_uml_t devtty_t:chr_file rw_file_perms; allow $1_uml_t self:unix_stream_socket create_stream_socket_perms; allow $1_uml_t self:unix_dgram_socket create_socket_perms; allow $1_uml_t privfd:fd use;
@@ -121,8 +120,7 @@ allow $1_uml_t proc_t:file write; # Write to the user domain tty. -allow $1_uml_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_uml_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_uml_t, $1) # access config files allow $1_uml_t home_root_t:dir search;
xauth_macros.te +1 -2
@@ -66,8 +66,7 @@ allow $1_xauth_t fs_t:filesystem getattr; # Write to the user domain tty. -allow $1_xauth_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_xauth_t $1_devpts_t:chr_file rw_file_perms; +access_terminal($1_xauth_t, $1) # Scan /var/run. allow $1_xauth_t var_t:dir search;
x_client_macros.te +1 -6
@@ -57,9 +57,9 @@ allow $1_$2_t etc_runtime_t:file { getattr read }; allow $1_$2_t etc_t:lnk_file read; allow $1_$2_t fs_t:filesystem getattr; +access_terminal($1_$2_t, $1) read_locale($1_$2_t) r_dir_file($1_$2_t, readable_t) -allow $1_$2_t devtty_t:chr_file { read write }; allow $1_$2_t proc_t:dir search; allow $1_$2_t proc_t:lnk_file read; allow $1_$2_t self:dir search;
@@ -143,11 +143,6 @@ can_tcp_connect($1_$2_t, sshd_t) ') -# Access the terminal. -allow $1_$2_t devpts_t:dir search; -allow $1_$2_t $1_tty_device_t:chr_file rw_file_perms; -allow $1_$2_t $1_devpts_t:chr_file rw_file_perms; - # Read the home directory, e.g. for .Xauthority and to get to config files allow $1_$2_t home_root_t:dir { search getattr }; file_type_auto_trans($1_$2_t, $1_home_dir_t, $1_$2_rw_t)
Quoted 1 line · Ivan Gyurdiev
Does this look reasonable?
- The patch removes a rule giving $1_su_t certain permissions to sysadm tty/pty types, likely requires testing to verify that this doesn't present a problem for proper handling and subsequent restoration of the label when the su'd shell exits.
- It might be desirable to reduce the permissions allowed by the macro from rw_file_perms to just { read write getattr }, as I see that many domains were only being given those permissions previously. Likewise, might want to reduce r_dir_perms down to just { read search getattr }.
Otherwise, looks sane to me (subject to testing, of course).
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 5 lines · Stephen Smalley
Quoted 1 line · Ivan Gyurdiev
Does this look reasonable?
- The patch removes a rule giving $1_su_t certain permissions to sysadm tty/pty types,
There's su_domain($1) in admin_macros.te, so access_terminal(sysadm_su_t, sysadm_t) should be invoked.
Quoted 7 lines
likely requires testing to verify that this doesn't
present a problem for proper handling and subsequent restoration of the label when the su'd shell exits.
- It might be desirable to reduce the permissions allowed by the macro fromrw_file_permsto just { read write getattr }, as I see that many domains were only being given those permissions previously. Likewise, might want to reducer_dir_permsdown to just { read search getattr }.
Changed, but it creates problems:
audit(1108067222.381:0): avc: denied { ioctl } for pid=5435 exe=/bin/su path=/dev/pts/1 dev=devpts ino=3 scontext=root:sysadm_r:sysadm_su_t tcontext=root:object_r:sysadm_devpts_t tclass=chr_file
Rebooting to see if I get denials during boot sequence...
Signature · 8 lines
Ivan Gyurdiev <[email protected]> Cornell University -- 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 · Ivan Gyurdiev
There's
su_domain($1)in admin_macros.te, soaccess_terminal(sysadm_su_t, sysadm_t)should be invoked.
Yes, but that doesn't help if you are starting in user_t (if user_canbe_sysadm is enabled) or staff_t. There was a specific rule removed by the patch between $1_su_t and sysadm_*_t, not just $1_*_t. Not clear whether those permissions were truly necessary or not, but su does need to be able to restore the label on the tty/pty when the su'd shell exits.
Quoted 6 lines
Changed, but it creates problems:
audit(1108067222.381:0): avc: denied { ioctl } for pid=5435 exe=/bin/su path=/dev/pts/1 dev=devpts ino=3 scontext=root:sysadm_r:sysadm_su_t tcontext=root:object_r:sysadm_devpts_t tclass=chr_file
Yes, but the question is whether this is always needed for all domains using this macro or whether we can selectively allow it for certain domains. A diff of the generated policy before and after showed that many domains only had getattr read write prior to the patch.
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 10 lines · Stephen Smalley
Quoted 2 lines · Ivan Gyurdiev
There's
su_domain($1)in admin_macros.te, soaccess_terminal(sysadm_su_t, sysadm_t)should be invoked.Yes, but that doesn't help if you are starting in
user_t(ifuser_canbe_sysadmis enabled) orstaff_t. There was a specific rule removed by the patch between $1_su_t and sysadm_*_t, not just $1_*_t. Not clear whether those permissions were truly necessary or not, but su does need to be able to restore the label on the tty/pty when the su'd shell exits.
It's restored fine./dev/pts/x goes to sysadm_devpts_t after su
and back to user_devpts_t after exit.
There are no denials.
Quoted 11 lines
Quoted 6 lines
Changed, but it creates problems:
audit(1108067222.381:0): avc: denied { ioctl } for pid=5435 exe=/bin/su path=/dev/pts/1 dev=devpts ino=3 scontext=root:sysadm_r:sysadm_su_t tcontext=root:object_r:sysadm_devpts_t tclass=chr_file
Yes, but the question is whether this is always needed for all domains using this macro or whether we can selectively allow it for certain domains. A diff of the generated policy before and after showed that many domains only had getattr read write prior to the patch.
Actually the vast majority of domains had rw_file_perms allowed. On the other hand I haven't gotten any denials so far other than an ioctl for su (which makes the system unusable).
The permissions you want to remove are { append lock ioctl } on chr_file, and { lock ioctl } on dir.
What should I do? ioctl could be allowed for su for now, and then if denials show up it could be reverted to rw_perms in the macro.
P.S. The java policy had dontaudit tty rules and not allow. I changed them by accident. Should they be changed back, or do you think allow is correct?
Quoted 1 line
Signature · 8 lines
Ivan Gyurdiev <[email protected]> Cornell University -- 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 · Ivan Gyurdiev
It's restored fine.
/dev/pts/xgoes tosysadm_devpts_tafter su
and back touser_devpts_tafter exit.There are no denials.
Ok, good.
Quoted 5 lines
The permissions you want to remove are { append lock ioctl } on
chr_file, and { lock ioctl } on dir.What should I do? ioctl could be allowed for su for now, and then if denials show up it could be reverted to
rw_permsin the macro.
I'd reduce the permissions in the macro for now, and just give ioctl to su via a separate allow rule.
Quoted 3 lines
P.S. The java policy had dontaudit tty rules and not allow. I changed them by accident. Should they be changed back, or do you think allow is correct?
I don't have that policy in our tree. Is it for the java plugin run from mozilla or for java run by a user domain? If the former, likely want dontaudit. If the latter, likely want/need allow.
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 8 lines
Quoted 4 lines
P.S. The java policy had dontaudit tty rules and not allow. I changed them by accident. Should they be changed back, or do you think allow is correct?I don't have that policy in our tree. Is it for the java plugin run from mozilla or for java run by a user domain? If the former, likely want dontaudit. If the latter, likely want/need allow.
Well, it's the one Daniel Walsh has been writing, and he said it's for a java plugin, so I guess I'll revert to dontaudit for now.
Thank you for the input - will send patches against FC.
Quoted 1 line
Signature · 8 lines
Ivan Gyurdiev <[email protected]> Cornell University -- 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 14 lines · Ivan Gyurdiev
Quoted 4 lines
Quoted 4 lines
P.S. The java policy had dontaudit tty rules and not allow.
I changed them by accident. Should they be changed back, or do you think allow is correct?Quoted 9 lines
I don't have that policy in our tree. Is it for the java plugin run
from mozilla or for java run by a user domain? If the former, likely
want dontaudit. If the latter, likely want/need allow.
Quoted 7 lines
Well, it's the one Daniel Walsh has been writing, and he said it's for a java plugin, so I guess I'll revert to dontaudit for now.
Thank you for the input - will send patches against FC.
Java policy is just for running from mozilla. IE Plugin, A full java policy as I stated before does not make much sense.
--
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 8 lines · Stephen Smalley
Quoted 5 lines · Ivan Gyurdiev
It's restored fine.
/dev/pts/xgoes tosysadm_devpts_tafter su
and back touser_devpts_tafter exit.There are no denials.
Ok, good.
Actually here's probably why:
it's duplicated in su_mini_domain:
# Close and re-open ttys and ptys to get the fd into the correct domain. allow $1_su_t { ttyfile ptyfile }:chr_file { read write };
So it's all good.
Signature · 8 lines
Ivan Gyurdiev <[email protected]> Cornell University -- 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 · Ivan Gyurdiev
Actually here's probably why:
it's duplicated insu_mini_domain:# Close and re-open ttys and ptys to get the fd into the correct domain. allow $1_su_t { ttyfile ptyfile }:chr_file { read write };
So it's all good.
That likely isn't necessary presently, as su/pam_selinux no longer does that (it caused breakage; we'd have to directly patch su to do it right, and at that point, we'd likely just introduce a proxy pty).
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.