Bug 624043

Summary: cronie is leaking a file descriptor?
Product: Red Hat Enterprise Linux 6 Reporter: Marcela Mašláňová <mmaslano>
Component: cronieAssignee: Marcela Mašláňová <mmaslano>
Status: CLOSED ERRATA QA Contact: qe-baseos-daemons
Severity: medium Docs Contact:
Priority: medium    
Version: 6.1CC: azelinka, borgan, dwalsh, mcermak, mmaslano, ovasik, tmraz
Target Milestone: rc   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: cronnie_leaks Environment:
Last Closed: 2011-05-19 14:29:06 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:    
Bug Blocks: 677364    

Description Marcela Mašláňová 2010-08-13 14:03:09 UTC
+++ This bug was initially created as a clone of Bug #623908 +++

+++ This bug was initially created as a clone of Bug #621842 +++


Summary:

SELinux is preventing /bin/bash access to a leaked /root file descriptor.

Detailed Description:

[prelink has a permissive type (prelink_cron_system_t). This access was not
denied.]

SELinux denied access requested by the prelink command. It looks like this is
either a leaked descriptor or prelink 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 /root. 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
(http://docs.fedoraproject.org/selinux-faq-fc5/#id2961385)

Additional Information:

Source Context                system_u:system_r:prelink_cron_system_t:s0-s0:c0.c
                              1023
Target Context                system_u:object_r:admin_home_t:s0
Target Objects                /root [ dir ]
Source                        prelink
Source Path                   /bin/bash
Port                          <Unknown>
Host                          (removed)
Source RPM Packages           bash-4.1.7-1.fc13
Target RPM Packages           filesystem-2.4.31-1.fc13
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) 2.6.33.6-147.2.4.fc13.x86_64 #1 SMP
                              Fri Jul 23 17:14:44 UTC 2010 x86_64 x86_64
Alert Count                   1
First Seen                    Fri 06 Aug 2010 11:18:47 AM EEST
Last Seen                     Fri 06 Aug 2010 11:18:47 AM EEST
Local ID                      52b0853a-ed87-468f-ba5a-07c08345fa93
Line Numbers                  

Raw Audit Messages            

node=(removed) type=AVC msg=audit(1281082727.83:20483): avc:  denied  { read } for  pid=13086 comm="prelink" path="/root" dev=sda3 ino=742 scontext=system_u:system_r:prelink_cron_system_t:s0-s0:c0.c1023 tcontext=system_u:object_r:admin_home_t:s0 tclass=dir

node=(removed) type=SYSCALL msg=audit(1281082727.83:20483): arch=c000003e syscall=59 success=yes exit=0 a0=f42860 a1=f42ff0 a2=f42530 a3=7fffab028930 items=0 ppid=3166 pid=13086 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=2 comm="prelink" exe="/bin/bash" subj=system_u:system_r:prelink_cron_system_t:s0-s0:c0.c1023 key=(null)

Updates will be created soon.

Comment 2 Marcela Mašláňová 2010-08-13 14:35:36 UTC
This leak was in code for a long time, but the latest changes, probably in selinux-policy, reveal it. Even if this couldn't be reproduced on RHEL, it should be fixed.

Comment 3 RHEL Program Management 2010-08-13 14:38:00 UTC
This issue has been proposed when we are only considering blocker
issues in the current Red Hat Enterprise Linux release.

** If you would still like this issue considered for the current
release, ask your support representative to file as a blocker on
your behalf. Otherwise ask that it be considered for the next
Red Hat Enterprise Linux release. **

Comment 5 cesar.davalos@inegi.org.mx 2010-08-13 16:11:19 UTC
I do not understand the report that generated a lot of SELinux. Does the error may be an attack?, Error occurred at night, the computer stays on downloading files from a torrent with Transmission program.

Sorry, my English is not very good. Thank you.

Comment 6 Daniel Walsh 2010-08-13 17:20:24 UTC
No it is most likely not an attack but a bug in cronie.

I think cronnie is opening /root and not setting the the file descriptor

fcntl(fd, F_SETFD, FD_CLOEXEC)

This means the file descriptor is leaked to all apps that cronnie starts.  Apps that are confined report this as an AVC error and close the file descriptor.

Other apps can list the contents of the /root directory.

Comment 7 Antonio Bulgheroni 2010-08-13 17:30:28 UTC
I had the same problem with Fedora 13 on a x86 system.

Comment 8 Jonathan Ryshpan 2010-08-13 21:29:55 UTC
I had the same problem with Fedora 13 on a x86_64 system.

Comment 9 Gene Snider 2010-08-13 21:47:59 UTC
I'm having the same problem with F14 developmental branch.

Gene

Comment 10 Dagan McGregor 2010-08-14 05:32:22 UTC
 I just got this error on Fedora 13, x86_64 system

