RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1029386 - avc denial in rescue mode
Summary: avc denial in rescue mode
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: selinux-policy
Version: 7.0
Hardware: Unspecified
OS: Linux
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Miroslav Grepl
QA Contact: Milos Malik
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-11-12 10:26 UTC by Karel Volný
Modified: 2015-01-08 10:04 UTC (History)
2 users (show)

Fixed In Version: selinux-policy-3.12.1-109.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-06-13 12:27:34 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
screenshot from my VM booted with "single" parameter (37.65 KB, image/png)
2013-11-28 10:19 UTC, Milos Malik
no flags Details

Description Karel Volný 2013-11-12 10:26:01 UTC
Description of problem:
I'm getting AVC denial for sulogin trying to access /proc/kcore
I'm really not sure if this is necessary, so instead for selinux policy to allow this, I'm filing for util-linux not to do this.

Version-Release number of selected component (if applicable):
util-linux-2.33.2-6.el7.x86_64

How reproducible:
(haven't retried)

Steps to Reproduce:
1. in grub, choose rescue, edit the commands and append "single" on the kernel line

Actual results:
[    3.548044] type=1400 audit(1384250750.510:4): avc:  denied  { getattr } for  pid=550 comm="sulogin" path="/proc/kcore" dev="proc" ino=4026532032 scontext=system_u:system_r:sulogin_t:s0-s0:c0.c1023 tcontext=system_u:object_r:proc_kcore_t:s0 tclass=file

Expected results:
(no denial)

Additional info:

Comment 2 Karel Zak 2013-11-12 11:18:18 UTC
It seems correct, sulogin(1) scans /dev and calls fstatat() for all devices (to get console tty) and there is /dev/kcore symlink to /proc/kcore.

Assigning to selinux policy.


[Just for the record, this sulogin code seems stupid as we can use dirent->d_type from readdir() or/and device names from /proc/consoles, but this code improvement is probably better to do in upstream tree. The current code with /dev scan is good enough for the current RHEL7.]

Comment 5 Miroslav Grepl 2013-11-26 15:24:24 UTC
commit a421f5f060eaf5c0d500dbda68ca4670c1a6c96c
Author: Miroslav Grepl <mgrepl>
Date:   Tue Nov 26 16:23:56 2013 +0100

    Allow sulogin to getattr on /proc/kcore

Comment 6 Milos Malik 2013-11-28 10:19:29 UTC
Created attachment 830130 [details]
screenshot from my VM booted with "single" parameter

Comment 7 Karel Volný 2013-11-29 12:53:48 UTC
(In reply to Karel Zak from comment #2)
> [Just for the record, this sulogin code seems stupid as we can use
> dirent->d_type from readdir() or/and device names from /proc/consoles, but
> this code improvement is probably better to do in upstream tree. The current
> code with /dev scan is good enough for the current RHEL7.]

thanks for the analysis; so, you have filed upstream bugreport, and you are about to file a bug for selinux-policy referencing that upstream bug with a note that once the code gets reworked this change in policy can get reverted, right? :-)

Comment 8 Karel Zak 2013-11-29 15:02:33 UTC
(In reply to Karel Volný from comment #7)
> (In reply to Karel Zak from comment #2)
> > [Just for the record, this sulogin code seems stupid as we can use
> > dirent->d_type from readdir() or/and device names from /proc/consoles, but
> > this code improvement is probably better to do in upstream tree. The current
> > code with /dev scan is good enough for the current RHEL7.]
> 
> thanks for the analysis; so, you have filed upstream bugreport

It's already improved in upstream code (commit commit 3deb67f50d513a1a74a62e8e248357e844e701a2), so it calls fstat() for character devices only if readdir() returns d_type (this depends on FS type and libc).

> and you are
> about to file a bug for selinux-policy referencing that upstream bug with a

well, it's not a bug if any code calls stat() to get device type, the problem is unnecessary selinux paranoia...

> note that once the code gets reworked this change in policy can get
> reverted, right? :-)

I think it will be better to keep this change in the selinux policy to make things more robust. It's really no security sensitive thing.

Comment 9 Karel Volný 2013-11-29 16:03:01 UTC
(In reply to Karel Zak from comment #8)
> (In reply to Karel Volný from comment #7)
> > (In reply to Karel Zak from comment #2)
> > > [Just for the record, this sulogin code seems stupid as we can use
> > > dirent->d_type from readdir() or/and device names from /proc/consoles, but
> > > this code improvement is probably better to do in upstream tree. The current
> > > code with /dev scan is good enough for the current RHEL7.]
> > 
> > thanks for the analysis; so, you have filed upstream bugreport
> 
> It's already improved in upstream code (commit commit
> 3deb67f50d513a1a74a62e8e248357e844e701a2), so it calls fstat() for character
> devices only if readdir() returns d_type (this depends on FS type and libc).

ok, cool!

> > and you are
> > about to file a bug for selinux-policy referencing that upstream bug with a
> 
> well, it's not a bug if any code calls stat() to get device type, the
> problem is unnecessary selinux paranoia...

I thought being paranoid is the point of selinux ... anyways, selinux guys were informed via this bug, so let's leave it upon them how do they feel about keeping this change after the code change gets downstream

Comment 10 Miroslav Grepl 2013-12-06 14:34:34 UTC
Milos,
does it work with sys_admin capability?

Comment 11 Milos Malik 2013-12-06 14:45:34 UTC
# rpm -qa selinux-policy\*
selinux-policy-doc-3.12.1-108.el7.noarch
selinux-policy-targeted-3.12.1-108.el7.noarch
selinux-policy-devel-3.12.1-108.el7.noarch
selinux-policy-3.12.1-108.el7.noarch
selinux-policy-minimum-3.12.1-108.el7.noarch
selinux-policy-mls-3.12.1-108.el7.noarch
# sesearch -s sulogin_t -t sulogin_t -c capability -A -C
Found 1 semantic av rules:
   allow sulogin_t sulogin_t : capability { dac_override sys_tty_config } ; 

# 

I still see the sys_admin AVC (the second AVC mentioned in comment#3).

Going to test the scenario with custom policy module.

Comment 12 Milos Malik 2013-12-06 14:53:15 UTC
[    2.816177] type=1400 audit(1386341301.995:4): avc:  denied  { getattr } for  pid=396 comm="sulogin" path="/dev/initctl" dev="devtmpfs" ino=15467 scontext=system_u:system_r:sulogin_t:s0-s0:c0.c1023 tcontext=system_u:object_r:initctl_t:s0 tclass=fifo_file

This AVC appears when following rule is present and the VM is booted into single mode.

allow sulogin_t sulogin_t : capability { sys_admin };

Comment 13 Milos Malik 2013-12-06 14:59:06 UTC
Following policy module solved the problem on my VM, where selinux-policy-3.12.1-108.el7 is installed:

module mypolicy 1.0;

require {
        type sulogin_t;
        type initctl_t;
        class capability { sys_admin };
        class fifo_file { getattr };
}

#============= useradd_t ==============
allow sulogin_t sulogin_t : capability { sys_admin };
allow sulogin_t initctl_t : fifo_file { getattr };

Comment 15 Ludek Smid 2014-06-13 12:27:34 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.


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