Bug 697812 - sudo -r ... cannot read /etc/selinux/targeted/contexts/default_type
Summary: sudo -r ... cannot read /etc/selinux/targeted/contexts/default_type
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: selinux-policy
Version: 6.1
Hardware: All
OS: Linux
high
medium
Target Milestone: rc
: ---
Assignee: Miroslav Grepl
QA Contact: Karel Srot
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-04-19 11:01 UTC by Milos Malik
Modified: 2011-05-19 12:27 UTC (History)
3 users (show)

Fixed In Version: selinux-policy-3.7.19-87.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-05-19 12:27:48 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:0526 0 normal SHIPPED_LIVE selinux-policy bug fix and enhancement update 2011-05-19 09:37:41 UTC

Description Milos Malik 2011-04-19 11:01:34 UTC
Description of problem:


Version-Release number of selected component (if applicable):
selinux-policy-minimum-3.7.19-85.el6.noarch
selinux-policy-doc-3.7.19-85.el6.noarch
selinux-policy-targeted-3.7.19-85.el6.noarch
selinux-policy-3.7.19-85.el6.noarch
selinux-policy-mls-3.7.19-85.el6.noarch

How reproducible:
always

Steps to Reproduce:
1) create an staff_u user
2) set a password for the user
3) allow the user to run w via sudo
( echo "USERNAME ALL = (ALL) /usr/bin/w" >> /etc/sudoers )
4) log in as the user (works in both SSH session and X session)
5) run "sudo -r unconfined_r w" (role change from staff_r to unconfined_r is allowed)
$ sudo -r unconfined_r w
[sudo] password for sudotester: 
sudo: unable to get default type for role unconfined_r
sudo: unable to execute /usr/bin/w: Invalid argument

6) run "sudo -r guest_r w" (role change from staff_r to guest_r is not allowed)
$ sudo -r guest_r w
[sudo] password for sudotester: 
sudo: unable to get default type for role guest_r
sudo: unable to execute /usr/bin/w: Invalid argument


Actual results:
----
time->Tue Apr 19 06:55:05 2011
type=SYSCALL msg=audit(1303210505.672:41918): arch=c000003e syscall=137 success=no exit=-13 a0=7fcd0ce368d0 a1=7fff5ac75d40 a2=7fff5ac75cb0 a3=7fff5ac75a10 items=0 ppid=4800 pid=4821 auid=501 uid=0 gid=502 euid=0 suid=0 fsuid=0 egid=502 sgid=502 fsgid=502 tty=pts2 ses=32 comm="sudo" exe="/usr/bin/sudo" subj=staff_u:staff_r:staff_sudo_t:s0 key=(null)
type=AVC msg=audit(1303210505.672:41918): avc:  denied  { getattr } for  pid=4821 comm="sudo" name="/" dev=devpts ino=1 scontext=staff_u:staff_r:staff_sudo_t:s0 tcontext=system_u:object_r:devpts_t:s0 tclass=filesystem
----
time->Tue Apr 19 06:55:05 2011
type=SYSCALL msg=audit(1303210505.752:41922): arch=c000003e syscall=2 success=no exit=-13 a0=7fcd0ce54d80 a1=0 a2=1b6 a3=0 items=0 ppid=4821 pid=4825 auid=501 uid=0 gid=502 euid=0 suid=0 fsuid=0 egid=502 sgid=502 fsgid=502 tty=pts2 ses=32 comm="sudo" exe="/usr/bin/sudo" subj=staff_u:staff_r:staff_sudo_t:s0 key=(null)
type=AVC msg=audit(1303210505.752:41922): avc:  denied  { read } for  pid=4825 comm="sudo" name="default_type" dev=dm-0 ino=132104 scontext=staff_u:staff_r:staff_sudo_t:s0 tcontext=system_u:object_r:default_context_t:s0 tclass=file
----

Expected results:
no AVCs

Comment 2 Miroslav Grepl 2011-04-19 12:25:26 UTC
Did yo try to allow staff_sudo_t to read default_context_t type?

Comment 3 Milos Malik 2011-04-19 12:45:39 UTC
Steps 5 and 6 described in comment#0 lead to 4 AVCs in enforcing mode. "Actual results" section shows the unique ones.

Comment 4 Milos Malik 2011-04-19 13:11:43 UTC
Following module solved my problem. I don't see any AVCs in enforcing mode when running the automated test.

module mypol 1.0;

require {
        type devpts_t;
        type default_context_t;
        type staff_sudo_t;
        class file { read getattr open };
        class filesystem getattr;
}

#============= staff_sudo_t ==============
allow staff_sudo_t default_context_t:file { read getattr open };
allow staff_sudo_t devpts_t:filesystem getattr;

Comment 5 Daniel Walsh 2011-04-19 15:01:01 UTC
Looks good to me.

Comment 6 Miroslav Grepl 2011-04-19 19:27:04 UTC
I will add. It works also for me.

Comment 8 Miroslav Grepl 2011-04-20 14:54:06 UTC
Fixed in selinux-policy-3.7.19-87.el6

Comment 11 errata-xmlrpc 2011-05-19 12:27:48 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHBA-2011-0526.html


Note You need to log in before you can comment on or make changes to this bug.