Skip to contentSkip to conversation

refpolicy HEAD, Debian, ioctl on xconsole by syslogd

PATCH Václav Ovsík 3 participants 6 messages Dec 4, 2007 – Dec 21, 2007 SELinux security module

lore
Share & tools
lore
#0 lore raw

Hi,
when starting syslogd by init script:

audit(1196761642.698:3): avc: denied { ioctl } for pid=1353 comm="syslogd" name="xconsole" dev=tmpfs ino=3703 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:xconsole_device_t:s0 tclass=fifo_file

attached patch, that xserver_rw_console() gives ioctl permission. Can be merged?
Regards

Signature · 1 line
Zito
modules/services/xserver.if +1 -1
Index: policy/modules/services/xserver.if
===================================================================
@@ -773,7 +773,7 @@
 		type xconsole_device_t;
 	')
 
-	allow $1 xconsole_device_t:fifo_file { getattr read write };
+	allow $1 xconsole_device_t:fifo_file { getattr read write ioctl };
 ')
 
 ########################################
#1 lore raw
Quoted 10 lines · Václav Ovsík

Hi,
when starting syslogd by init script:

audit(1196761642.698:3): avc: denied { ioctl } for pid=1353 comm="syslogd" name="xconsole" dev=tmpfs ino=3703 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:xconsole_device_t:s0 tclass=fifo_file

attached patch, that xserver_rw_console() gives ioctl permission. Can be merged?

I switched it to use rw_fifo_file_perms instead.

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.
#2 lore raw

Hi,

Quoted 9 lines · Christopher J. PeBenito
Quoted 8 lines · Václav Ovsík

Hi,
when starting syslogd by init script:

audit(1196761642.698:3): avc: denied { ioctl } for pid=1353 comm="syslogd" name="xconsole" dev=tmpfs ino=3703 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:xconsole_device_t:s0 tclass=fifo_file

Quoted 4 lines
Quoted 2 lines

attached patch, that xserver_rw_console() gives ioctl permission. Can be merged?

I switched it to use rw_fifo_file_perms instead.

I found another problem in dependency of the logging module on the xserver module. When the xserver module is not used (policy without this module), access to xconsole is denied. Problem is, that pipe /dev/xconsole is created by syslogd startup script, but it's type (context) belongs to the xserver module. That is if no X Window System is installed (thus no policy module for it), syslogd startup script creates /dev/xconsole, but can't do labeling and access to /dev/xconsole.

I have no idea what to write into optional-else block. Maybe to use some dummy type, allow syslogd_t to rw to this dummy type. But how to write context for /dev/xconsole with this dummy type optionaly? That is, entry for /dev/xconsole, valid only when there is no entry from other module (xserver). Impossible?

Move xconsole_device_t staff from xserver into logging?

Any idea how to solve this?

Signature · 6 lines
Zito

--
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 29 lines · Václav Ovsík
Quoted 8 lines · Christopher J. PeBenito
Quoted 7 lines · Václav Ovsík

when starting syslogd by init script:

audit(1196761642.698:3): avc: denied { ioctl } for pid=1353 comm="syslogd" name="xconsole" dev=tmpfs ino=3703 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:xconsole_device_t:s0 tclass=fifo_file

Quoted 4 lines
Quoted 2 lines

attached patch, that xserver_rw_console() gives ioctl permission. Can be merged?

I switched it to use rw_fifo_file_perms instead.

I found another problem in dependency of the logging module on the xserver module. When the xserver module is not used (policy without this module), access to xconsole is denied. Problem is, that pipe /dev/xconsole is created by syslogd startup script, but it's type (context) belongs to the xserver module. That is if no X Window System is installed (thus no policy module for it), syslogd startup script creates /dev/xconsole, but can't do labeling and access to /dev/xconsole.

I have no idea what to write into optional-else block. Maybe to use some dummy type, allow syslogd_t to rw to this dummy type. But how to write context for /dev/xconsole with this dummy type optionaly? That is, entry for /dev/xconsole, valid only when there is no entry from other module (xserver). Impossible?

Quoted 3 lines

Move xconsole_device_t staff from xserver into logging?

Any idea how to solve this?

This came up before, and I was under the impression that it had been fixed. I guess not. You can see the previous thread:

http://marc.info/?l=selinux&m=115816229022334&w=2

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.
#4 lore raw

Hi,

Quoted 9 lines · Christopher J. PeBenito

...

Quoted 3 lines

Move xconsole_device_t staff from xserver into logging?

