All of lore.kernel.org
 help / color / mirror / Atom feed
* cdrecord deadlocks linux 2.6.8.1 (problem in setscheduler)
@ 2004-10-18 12:43 Thomas Bleher
  2004-10-18 13:49 ` Stephen Smalley
  2004-10-18 14:38 ` Luke Kenneth Casson Leighton
  0 siblings, 2 replies; 53+ messages in thread
From: Thomas Bleher @ 2004-10-18 12:43 UTC (permalink / raw)
  To: SELinux ML

[-- Attachment #1: Type: text/plain, Size: 916 bytes --]

cdrecord deadlocks linux 2.6.8.1:

I have just written selinux policy for cdrecord. While writing this 
policy cdrecord constantly locked up the computer (even in permissive
mode). When booting with selinux=0 the problem went away.

After digging around for a while, the following seems to be happening:
* cdrecord calls sched_setscheduler()
* setscheduler (in kernel/sched.c) asks for CAP_SYS_NICE
* cdrecord doesn't have this capability
* selinux generates an audit message ==> deadlock

When I grant cdrecord CAP_SYS_NICE everything works fine.
I think SELinux shouldn't generate a log message in this case; like it
is already suppressed for setsched.

To test, add the attached policy, remove sys_nice from the allowed caps
and simply call cdrecord without parameters.

Thomas

-- 
http://www.cip.ifi.lmu.de/~bleher/selinux/ - my SELinux pages
GPG-Fingerprint: BC4F BB16 30D6 F253 E3EA  D09E C562 2BAE B2F4 ABE7

[-- Attachment #2: cdrecord.patch --]
[-- Type: text/plain, Size: 3021 bytes --]

diff -urN orig/domains/program/unused/cdrecord.te mod/domains/program/unused/cdrecord.te
--- orig/domains/program/unused/cdrecord.te	1970-01-01 01:00:00.000000000 +0100
+++ mod/domains/program/unused/cdrecord.te	2004-10-18 14:32:37.237650320 +0200
@@ -0,0 +1,9 @@
+# DESC cdrecord - record audio or data Compact Disks or Digital Versatile Disks from a master
+#
+# Author: Thomas Bleher <ThomasBleher@gmx.de>
+
+# Type for the cdrecord excutable.
+type cdrecord_exec_t, file_type, sysadmfile, exec_type;
+
+# everything else is in the cdrecord_domain macros in
+# macros/program/cdrecord_macros.te.
diff -urN orig/file_contexts/program/cdrecord.fc mod/file_contexts/program/cdrecord.fc
--- orig/file_contexts/program/cdrecord.fc	1970-01-01 01:00:00.000000000 +0100
+++ mod/file_contexts/program/cdrecord.fc	2004-10-18 14:32:49.467791056 +0200
@@ -0,0 +1,2 @@
+# cdrecord
+/usr/bin/cdrecord	--	system_u:object_r:cdrecord_exec_t
diff -urN orig/macros/base_user_macros.te mod/macros/base_user_macros.te
--- orig/macros/base_user_macros.te	2004-10-14 12:42:18.000000000 +0200
+++ mod/macros/base_user_macros.te	2004-10-18 14:33:47.317996488 +0200
@@ -167,6 +167,7 @@
 ifdef(`irc.te', `irc_domain($1)')
 ifdef(`using_spamassassin', `spamassassin_domain($1)')
 ifdef(`uml.te', `uml_domain($1)')
+ifdef(`cdrecord.te', `cdrecord_domain($1)')
 
 # Instantiate a derived domain for user cron jobs.
 ifdef(`crond.te', `crond_domain($1)')
diff -urN orig/macros/program/cdrecord_macros.te mod/macros/program/cdrecord_macros.te
--- orig/macros/program/cdrecord_macros.te	1970-01-01 01:00:00.000000000 +0100
+++ mod/macros/program/cdrecord_macros.te	2004-10-18 14:33:00.562104464 +0200
@@ -0,0 +1,42 @@
+# macros for the cdrecord domain
+# Author: Thomas Bleher <ThomasBleher@gmx.de>
+
+define(`cdrecord_domain', `
+type $1_cdrecord_t, domain;
+
+domain_auto_trans($1_t, cdrecord_exec_t, $1_cdrecord_t)
+
+# The user role is authorized for this domain.
+role $1_r types $1_cdrecord_t;
+
+uses_shlib($1_cdrecord_t)
+
+# allow ps to show cdrecord and allow the user to kill it 
+can_ps($1_t, $1_cdrecord_t)
+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;
+allow $1_cdrecord_t privfd:fd use;
+
+allow $1_cdrecord_t home_root_t:dir { search };
+
+# allow cdrecord to read user files
+r_dir_file($1_cdrecord_t, { $1_home_t $1_tmp_t })
+ifdef(`nfs_home_dirs', `
+r_dir_file($1_cdrecord_t, nfs_t)
+')dnl end if nfs_home_dirs
+
+# allow searching for cdrom-drive
+allow $1_cdrecord_t device_t:dir { getattr search };
+allow $1_cdrecord_t device_t:lnk_file { getattr read };
+
+# allow cdrecord to write the CD
+allow $1_cdrecord_t removable_device_t:blk_file { getattr ioctl read };
+allow $1_cdrecord_t scsi_generic_device_t:chr_file { getattr read write ioctl };
+
+allow $1_cdrecord_t self:capability { ipc_lock sys_nice setuid };
+allow $1_cdrecord_t self:process { getsched setsched };
+
+')

^ permalink raw reply	[flat|nested] 53+ messages in thread

end of thread, other threads:[~2004-11-06 10:46 UTC | newest]

Thread overview: 53+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-18 12:43 cdrecord deadlocks linux 2.6.8.1 (problem in setscheduler) Thomas Bleher
2004-10-18 13:49 ` Stephen Smalley
2004-10-18 15:03   ` James Morris
     [not found]     ` <4173F737.1070204@immunix.com>
2004-10-18 19:07       ` Stephen Smalley
2004-10-18 19:14       ` Chris Wright
     [not found]         ` <20041018214052.GB4336@immunix.com>
2004-10-19 12:14           ` Stephen Smalley
2004-10-19 16:21             ` Chris Wright
2004-10-19 18:17             ` Stephen Smalley
2004-10-19 18:27               ` Chris Wright
2004-10-19 18:36                 ` James Morris
2004-10-19 18:39                   ` Chris Wright
2004-10-19 18:52                   ` Stephen Smalley
2004-10-19 19:02                     ` Chris Wright
2004-10-19 19:14                       ` Stephen Smalley
2004-10-19 19:20                         ` Chris Wright
2004-10-19 20:09                           ` Stephen Smalley
2004-10-19 20:17                             ` Stephen Smalley
2004-10-19 20:42                               ` James Morris
2004-10-19 21:09                                 ` Chris Wright
2004-10-20 12:23                                   ` Stephen Smalley
2004-10-20 12:44                                     ` Stephen Smalley
     [not found]                                     ` <20041020154909.GA1917@immunix.com>
2004-10-20 16:01                                       ` Stephen Smalley
2004-10-20 16:07                                       ` Chris Wright
2004-10-20 17:41                                     ` Chris Wright
2004-10-20 20:05                                       ` Stephen Smalley
2004-10-21  0:28                                         ` Chris Wright
2004-10-18 19:11     ` Chris Wright
2004-10-18 14:38 ` Luke Kenneth Casson Leighton
2004-10-18 21:58   ` cdrecord patch [was: Re: cdrecord deadlocks linux 2.6.8.1 (problem in setscheduler)] Thomas Bleher
2004-10-29 19:31     ` James Carter
2004-11-01 16:18       ` Patch to make can_network stronger and remove nscd tunable Daniel J Walsh
2004-11-02 13:27         ` Russell Coker
2004-11-02 14:30           ` Daniel J Walsh
2004-11-02 14:39             ` Stephen Smalley
2004-11-02 14:44               ` Daniel J Walsh
2004-11-02 14:50               ` Daniel J Walsh
2004-11-02 15:38                 ` Russell Coker
2004-11-02 15:48             ` Russell Coker
2004-11-02 15:55               ` Daniel J Walsh
2004-11-03  5:23                 ` Russell Coker
2004-11-02 15:56               ` Daniel J Walsh
2004-11-03  0:07                 ` Thomas Bleher
2004-11-03  6:16                   ` Russell Coker
2004-11-03 16:17                   ` Daniel J Walsh
2004-11-03  5:41                 ` Russell Coker
2004-11-03 16:23                   ` Daniel J Walsh
2004-11-03 18:45                     ` Colin Walters
2004-11-03 22:13                       ` Colin Walters
2004-11-03 22:49                         ` Daniel J Walsh
2004-11-05 13:10                           ` Thomas Bleher
2004-11-05 13:38                             ` Stephen Smalley
2004-11-05 21:24                             ` James Carter
2004-11-06 10:46                               ` Thomas Bleher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.