Bug 586663 - SELinux is preventing /bin/bash "open" access on console.
Summary: SELinux is preventing /bin/bash "open" access on console.
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: selinux-policy
Version: 6.0
Hardware: x86_64
OS: Linux
Target Milestone: rc
: ---
Assignee: Daniel Walsh
QA Contact: Milos Malik
Whiteboard: setroubleshoot_trace_hash:778d5612043...
: 585959 (view as bug list)
Depends On:
TreeView+ depends on / blocked
Reported: 2010-04-28 05:14 UTC by Matěj Cepl
Modified: 2012-10-15 15:10 UTC (History)
8 users (show)

Fixed In Version: selinux-policy-3.7.19-14.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2010-11-11 14:56:52 UTC
Target Upstream Version:

Attachments (Terms of Use)

Description Matěj Cepl 2010-04-28 05:14:26 UTC
Happened during the booting of the system without me doing anything particular.

SELinux is preventing /bin/bash "open" access on console.

Podrobný popis:

[SELinux je v tolerantním režimu. Přístup byl povolen.]

SELinux denied access requested by ksmtuned. It is not expected that this access
is required by ksmtuned and this access may signal an intrusion attempt. It is
also possible that the specific version or configuration of the application is
causing it to require additional access.

Povolení přístupu:

