Bug 623466 - SELinux is preventing /usr/sbin/nscd access to a leaked /dev/null file descriptor.
Summary: SELinux is preventing /usr/sbin/nscd access to a leaked /dev/null file descri...
Alias: None
Product: Fedora
Classification: Fedora
Component: rpm
Version: 13
Hardware: i386
OS: Linux
Target Milestone: ---
Assignee: Panu Matilainen
QA Contact: Fedora Extras Quality Assurance
Whiteboard: setroubleshoot_trace_hash:e33baeffd2a...
Depends On:
TreeView+ depends on / blocked
Reported: 2010-08-11 20:26 UTC by Steve Tyler
Modified: 2014-01-21 23:16 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2011-06-28 14:42:18 UTC
Type: ---

Attachments (Terms of Use)

Description Steve Tyler 2010-08-11 20:26:54 UTC

SELinux is preventing /usr/sbin/nscd access to a leaked /dev/null file

Detailed Description:

[nscd has a permissive type (nscd_t). This access was not denied.]

SELinux denied access requested by the nscd command. It looks like this is
either a leaked descriptor or nscd output was redirected to a file it is not
allowed to access. Leaks usually can be ignored since SELinux is just closing
the leak and reporting the error. The application does not use the descriptor,
so it will run properly. If this is a redirection, you will not get output in
the /dev/null. You should generate a bugzilla on selinux-policy, and it will get
routed to the appropriate package. You can safely ignore this avc.

Allowing Access:

You can generate a local policy module to allow this access - see FAQ

Additional Information:

Source Context                unconfined_u:system_r:nscd_t:s0-s0:c0.c1023
Target Context                unconfined_u:object_r:device_t:s0
Target Objects                /dev/null [ file ]
Source                        nscd
Source Path                   /usr/sbin/nscd
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           nscd-2.12-3
Target RPM Packages           
Policy RPM                    selinux-policy-3.7.19-41.fc13
Selinux Enabled               True
Policy Type                   targeted
Enforcing Mode                Enforcing
Plugin Name                   leaks
Host Name                     (removed)
Platform                      Linux (removed) #1 SMP
                              Fri Jul 23 17:21:06 UTC 2010 i686 i686
Alert Count                   32
First Seen                    Sat 07 Aug 2010 02:59:13 PM PDT
Last Seen                     Sat 07 Aug 2010 03:01:13 PM PDT
Local ID                      ab9bee59-e966-4886-a1ad-7c3646e7cfbe
Line Numbers                  

Raw Audit Messages            

node=(removed) type=AVC msg=audit(1281218473.990:210): avc:  denied  { write } for  pid=4902 comm="nscd" path="/dev/null" dev=sda7 ino=169346 scontext=unconfined_u:system_r:nscd_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:device_t:s0 tclass=file

node=(removed) type=SYSCALL msg=audit(1281218473.990:210): arch=40000003 syscall=11 success=yes exit=0 a0=80598b3 a1=bffb77b0 a2=bffb77c4 a3=bffb7904 items=0 ppid=4898 pid=4902 auid=500 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=1 comm="nscd" exe="/usr/sbin/nscd" subj=unconfined_u:system_r:nscd_t:s0-s0:c0.c1023 key=(null)

Hash String generated from  leaks,nscd,nscd_t,device_t,file,write
audit2allow suggests:

#============= nscd_t ==============
allow nscd_t device_t:file write;

Comment 1 Steve Tyler 2010-08-11 21:00:31 UTC
AFAICT, the first occurrence was during a massive update on Aug 7, 2010.

Snippet from /var/log/messages-20100808:
Aug  7 14:56:25 maple yum[4236]: Installed: bzip2-1.0.5-6.fc12.i686
Aug  7 14:56:26 maple yum[4236]: Installed: pcre-7.8-3.fc12.i686
Aug  7 14:56:27 maple setroubleshoot: SELinux is preventing /usr/sbin/groupadd access to a leaked /dev/null file descriptor. For complete SELinux messages. run sealert -l 351f77ca-8fef-4d62-a53d-aed11492d410
Aug  7 14:56:29 maple yum[4236]: Installed: grep-2.6.3-1.fc13.i686
Aug  7 14:56:33 maple yum[4236]: Installed: lua-5.1.4-4.fc12.i686

The context is now:
$ ls -Z /dev/null
crw-rw-rw-. root root system_u:object_r:null_device_t:s0 /dev/null

NB: This system was a clean F13 net install using all default settings for a Gnome desktop configuration on a laptop.

I can attach logs if needed.

Comment 2 Steve Tyler 2010-08-11 22:00:03 UTC
Whoops! Those log messages say "Installed", not "Updated". I now remember doing an non-standard yum install to another partition in an experiment to try installing without anaconda.

