Bug 732057

Summary: SELinux is preventing /usr/lib/cups/backend/usb from 'ioctl' accesses on the chr_file /dev/usb/lp0.
Product: [Fedora] Fedora Reporter: Till Maas <opensource>
Component: selinux-policyAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 15CC: dominick.grift, dwalsh, mgrepl, opensource
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard: setroubleshoot_trace_hash:5b5b0595276465af571cccc5622a058797b6e4698fd7c38c806c71a032c4efc8
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-10-07 15:00:51 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Till Maas 2011-08-19 16:00:04 UTC
SELinux is preventing /usr/lib/cups/backend/usb from 'ioctl' accesses on the chr_file /dev/usb/lp0.

*****  Plugin restorecon (90.5 confidence) suggests  *************************

If you want to fix the label. 
/dev/usb/lp0 default label should be printer_device_t.
Then you can run restorecon.
Do
# /sbin/restorecon -v /dev/usb/lp0

*****  Plugin device (9.50 confidence) suggests  *****************************

If you want to allow usb to have ioctl access on the lp0 chr_file
Then you need to change the label on /dev/usb/lp0 to a type of a similar device.
Do
# semanage fcontext -a -t SIMILAR_TYPE '/dev/usb/lp0'
# restorecon -v '/dev/usb/lp0'

*****  Plugin catchall (1.40 confidence) suggests  ***************************

If you believe that usb should be allowed ioctl access on the lp0 chr_file by default.
Then you should report this as a bug.
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep usb /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp

Additional Information:
Source Context                system_u:system_r:cupsd_t:s0-s0:c0.c1023
Target Context                system_u:object_r:device_t:s0
Target Objects                /dev/usb/lp0 [ chr_file ]
Source                        usb
Source Path                   /usr/lib/cups/backend/usb
Port                          <Unbekannt>
Host                          (removed)
Source RPM Packages           cups-1.4.8-1.fc15
Target RPM Packages           
Policy RPM                    selinux-policy-3.9.16-35.fc15
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Permissive
Host Name                     (removed)
Platform                      Linux (removed) 2.6.40-4.fc15.x86_64 #1 SMP
                              Fri Jul 29 18:46:53 UTC 2011 x86_64 x86_64
Alert Count                   1
First Seen                    Fr 12 Aug 2011 18:52:00 CEST
Last Seen                     Fr 12 Aug 2011 18:52:00 CEST
Local ID                      7c818c31-b82c-43b2-92af-16d81d81195b

Raw Audit Messages
type=AVC msg=audit(1313167920.824:2217): avc:  denied  { ioctl } for  pid=851 comm="usb" path="/dev/usb/lp0" dev=devtmpfs ino=578769 scontext=system_u:system_r:cupsd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:device_t:s0 tclass=chr_file


type=SYSCALL msg=audit(1313167920.824:2217): arch=x86_64 syscall=ioctl success=yes exit=0 a0=5 a1=84005001 a2=7fffd4514700 a3=7fffd45142d0 items=0 ppid=3085 pid=851 auid=4294967295 uid=4 gid=7 euid=4 suid=4 fsuid=4 egid=7 sgid=7 fsgid=7 tty=(none) ses=4294967295 comm=usb exe=/usr/lib/cups/backend/usb subj=system_u:system_r:cupsd_t:s0-s0:c0.c1023 key=(null)

Hash: usb,cupsd_t,device_t,chr_file,ioctl

audit2allow

#============= cupsd_t ==============
allow cupsd_t device_t:chr_file ioctl;

audit2allow -R

#============= cupsd_t ==============
allow cupsd_t device_t:chr_file ioctl;

Comment 1 Miroslav Grepl 2011-08-22 10:41:25 UTC
"/dev/usb/lp0" is mislabeled.

What does ls -lZ /dev/usb/lp0

show?

Comment 2 Till Maas 2011-08-22 15:29:40 UTC
$ ls -lZ /dev/usb/lp0
crw-rw----. root lp system_u:object_r:printer_device_t:s0 /dev/usb/lp0

Comment 3 Daniel Walsh 2011-08-22 16:15:56 UTC
Looks like a race condition between the creation and udev fixing the label.

Comment 4 Till Maas 2011-08-22 16:50:33 UTC
(In reply to comment #3)
> Looks like a race condition between the creation and udev fixing the label.

If I plug the USB cable in, the label is indeed different for a short amount of time:
$ ls -lZ /dev/usb/lp0
crw-------. root root system_u:object_r:device_t:s0    /dev/usb/lp0
$ ls -lZ /dev/usb/lp0
crw-rw----. root lp system_u:object_r:printer_device_t:s0 /dev/usb/lp

Comment 5 Daniel Walsh 2011-08-24 03:26:31 UTC
Luckily this race condition should be fixed in F16

Comment 6 Daniel Walsh 2011-08-24 03:27:27 UTC
Miroslav we can probably add a dontaudit for now.