You can generate a local policy module to allow this access - see FAQ
(http://docs.fedoraproject.org/selinux-faq-fc5/#id2961385) Please file a bug

Další informace:

Kontext zdroje                system_u:system_r:ksmtuned_t:s0
Kontext cíle                 system_u:object_r:console_device_t:s0
Objekty cíle                 console [ chr_file ]
Zdroj                         ksmtuned
Cesta zdroje                  /bin/bash
Port                          <Neznámé>
Počítač                    (removed)
RPM balíčky zdroje          bash-4.1.2-2.el6
RPM balíčky cíle           
RPM politiky                  selinux-policy-3.7.19-5.el6
Selinux povolen               True
Typ politiky                  targeted
Vynucovací režim            Permissive
Název zásuvného modulu     catchall
Název počítače            (removed)
Platforma                     Linux johanka.ceplovi.cz 2.6.32-22.el6.x86_64 #1
                              SMP Tue Apr 20 12:10:42 EDT 2010 x86_64 x86_64
Počet upozornění           1
Poprvé viděno               St 28. duben 2010, 07:11:53 CEST
Naposledy viděno             St 28. duben 2010, 07:11:53 CEST
Místní ID                   f8a149bf-ea19-4570-93b7-fe8a0d3b4f9e
Čísla řádků              

Původní zprávy auditu      

node=johanka.ceplovi.cz type=AVC msg=audit(1272431513.672:11): avc:  denied  { open } for  pid=1734 comm="ksmtuned" name="console" dev=devtmpfs ino=4848 scontext=system_u:system_r:ksmtuned_t:s0 tcontext=system_u:object_r:console_device_t:s0 tclass=chr_file

node=johanka.ceplovi.cz type=SYSCALL msg=audit(1272431513.672:11): arch=c000003e syscall=2 success=yes exit=3 a0=2278010 a1=802 a2=c a3=1000 items=0 ppid=1733 pid=1734 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="ksmtuned" exe="/bin/bash" subj=system_u:system_r:ksmtuned_t:s0 key=(null)

Hash String generated from  catchall,ksmtuned,ksmtuned_t,console_device_t,chr_file,open
audit2allow suggests:

#============= ksmtuned_t ==============
allow ksmtuned_t console_device_t:chr_file open;

Comment 2 RHEL Program Management 2010-04-28 06:24:18 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for

Comment 3 Daniel Walsh 2010-04-28 13:49:48 UTC
Why is ksmtuned opening the console?

Comment 5 Dan Kenigsberg 2010-04-28 19:36:32 UTC
(In reply to comment #3)
> Why is ksmtuned opening the console?    

Probably due to a bug. I did not intend to, and actually, I don't understand what may cause it. Would you take a look at the ksmtuned script?

Comment 6 Amit Shah 2010-05-04 14:33:55 UTC
I think this was recently fixed in Fedora by an updated selinux-policy.

Comment 7 Dan Kenigsberg 2010-05-04 16:38:37 UTC
(In reply to comment #6)
> I think this was recently fixed in Fedora by an updated selinux-policy.    

What do you mean by "this"? You mean daemon scripts should be allowed to open the console?

The only thing remotely reminiscent I see in strace is /dev/tty which is opened by (any) bash. Can bash be told to avoid this?
# strace -eopen -f /usr/sbin/ksmtuned
open("/etc/ld.so.cache", O_RDONLY)      = 3
open("/lib64/libtinfo.so.5", O_RDONLY)  = 3
open("/lib64/libdl.so.2", O_RDONLY)     = 3
open("/lib64/libc.so.6", O_RDONLY)      = 3
open("/dev/tty", O_RDWR|O_NONBLOCK)     = 3
open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
open("/proc/meminfo", O_RDONLY)         = 3
open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3
open("/usr/sbin/ksmtuned", O_RDONLY)    = 3
open("/etc/ksmtuned.conf", O_RDONLY)    = 3
Process 9713 attached
[pid  9713] open("/etc/ld.so.cache", O_RDONLY) = 3
[pid  9713] open("/lib64/libdl.so.2", O_RDONLY) = 3
[pid  9713] open("/lib64/libm.so.6", O_RDONLY) = 3
[pid  9713] open("/lib64/libc.so.6", O_RDONLY) = 3
[pid  9713] open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
[pid  9713] open("/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3
[pid  9713] open("/proc/meminfo", O_RDONLY) = 3
Process 9713 detached
--- SIGCHLD (Child exited) @ 0 (0) ---
Process 9714 attached
Process 9712 suspended
[pid  9714] open("/etc/ld.so.cache", O_RDONLY) = 3
[pid  9714] open("/lib64/librt.so.1", O_RDONLY) = 3
[pid  9714] open("/lib64/libc.so.6", O_RDONLY) = 3
[pid  9714] open("/lib64/libpthread.so.0", O_RDONLY) = 3
[pid  9714] open("/usr/lib/locale/locale-archive", O_RDONLY) = 3
[pid  9714] open("/var/run/ksmtune.pid", O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK, 0666) = 3
Process 9712 resumed
Process 9714 detached
--- SIGCHLD (Child exited) @ 0 (0) ---
Process 9715 attached
[pid  9712] open("/var/run/ksmtune.pid", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 3
[pid  9715] open("/dev/null", O_RDONLY) = 3
Process 9716 attached
Process 9715 suspended
[pid  9716] open("/dev/null", O_RDONLY) = 3
[pid  9716] open("/etc/ld.so.cache", O_RDONLY) = 3
[pid  9716] open("/lib64/libc.so.6", O_RDONLY) = 3
[pid  9716] open("/usr/lib/locale/locale-archive", O_RDONLY) = 3

Comment 8 Amit Shah 2010-05-04 19:11:06 UTC
I'm not sure of the details. Perhaps dwalsh can tell us.

Comment 9 Daniel Walsh 2010-05-04 19:29:16 UTC
Yes it is happening because bash is opening /dev/console.  It is allowed in the latest policy.


Comment 11 Amit Shah 2010-05-05 10:37:32 UTC
*** Bug 585959 has been marked as a duplicate of this bug. ***

Comment 13 Milos Malik 2010-05-07 14:28:38 UTC
Last 2 lines in /etc/ksmtuned.conf look this way:

# LOGFILE=/var/log/ksmtuned

I uncommented them and then executed following commands:

# setenforce 0
# service ksmtuned start
# service ksmtuned status
# service ksmtuned stop

which led to following AVC:

time->Fri May  7 10:20:31 2010
type=SYSCALL msg=audit(1273242031.291:75597): arch=c000003e syscall=2 success=yes exit=3 a0=19180c0 a1=441 a2=1b6 a3=76 items=0 ppid=29238 pid=29239 auid=0 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0 ses=21 comm="ksmtuned" exe="/bin/bash" subj=unconfined_u:system_r:ksmtuned_t:s0 key=(null)
type=AVC msg=audit(1273242031.291:75597): avc:  denied  { create } for  pid=29239 comm="ksmtuned" name="ksmtuned" scontext=unconfined_u:system_r:ksmtuned_t:s0 tcontext=unconfined_u:object_r:var_log_t:s0 tclass=file
type=AVC msg=audit(1273242031.291:75597): avc:  denied  { add_name } for  pid=29239 comm="ksmtuned" name="ksmtuned" scontext=unconfined_u:system_r:ksmtuned_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=dir
type=AVC msg=audit(1273242031.291:75597): avc:  denied  { write } for  pid=29239 comm="ksmtuned" name="log" dev=dm-0 ino=262829 scontext=unconfined_u:system_r:ksmtuned_t:s0 tcontext=system_u:object_r:var_log_t:s0 tclass=dir

Comment 14 Milos Malik 2010-05-07 14:37:29 UTC
# rpm -q selinux-policy
# matchpathcon /var/log/ksmtuned
/var/log/ksmtuned       system_u:object_r:var_log_t

Comment 15 Daniel Walsh 2010-05-07 15:21:37 UTC
Fixed in selinux-policy-3.7.19-14.el6

Comment 17 releng-rhel@redhat.com 2010-11-11 14:56:52 UTC
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.

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