Comment 11 Raphael Groner 2010-08-14 07:39:08 UTC
(In reply to comment #8)
(In reply to comment #10)
Confirmed here, too.

Comment 12 Terry Moschou 2010-08-14 09:06:38 UTC
Got this problem on Fedora 13, x86_64 system, using Oracle VM VirtualBox.

Comment 13 ludwig.7 2010-08-14 13:31:13 UTC
For me it is the same on Fedora x86_64 report today

Comment 14 Jonathan Ryshpan 2010-08-14 16:55:32 UTC
(In reply to comment #0)
> SELinux is preventing /bin/bash access to a leaked /root file descriptor.
> 
> Detailed Description:
> 
> [prelink has a permissive type (prelink_cron_system_t). This access was not
> denied.]

What is a "leaked ... file descriptor"?

Comment 15 Daniel Walsh 2010-08-15 12:01:25 UTC
In C code, when you open a file or socket you get a file descriptor, that you can use to read and write.

By default when you fork another process that process inherits access to the file descriptor.  If you execute a program from that process, the new process inherits (leaks) the file descriptor.

The reason this was done in the beginning was to allow processes to use STDIN, STDOUT, STDERR. (0,1,2) But it can lead to problems.

Most file descriptors should not be allowed to be inherited (leaked) to other programs.

If you look at the "man open" you will see the following

"By  default,  the  new  file descriptor is set to remain open across an
       execve(2) (i.e., the  FD_CLOEXEC  file  descriptor  flag  described  in
       fcntl(2)  is  initially  disabled;  the  Linux-specific O_CLOEXEC flag,
       described below, can be used to change this default).
...

       O_CLOEXEC (Since Linux 2.6.23)
              Enable the close-on-exec  flag  for  the  new  file  descriptor.
              Specifying  this  flag  permits  a  program  to avoid additional
              fcntl(2) F_SETFD operations to set the FD_CLOEXEC  flag.   Addi‐
              tionally,  use  of  this flag is essential in some multithreaded
              programs since using a separate fcntl(2)  F_SETFD  operation  to
              set  the  FD_CLOEXEC  flag does not suffice to avoid race condi‐
              tions where one thread opens a file descriptor at the same  time
              as another thread does a fork(2) plus execve(2).

"

Comment 16 Mark Lacdao 2010-08-16 02:36:18 UTC
I encountered this issue several times on my Fedora 13 on a x86 system.

Comment 17 Jean-Charles Malahieude 2010-08-16 08:47:23 UTC
I encountered this sevreal times since Aug.12 on my x86 Fedora13 box, while just editing a file form my git local repo in emacs.

Comment 18 Alexander Todorov 2010-08-16 08:53:12 UTC
This bug is reported against RHEL6 but when I selected to file the SELinux alert via report I was on F13 system.

Comment 19 Jean-Charles Malahieude 2010-08-16 09:26:29 UTC
(In addition to comment #17)

I omitted to say my box runs 32bits and uname -r is:
2.6.33.6-147.2.4.fc13.i686.PAE

Comment 20 Jean-Charles Malahieude 2010-08-16 09:28:30 UTC
(In addition to comment #17)

I omitted to say my box runs 32bits and uname -r is:
2.6.33.6-147.2.4.fc13.i686.PAE

Comment 21 Tomas Mraz 2010-08-16 09:40:16 UTC
This is RHEL bug, please use Bug #623908 for Fedora reports. And moreover the bug is already solved in the testing update cronie package. Please install it, restart crond and report only when the problem reappears after that.

Comment 22 Jean-Charles Malahieude 2010-08-16 09:46:05 UTC
(In reply to comment #21)
> This is RHEL bug, please use Bug #623908 for Fedora reports. And moreover the
> bug is already solved in the testing update cronie package. Please install it,
> restart crond and report only when the problem reappears after that.

Sorry if this is not the right place, but that's where Selunix invited me when I reported (link provided in the popped up box).

Comment 23 Tomas Mraz 2010-08-16 09:59:38 UTC
That was caused by the copied setroubleshoot hash when the bug was cloned. Hopefully for new reports it should find the original Fedora bug.

Comment 24 Daniel Walsh 2010-08-16 12:06:48 UTC
*** Bug 624223 has been marked as a duplicate of this bug. ***

Comment 25 Daniel Walsh 2010-08-16 12:07:05 UTC
*** Bug 624284 has been marked as a duplicate of this bug. ***

Comment 28 RHEL Program Management 2011-02-15 09:38:20 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. 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. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 37 Martin Cermak 2011-03-15 14:57:54 UTC
Comment #36 => Verified=SanityOnly.

Comment 38 errata-xmlrpc 2011-05-19 14:29:06 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-0788.html