Bug 596419

Summary: capability check in pci_read_config() bypasses lsm/selinux
Product: Red Hat Enterprise Linux 6 Reporter: Chris Wright <chrisw>
Component: kernelAssignee: Eric Paris <eparis>
Status: CLOSED ERRATA QA Contact: Boris Ranto <branto>
Severity: medium Docs Contact:
Priority: high    
Version: 6.0CC: alex.williamson, branto, chrisw, juzhang, lihuang, shuang, syeghiay, tburke, virt-maint
Target Milestone: beta   
Target Release: 6.2   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: kernel-2.6.32-241.el6 Doc Type: Bug Fix
Doc Text:
The cred argument has been included in the security_capable() function so that it can be used in a wider range of call sites.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 07:33:22 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:
Bug Depends On: 559709    
Bug Blocks: 562808, 580951, 756082, 758829    
Attachments:
Description Flags
security: add task, cred and audit flag arguments to security_capable()
none
pci: use security_capable() when checking capablities during config space read
none
security: add cred argument to security_capable()
none
pci: use security_capable() when checking capablities during config space read
none
pci: use security_capable() when checking capablities during config space read none

Description Chris Wright 2010-05-26 18:02:51 UTC
The fix in bug 559709 changes how capabilities are checked in pci_read_config().
The new check does a raw capability comparison against the open file's credentials, and that bypasses lsm/selinux checking.  Restore the lsm/selinux checking (while maintaining the new check against filp->f_cred).

Comment 1 Don Dutile (Red Hat) 2010-07-13 17:49:08 UTC
Moved to rhel6.1 .

Awaiting upstream direction before changing rhel6 (again).

Comment 6 RHEL Program Management 2010-11-10 20:39:45 UTC
This request was evaluated by Red Hat Product Management for inclusion
in a Red Hat Enterprise Linux maintenance release. Product Management has 
requested further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed 
products. This request is not yet committed for inclusion in an Update release.

Comment 12 Chris Wright 2011-02-09 23:11:27 UTC
Created attachment 477924 [details]
security: add task, cred and audit flag arguments to security_capable()

Expand arguments of security_capable() to include all arguments that
will be passed through to the underlying ->capable() callback.  This
makes security_capable() usable in a wider range of call sites.

Comment 13 Chris Wright 2011-02-09 23:12:32 UTC
Created attachment 477925 [details]
pci: use security_capable() when checking capablities during config space read

Eric Paris noted that commit de139a3 ("pci: check caps from sysfs file
open to read device dependent config space") caused the capability check
to bypass security modules and potentially auditing.  Rectify this by
calling security_capable() when checking the open file's capabilities
for config space reads.

Comment 14 Chris Wright 2011-02-10 00:00:30 UTC
Those two patches don't compile together, but give the basic idea.

Comment 15 Chris Wright 2011-02-10 01:40:58 UTC
Created attachment 477941 [details]
security: add cred argument to security_capable()

Expand security_capable() to include cred, so that it can be usable in a
wider range of call sites.

Comment 16 Chris Wright 2011-02-10 01:42:08 UTC
Created attachment 477942 [details]
pci: use security_capable() when checking capablities during config space read

Eric Paris noted that commit de139a3 ("pci: check caps from sysfs file
open to read device dependent config space") caused the capability check
to bypass security modules and potentially auditing.  Rectify this by
calling security_capable() when checking the open file's capabilities
for config space reads.

Comment 17 Chris Wright 2011-02-10 06:13:55 UTC
Posted patches in Comment #15 and Comment #16 upstream

Comment 18 Chris Wright 2011-02-15 01:26:18 UTC
And patch in Comment #16 is buggy.

Comment 19 Chris Wright 2011-02-15 01:29:08 UTC
Created attachment 478746 [details]
pci: use security_capable() when checking capablities during config space read

This reintroduces commit 47970b1b which was subsequently reverted
as f00eaeea.  The original change was broken and caused X startup
failures and generally made privileged processes incapable of reading
device dependent config space.  The normal capable() interface returns
true on success, but the LSM interface returns 0 on success.  This thinko
is now fixed in this patch, and has been confirmed to work properly.
 
So, once again...Eric Paris noted that commit de139a3 ("pci: check caps
from sysfs file open to read device dependent config space") caused the
capability check to bypass security modules and potentially auditing.
Rectify this by calling security_capable() when checking the open file's
capabilities for config space reads.

Comment 22 Suzanne Logcher 2011-03-28 21:08:40 UTC
Since RHEL 6.1 External Beta has begun, and this bug remains 
unresolved, it has been rejected as it is not proposed as an 
exception or blocker.

Red Hat invites you to ask your support representative to 
propose this request, if appropriate and relevant, in the 
next release of Red Hat Enterprise Linux.

Comment 25 Suqin Huang 2011-12-14 02:52:01 UTC
Hi Chris, Eric,
Can you give some suggestion how to this bug.
Thanks
Suqin

Comment 26 Suqin Huang 2011-12-19 02:35:04 UTC
Eric will provide the bug description, ack this bug first.
suqin

Comment 27 Suqin Huang 2011-12-23 03:14:45 UTC
steps to test:
$ sudo sandbox cat /sys/bus/pci/devices/$DEVICE/config

should generate an avc denying sys_admin.

Comment 29 Eric Paris 2012-02-14 21:59:06 UTC
Patch posted for internal review

Comment 30 Aristeu Rozanski 2012-02-28 16:53:44 UTC
Patch(es) available on kernel-2.6.32-241.el6

Comment 35 Martin Prpič 2012-05-18 09:43:30 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
The cred argument has been included in the security_capable() function so that it can be used in a wider range of call sites.

Comment 38 errata-xmlrpc 2012-06-20 07:33:22 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHSA-2012-0862.html