Any idea how to solve this?

This came up before, and I was under the impression that it had been fixed. I guess not. You can see the previous thread:

http://marc.info/?l=selinux&m=115816229022334&w=2

Ok, and what is the conclusion from this thread? I think, that the move xconsole pipe from xserver to logging can solve problem on Debian. I didn't find /dev/xconsole on CentoOS, don't know what Gentoo and Suse.

On Debian:
Xconsole pipe is created by init script (/etc/init.d/sysklogd) under /dev with type device_t, then chown and chmod is done and finally restorecon is (will be) called on it (obtains xconsole_device_t type). Init script is capable to create the pipe (with device_t type) thanks to unconfined module. I tried to remove unconfined module and some new denials appeared on system startup and I will report this in 2008 :).

I rewrite Erichs S. changeset a bit and is attached. One version is patch with logging_setattr_xconsole macro (xconsole-move.patch) and another is without it (xconsole-move2.patch). This macro call with domain initrc_t as argument is not too interesting I think. Init script is capable of creating pipe thanks to unconfined module. More permissions are needed without unconfined module. I save this for later.

What about to rename xconsole_device_t to xconsole_pipe_t?

Please consider some changes above. Thanks.

Mary Xmass.

Signature · 1 line
Zito
modules/services/xserver.te +0 -8
Index: policy/modules/services/xserver.te
===================================================================
@@ -32,12 +32,6 @@
 type xauth_exec_t;
 application_executable_file(xauth_exec_t)
 
-# this is not actually a device, its a pipe
-type xconsole_device_t;
-files_type(xconsole_device_t)
-fs_associate_tmpfs(xconsole_device_t)
-files_associate_tmp(xconsole_device_t)
-
 type xdm_t;
 type xdm_exec_t;
 auth_login_pgm_domain(xdm_t)
@@ -108,8 +102,6 @@
 allow xdm_t self:appletalk_socket create_socket_perms;
 allow xdm_t self:key { search link write };
 
-allow xdm_t xconsole_device_t:fifo_file { getattr setattr };
-
 # Allow gdm to run gdm-binary
 can_exec(xdm_t, xdm_exec_t)
 
modules/services/xserver.fc +0 -5
Index: policy/modules/services/xserver.fc
===================================================================
@@ -10,11 +10,6 @@
 HOME_DIR/\.Xauthority.*	--	gen_context(system_u:object_r:ROLE_xauth_home_t,s0)
 
 #
-# /dev
-#
-/dev/xconsole		-p	gen_context(system_u:object_r:xconsole_device_t,s0)
-
-#
 # /etc
 #
 
modules/services/xserver.if +0 -36
Index: policy/modules/services/xserver.if
===================================================================
@@ -729,42 +729,6 @@
 
 ########################################
 ## <summary>