# history | grep groupinstall
  147  yum groupinstall Base --installroot=`pwd` --releasever=13

The other partition was previously formatted and mounted.

Comment 3 Miroslav Grepl 2010-08-12 11:18:48 UTC
Something was wrong (maybe udev problem) and /dev/null was mislabeled. Now it has right context and it will work.

Comment 4 Steve Tyler 2010-08-12 16:56:00 UTC
(In reply to comment #3)
> Something was wrong (maybe udev problem) and /dev/null was mislabeled. Now it
> has right context and it will work.    

I easily reproduced this bug as suggested in comment 2.

mkdir fake_root
cd fake_root
sudo yum groupinstall Base --installroot=`pwd` --releasever=13

The mislabelling is in fake_root/dev:

[stephent@walnut fake_root]$ ls -Z dev
-rw-r--r--. root root unconfined_u:object_r:device_t:s0 null
-rw-r--r--. root root unconfined_u:object_r:device_t:s0 stderr
[stephent@walnut fake_root]$ ls -l dev
total 4
-rw-r--r--. 1 root root  0 Aug 12 09:43 null
-rw-r--r--. 1 root root 45 Aug 12 09:43 stderr
[stephent@walnut fake_root]$ 

Snippet from /var/log/messages:
Aug 12 09:38:35 localhost yum[6293]: Installed: libacl-2.2.49-6.fc13.x86_64
Aug 12 09:38:36 localhost yum[6293]: Installed: 2:shadow-utils-
Aug 12 09:38:36 localhost kernel: type=1400 audit(1281631116.450:29492): avc:  denied  { write } for  pid=6507 comm="groupadd" path="/dev/null" dev=dm-4 ino=4073123 scontext=unconfined_u:system_r:groupadd_t:s0-s0:c0.c1023 tcontext=unconfined_u:object_r:device_t:s0 tclass=file
Aug 12 09:38:37 localhost yum[6293]: Installed: 1:dbus-1.2.24-1.fc13.x86_64
Aug 12 09:38:37 localhost yum[6293]: Installed: 1:findutils-4.4.2-8.fc13.x86_64

Comment 5 Daniel Walsh 2010-08-12 20:31:24 UTC
I guess I would say this is a yum/rpm error.  Although I am not sure how I would fix this.  Rpm needs to be faked out that the chroot path is eliminated.

Comment 6 Steve Tyler 2010-08-13 14:36:09 UTC
I may have narrowed this down a bit.
It looks like dev/null with the wrong security context is created when
device-mapper-libs is installed.


mkdir fake_root
cd fake_root

In a new terminal window run:
watch -n 1 'ls --lcontext dev 2>&1'

Start the install:
sudo yum install --installroot=`pwd` --releasever=13 device-mapper-libs

When it completes, dev/null exists:

$ ls --lcontext dev
total 0
-rw-r--r--. 1 unconfined_u:object_r:device_t:s0 root root 0 Aug 13 07:01 null


Comment 7 Daniel Walsh 2010-08-13 18:16:43 UTC
Just seems like a very strange context to get created. Wait it is created as a file rather then a device.

Comment 8 Daniel Walsh 2010-08-13 18:17:32 UTC
Maybe rpm and yum are working correctly but post install scripts are causing these files to get created as files.

Comment 9 Daniel Walsh 2010-08-13 18:20:19 UTC
mkdir -p fake_root/dev
sudo mount -o bind /dev fake_root/dev
cd fake_root
sudo yum groupinstall Base --installroot=`pwd` --releasever=13

Should work

Comment 10 Daniel Walsh 2010-08-13 18:23:23 UTC
This might be an example of where we would want yum/rpm to not put down labels, like with mock.

Comment 11 Steve Tyler 2010-08-13 18:52:20 UTC
(In reply to comment #8)
> Maybe rpm and yum are working correctly but post install scripts are causing
> these files to get created as files.    

In the chroot environment during the install, the "filesystem" package creates /dev, but /dev/null does not exist, so the first script that opens /dev/null could end up creating it as a regular file.

> Wait it is created as a file rather then a device.

They both are regular files:

[stephent@walnut fake_root]$ cat dev/stderr
The default plymouth plugin () doesn't exist
[stephent@walnut fake_root]$

Comment 12 Daniel Walsh 2010-08-13 19:10:07 UTC
Yes I figured this out.

Comment 13 Bug Zapper 2011-06-01 11:39:01 UTC
This message is a reminder that Fedora 13 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 13.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '13'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 13's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 13 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 

Comment 14 Bug Zapper 2011-06-28 14:42:18 UTC
Fedora 13 changed to end-of-life (EOL) status on 2011-06-25. Fedora 13 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.

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