Bug 586663 - SELinux is preventing /bin/bash "open" access on console.
SELinux is preventing /bin/bash "open" access on console.
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: selinux-policy (Show other bugs)
x86_64 Linux
medium Severity medium
: rc
: ---
Assigned To: Daniel Walsh
Milos Malik
: 585959 (view as bug list)
Depends On:
  Show dependency treegraph
Reported: 2010-04-28 01:14 EDT by Matěj Cepl
Modified: 2012-10-15 11:10 EDT (History)
8 users (show)

See Also:
Fixed In Version: selinux-policy-3.7.19-14.el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2010-11-11 09:56:52 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Matěj Cepl 2010-04-28 01:14:26 EDT
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 Product and Program Management 2010-04-28 02:24:18 EDT
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 09:49:48 EDT
Why is ksmtuned opening the console?
Comment 5 Dan Kenigsberg 2010-04-28 15:36:32 EDT
(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 10:33:55 EDT
I think this was recently fixed in Fedora by an updated selinux-policy.
Comment 7 Dan Kenigsberg 2010-05-04 12:38:37 EDT
(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 15:11:06 EDT
I'm not sure of the details. Perhaps dwalsh can tell us.
Comment 9 Daniel Walsh 2010-05-04 15:29:16 EDT
Yes it is happening because bash is opening /dev/console.  It is allowed in the latest policy.

Comment 11 Amit Shah 2010-05-05 06:37:32 EDT
*** Bug 585959 has been marked as a duplicate of this bug. ***
Comment 13 Milos Malik 2010-05-07 10:28:38 EDT
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 10:37:29 EDT
# 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 11:21:37 EDT
Fixed in selinux-policy-3.7.19-14.el6
Comment 17 releng-rhel@redhat.com 2010-11-11 09:56:52 EST
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.