-##	Set the attributes of the X windows console named pipes.
-## </summary>
-## <param name="domain">
-##	<summary>
-##	Domain allowed access.
-##	</summary>
-## </param>
-#
-interface(`xserver_setattr_console_pipes',`
-	gen_require(`
-		type xconsole_device_t;
-	')
-
-	allow $1 xconsole_device_t:fifo_file setattr;
-')
-
-########################################
-## <summary>
-##	Read and write the X windows console named pipe.
-## </summary>
-## <param name="domain">
-##	<summary>
-##	Domain allowed access.
-##	</summary>
-## </param>
-#
-interface(`xserver_rw_console',`
-	gen_require(`
-		type xconsole_device_t;
-	')
-
-	allow $1 xconsole_device_t:fifo_file rw_fifo_file_perms;
-')
-
-########################################
-## <summary>
 ##	Use file descriptors for xdm.
 ## </summary>
 ## <param name="domain">
modules/system/logging.te +9 -5
Index: policy/modules/system/logging.te
===================================================================
@@ -65,6 +65,12 @@
 	init_ranged_daemon_domain(auditd_t,auditd_exec_t,mls_systemhigh)
 ')
 
+# this is not actually a device, its a pipe
+type xconsole_device_t;
+files_type(xconsole_device_t)
+fs_associate_tmpfs(xconsole_device_t)
+files_associate_tmp(xconsole_device_t)
+
 ########################################
 #
 # Auditctl local policy
@@ -277,6 +283,9 @@
 manage_files_pattern(syslogd_t,syslogd_var_run_t,syslogd_var_run_t)
 files_pid_filetrans(syslogd_t,syslogd_var_run_t,file)
 
+# log to xconsole
+allow syslogd_t xconsole_device_t:fifo_file rw_fifo_file_perms;
+
 kernel_read_kernel_sysctls(syslogd_t)
 kernel_read_proc_symlinks(syslogd_t)
 # Allow access to /proc/kmsg for syslog-ng
@@ -376,8 +385,3 @@
 optional_policy(`
 	udev_read_db(syslogd_t)
 ')
-
-optional_policy(`
-	# log to the xconsole
-	xserver_rw_console(syslogd_t)
-')
modules/system/logging.if +36 -0
Index: policy/modules/system/logging.if
===================================================================
@@ -804,3 +804,39 @@
 	logging_admin_audit($1, $2, $3)
 	logging_admin_syslog($1, $2, $3)
 ')
+
+########################################
+## <summary>
+##	Set the attributes of the xconsole named pipe.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`logging_setattr_xconsole',`
+	gen_require(`
+		type xconsole_device_t;
+	')
+
+	allow $1 xconsole_device_t:fifo_file setattr;
+')
+
+########################################
+## <summary>
+##	Read the xconsole named pipe.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`logging_r_xconsole',`
+	gen_require(`
+		type xconsole_device_t;
+	')
+
+	allow $1 xconsole_device_t:fifo_file read_fifo_file_perms;
+')
modules/system/init.te +1 -3
Index: policy/modules/system/init.te
===================================================================
@@ -356,6 +356,7 @@
 logging_read_all_logs(initrc_t)
 logging_append_all_logs(initrc_t)
 logging_read_audit_config(initrc_t)
+logging_setattr_xconsole(initrc_t)
 
 miscfiles_read_localization(initrc_t)
 # slapd needs to read cert files from its initscript
@@ -755,9 +756,6 @@
 ')
 
 optional_policy(`
-	# Set device ownerships/modes.
-	xserver_setattr_console_pipes(initrc_t)
-
 	# init script wants to check if it needs to update windowmanagerlist
 	xserver_read_xdm_rw_config(initrc_t)
 ')
modules/system/logging.fc +1 -0
Index: policy/modules/system/logging.fc
===================================================================
@@ -1,4 +1,5 @@
 /dev/log		-s	gen_context(system_u:object_r:devlog_t,s0)
+/dev/xconsole		-p	gen_context(system_u:object_r:xconsole_device_t,s0)
 
 /etc/rsyslog.conf		gen_context(system_u:object_r:syslog_conf_t,s0)
 /etc/syslog.conf		gen_context(system_u:object_r:syslog_conf_t,s0)
modules/services/xserver.te +0 -8
Index: policy/modules/services/xserver.te
===================================================================
@@ -32,12 +32,6 @@
 type xauth_exec_t;
 application_executable_file(xauth_exec_t)
 
-# this is not actually a device, its a pipe
-type xconsole_device_t;
-files_type(xconsole_device_t)
-fs_associate_tmpfs(xconsole_device_t)
-files_associate_tmp(xconsole_device_t)
-
 type xdm_t;
 type xdm_exec_t;
 auth_login_pgm_domain(xdm_t)
@@ -108,8 +102,6 @@
 allow xdm_t self:appletalk_socket create_socket_perms;
 allow xdm_t self:key { search link write };
 
-allow xdm_t xconsole_device_t:fifo_file { getattr setattr };
-
 # Allow gdm to run gdm-binary
 can_exec(xdm_t, xdm_exec_t)
 
modules/services/xserver.fc +0 -5
Index: policy/modules/services/xserver.fc
===================================================================
@@ -10,11 +10,6 @@
 HOME_DIR/\.Xauthority.*	--	gen_context(system_u:object_r:ROLE_xauth_home_t,s0)
 
 #
-# /dev
-#
-/dev/xconsole		-p	gen_context(system_u:object_r:xconsole_device_t,s0)
-
-#
 # /etc
 #
 
modules/services/xserver.if +0 -36
Index: policy/modules/services/xserver.if
===================================================================
@@ -729,42 +729,6 @@
 
 ########################################
 ## <summary>
-##	Set the attributes of the X windows console named pipes.
-## </summary>
-## <param name="domain">
-##	<summary>
-##	Domain allowed access.
-##	</summary>
-## </param>
-#
-interface(`xserver_setattr_console_pipes',`
-	gen_require(`
-		type xconsole_device_t;
-	')
-
-	allow $1 xconsole_device_t:fifo_file setattr;
-')
-
-########################################
-## <summary>
-##	Read and write the X windows console named pipe.
-## </summary>
-## <param name="domain">
-##	<summary>
-##	Domain allowed access.
-##	</summary>
-## </param>
-#
-interface(`xserver_rw_console',`
-	gen_require(`
-		type xconsole_device_t;
-	')
-
-	allow $1 xconsole_device_t:fifo_file rw_fifo_file_perms;
-')
-
-########################################
-## <summary>
 ##	Use file descriptors for xdm.
 ## </summary>
 ## <param name="domain">
modules/system/logging.te +9 -5
Index: policy/modules/system/logging.te
===================================================================
@@ -65,6 +65,12 @@
 	init_ranged_daemon_domain(auditd_t,auditd_exec_t,mls_systemhigh)
 ')
 
+# this is not actually a device, its a pipe
+type xconsole_device_t;
+files_type(xconsole_device_t)
+fs_associate_tmpfs(xconsole_device_t)
+files_associate_tmp(xconsole_device_t)
+
 ########################################
 #
 # Auditctl local policy
@@ -277,6 +283,9 @@
 manage_files_pattern(syslogd_t,syslogd_var_run_t,syslogd_var_run_t)
 files_pid_filetrans(syslogd_t,syslogd_var_run_t,file)
 
+# log to xconsole
+allow syslogd_t xconsole_device_t:fifo_file rw_fifo_file_perms;
+
 kernel_read_kernel_sysctls(syslogd_t)
 kernel_read_proc_symlinks(syslogd_t)
 # Allow access to /proc/kmsg for syslog-ng
@@ -376,8 +385,3 @@
 optional_policy(`
 	udev_read_db(syslogd_t)
 ')
-
-optional_policy(`
-	# log to the xconsole
-	xserver_rw_console(syslogd_t)
-')
modules/system/logging.if +18 -0
Index: policy/modules/system/logging.if
===================================================================
@@ -804,3 +804,21 @@
 	logging_admin_audit($1, $2, $3)
 	logging_admin_syslog($1, $2, $3)
 ')
+
+########################################
+## <summary>
+##	Read the xconsole named pipe.
+## </summary>
+## <param name="domain">
+##	<summary>
+##	Domain allowed access.
+##	</summary>
+## </param>
+#
+interface(`logging_r_xconsole',`
+	gen_require(`
+		type xconsole_device_t;
+	')
+
+	allow $1 xconsole_device_t:fifo_file read_fifo_file_perms;
+')
modules/system/init.te +0 -3
Index: policy/modules/system/init.te
===================================================================
@@ -755,9 +755,6 @@
 ')
 
 optional_policy(`
-	# Set device ownerships/modes.
-	xserver_setattr_console_pipes(initrc_t)
-
 	# init script wants to check if it needs to update windowmanagerlist
 	xserver_read_xdm_rw_config(initrc_t)
 ')
modules/system/logging.fc +1 -0
Index: policy/modules/system/logging.fc
===================================================================
@@ -1,4 +1,5 @@
 /dev/log		-s	gen_context(system_u:object_r:devlog_t,s0)
+/dev/xconsole		-p	gen_context(system_u:object_r:xconsole_device_t,s0)
 
 /etc/rsyslog.conf		gen_context(system_u:object_r:syslog_conf_t,s0)
 /etc/syslog.conf		gen_context(system_u:object_r:syslog_conf_t,s0)
#5 lore raw

Hi,
I'm still convinced of the opinion that /dev/xconsole has nothing to do with the Xserver or devices. It's just a logging pipe, and that is exactly where it should go to: the logging module.
The only thing I'm aware of linking xconsole with the Xserver is that the xconsole program is one of a couple of utilities usually included with the xserver...

Quoted 1 line

From the xconsole man page:

DESCRIPTION
The xconsole program displays messages which are usually sent to /dev/console.

Note that /dev/console has nothing to do with the xserver either. This is not about seeing Xserver output. It's about seeing system console output (which happens to be handled by system logging these days...)

Also note that IIRC the only thing that actually could write to /dev/xconsole on SELinux is syslog, isn't it? The X server can not?

Quoted 1 line

What about to rename xconsole_device_t to xconsole_pipe_t?

Or logging_xconsole_pipe_t or so. Although something similar to the type of /dev/console would be appropriate, I guess.

best regards,
Erich Schubert

Signature · 9 lines
   erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C    (o_
    Go away or i'll replace you with a very small shell script.     //\
    Der Anfang aller Erkenntnis ist das Staunen. --- Aristoteles    V_/_


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