Commit Graph

3270 Commits

Author SHA1 Message Date
Nicolas Iooss
789307d57e
mount: allow callers of mount to search /usr/bin
In order to be able to invoke /usr/bin/mount, /usr/bin/fusermount, etc.
callers need to be able to search /usr/bin. Otherwise, such denials are
recorded:

    type=AVC msg=audit(1576534518.220:1320): avc:  denied  { search }
    for  pid=24067 comm="cryfs" name="bin" dev="vda1" ino=524829
    scontext=sysadm_u:sysadm_r:cryfs_t tcontext=system_u:object_r:bin_t
    tclass=dir permissive=0

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-12-22 16:54:51 +01:00
Chris PeBenito
17f06cf1fe unconfined: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-12-02 08:47:19 -05:00
Chris PeBenito
9a04561643 Merge pull request #130 from pebenito/unconfined-systemd-user 2019-12-02 08:45:44 -05:00
Chris PeBenito
832face6f2 logging: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-11-23 10:27:14 -05:00
Chris PeBenito
9c3c525aa8 logging: Reorder lines.
No rule change.

Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-11-23 10:26:50 -05:00
Sugar, David
a9ae616800 resolve syslog imuxsock denial
I'm seeing the following error while starting rsyslog:
Nov 17 02:01:38 localhost rsyslogd: cannot create '/run/systemd/journal/syslog': Permission denied [v8.24.0-41.el7_7.2]
Nov 17 02:01:38 localhost rsyslogd: imuxsock does not run because we could not aquire any socket  [v8.24.0-41.el7_7.2]
Nov 17 02:01:38 localhost rsyslogd: activation of module imuxsock failed [v8.24.0-41.el7_7.2]

With the following denials:
type=AVC msg=audit(1573958708.773:1896): avc:  denied  { create } for  pid=2347 comm="rsyslogd" name="syslog" scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:syslogd_runtime_t:s0 tclass=sock_file permissive=1
type=AVC msg=audit(1573958708.773:1897): avc:  denied  { setattr } for  pid=2347 comm="rsyslogd" name="syslog" dev="tmpfs" ino=19368 scontext=system_u:system_r:syslogd_t:s0 tcontext=system_u:object_r:syslogd_runtime_t:s0 tclass=sock_file permissive=1

Signed-off-by: Dave Sugar <dsugar@tresys.com>
2019-11-23 10:24:13 -05:00
Chris PeBenito
45bd96f619 various: Module version bump. 2019-11-23 09:54:36 -05:00
Chris PeBenito
8fcd20b9f9 Merge pull request #127 from pebenito/unconfined-cap_userns 2019-11-23 09:51:42 -05:00
Chris PeBenito
42d115aa53 unconfined: Fix systemd --user rule.
Use the full init_pgm_spec_user_daemon_domain() to ensure correct
permissions.

Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2019-11-22 16:39:35 -05:00
Chris PeBenito
87745f09d9 unconfined: Add namespaced capabilities.
Signed-off-by: Chris PeBenito <chpebeni@linux.microsoft.com>
2019-11-15 11:13:58 -05:00
Laurent Bigonville
53a76d3fb7 Allow alsa_t to set scheduling priority and send signal to itself
When alsactl is running as a daemon with systemd, it sets its process
priority to be nice to other processes. When stopping the service, it's
signaling to itself that it needs to exit.

----
time->Sun Oct  6 11:59:59 2019
type=AVC msg=audit(1570355999.755:43): avc:  denied  { setsched } for  pid=794 comm="alsactl" scontext=system_u:system_r:alsa_t:s0 tcontext=system_u:system_r:alsa_t:s0 tclass=process permissive=1
----
time->Sun Oct  6 11:59:59 2019
type=AVC msg=audit(1570355999.755:44): avc:  denied  { getsched } for  pid=794 comm="alsactl" scontext=system_u:system_r:alsa_t:s0 tcontext=system_u:system_r:alsa_t:s0 tclass=process permissive=1
----
time->Sun Oct  6 12:07:26 2019
type=AVC msg=audit(1570356446.747:292): avc:  denied  { signal } for  pid=3585 comm="alsactl" scontext=system_u:system_r:alsa_t:s0 tcontext=system_u:system_r:alsa_t:s0 tclass=process permissive=1

Signed-off-by: Laurent Bigonville <bigon@bigon.be>
2019-10-31 12:08:03 +01:00
Laurent Bigonville
56a11f07c3 Allow alsa_t to create alsa_runtime_t file as well
When alsactl is started as a daemon, it creates a pidfile
(/run/alsactl.pid), that needs to be allowed

----
time->Sun Oct  6 10:59:09 2019
type=AVC msg=audit(1570352349.743:45): avc:  denied  { write open } for  pid=804 comm="alsactl" path="/run/alsactl.pid" dev="tmpfs" ino=25882 scontext=system_u:system_r:alsa_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=file permissive=1
type=AVC msg=audit(1570352349.743:45): avc:  denied  { create } for  pid=804 comm="alsactl" name="alsactl.pid" scontext=system_u:system_r:alsa_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=file permissive=1
----
time->Sun Oct  6 11:54:38 2019
type=AVC msg=audit(1570355678.226:657): avc:  denied  { open } for  pid=9186 comm="alsactl" path="/run/alsactl.pid" dev="tmpfs" ino=25882 scontext=system_u:system_r:alsa_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=file permissive=1
type=AVC msg=audit(1570355678.226:657): avc:  denied  { read } for  pid=9186 comm="alsactl" name="alsactl.pid" dev="tmpfs" ino=25882 scontext=system_u:system_r:alsa_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=file permissive=1
----
time->Sun Oct  6 11:54:38 2019
type=AVC msg=audit(1570355678.230:659): avc:  denied  { unlink } for  pid=804 comm="alsactl" name="alsactl.pid" dev="tmpfs" ino=25882 scontext=system_u:system_r:alsa_t:s0 tcontext=system_u:object_r:var_run_t:s0 tclass=file permissive=1

Signed-off-by: Laurent Bigonville <bigon@bigon.be>
2019-10-31 12:08:03 +01:00
Laurent Bigonville
9b18951eb0 Allow realmd_t to read localization files
----
time->Sat Oct  5 13:11:40 2019
type=AVC msg=audit(1570273900.483:148): avc:  denied  { open } for  pid=1382 comm="realmd" path="/etc/locale.alias" dev="dm-1" ino=1047048 scontext=system_u:system_r:realmd_t:s0 tcontext=system_u:object_r:locale_t:s0 tclass=file permissive=1
type=AVC msg=audit(1570273900.483:148): avc:  denied  { read } for  pid=1382 comm="realmd" name="locale.alias" dev="dm-1" ino=1047048 scontext=system_u:system_r:realmd_t:s0 tcontext=system_u:object_r:locale_t:s0 tclass=file permissive=1
type=AVC msg=audit(1570273900.483:148): avc:  denied  { read } for  pid=1382 comm="realmd" name="locale.alias" dev="dm-1" ino=262415 scontext=system_u:system_r:realmd_t:s0 tcontext=system_u:object_r:locale_t:s0 tclass=lnk_file permissive=1
type=AVC msg=audit(1570273900.483:148): avc:  denied  { search } for  pid=1382 comm="realmd" name="locale" dev="dm-1" ino=262056 scontext=system_u:system_r:realmd_t:s0 tcontext=system_u:object_r:locale_t:s0 tclass=dir permissive=1
----
time->Sat Oct  5 13:11:40 2019
type=AVC msg=audit(1570273900.483:149): avc:  denied  { getattr } for  pid=1382 comm="realmd" path="/etc/locale.alias" dev="dm-1" ino=1047048 scontext=system_u:system_r:realmd_t:s0 tcontext=system_u:object_r:locale_t:s0 tclass=file permissive=1
----

Signed-off-by: Laurent Bigonville <bigon@bigon.be>
2019-10-31 12:08:03 +01:00
Laurent Bigonville
69d88981bc Allow geoclue to log in syslog
----
time->Thu Oct  3 17:16:40 2019
type=AVC msg=audit(1570115800.136:513): avc:  denied  { create } for  pid=1384 comm="geoclue" scontext=system_u:system_r:geoclue_t:s0 tcontext=system_u:system_r:geoclue_t:s0 tclass=unix_dgram_socket permissive=1
----
time->Thu Oct  3 17:16:40 2019
type=AVC msg=audit(1570115800.136:514): avc:  denied  { sendto } for  pid=1384 comm="geoclue" path="/run/systemd/journal/socket" scontext=system_u:system_r:geoclue_t:s0 tcontext=system_u:system_r:syslogd_t:s0 tc
lass=unix_dgram_socket permissive=1
type=AVC msg=audit(1570115800.136:514): avc:  denied  { write } for  pid=1384 comm="geoclue" name="socket" dev="tmpfs" ino=1781 scontext=system_u:system_r:geoclue_t:s0 tcontext=system_u:object_r:devlog_t:s0 tcla
ss=sock_file permissive=1
type=AVC msg=audit(1570115800.136:514): avc:  denied  { search } for  pid=1384 comm="geoclue" name="journal" dev="tmpfs" ino=1777 scontext=system_u:system_r:geoclue_t:s0 tcontext=system_u:object_r:syslogd_runtim
e_t:s0 tclass=dir permissive=1
type=AVC msg=audit(1570115800.136:514): avc:  denied  { search } for  pid=1384 comm="geoclue" name="systemd" dev="tmpfs" ino=11001 scontext=system_u:system_r:geoclue_t:s0 tcontext=system_u:object_r:init_runtime_
t:s0 tclass=dir permissive=1
type=AVC msg=audit(1570115800.136:514): avc:  denied  { write } for  pid=1384 comm="geoclue" scontext=system_u:system_r:geoclue_t:s0 tcontext=system_u:system_r:geoclue_t:s0 tclass=unix_dgram_socket permissive=1
----

Signed-off-by: Laurent Bigonville <bigon@bigon.be>
2019-10-31 12:05:05 +01:00
Laurent Bigonville
805f2d9cd4 Allow the systemd dbus-daemon to talk to systemd
Recent versions of dbus are started as Type=notify

type=AVC msg=audit(03/10/19 15:32:40.347:64) : avc:  denied  { write } for  pid=809 comm=dbus-daemon name=notify dev="tmpfs" ino=1751 scontext=system_u:system_r:system_dbusd_t:s0-s0:c0.c1023 tcontext=system_u:object_r:init_runtime_t:s0 tclass=sock_file permissive=1

Signed-off-by: Laurent Bigonville <bigon@bigon.be>
2019-10-31 12:05:05 +01:00
Chris PeBenito
04a83b9616 init: Module version bump. 2019-10-31 04:12:24 -04:00
Chris PeBenito
bb48674bd1 init: Whitespace change.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-10-31 03:33:14 -04:00
Sugar, David
36ebc670cb Add missing gen_require for init_t in init_script_domain
Signed-off-by: Dave Sugar <dsugar@tresys.com>
2019-10-31 03:31:52 -04:00
Chris PeBenito
69cd9b4614 xserver: Move XDM dbus chats under main dbus optional. 2019-10-12 11:38:52 -04:00
Chris PeBenito
9731e44e43 xserver: Remove duplicate colord rule.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-10-12 11:37:00 -04:00
Chris PeBenito
6f19979a2f gpg, systemd: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-10-03 19:05:05 -04:00
Chris PeBenito
17512a799d Merge pull request #117 from fishilico/gpg-crypto-fips 2019-10-03 18:59:04 -04:00
Nicolas Iooss
15151782bd
gpg: allow gpg-agent to read crypto.fips_enabled sysctl
On Debian 10, when gpg-agent starts, it reads crypto.fips_enabled:

    type=AVC msg=audit(1569958604.280:42): avc:  denied  { open } for
    pid=329 comm="gpg-agent" path="/proc/sys/crypto/fips_enabled"
    dev="proc" ino=14687 scontext=sysadm_u:sysadm_r:gpg_agent_t
    tcontext=system_u:object_r:sysctl_crypto_t tclass=file permissive=1

    type=AVC msg=audit(1569958604.280:42): avc:  denied  { read } for
    pid=329 comm="gpg-agent" name="fips_enabled" dev="proc" ino=14687
    scontext=sysadm_u:sysadm_r:gpg_agent_t
    tcontext=system_u:object_r:sysctl_crypto_t tclass=file permissive=1

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-10-01 21:58:24 +02:00
Nicolas Iooss
90a2688712
systemd: make the kernel spawn systemd-coredump with a context transition
On Arch Linux, /proc/sys/kernel/core_pattern contains:

    |/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h

When a crash happens in a userspace application, this setting makes the
kernel spawn /usr/lib/systemd/systemd-coredump from kernel_t:

    type=AVC msg=audit(1569910108.877:336): avc:  denied  { execute }
    for  pid=1087 comm="kworker/u2:3" name="systemd-coredump" dev="vda1"
    ino=406365 scontext=system_u:system_r:kernel_t
    tcontext=system_u:object_r:systemd_coredump_exec_t tclass=file
    permissive=1

Introduce a transition to systemd_coredump_t to handle this.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-10-01 21:30:29 +02:00
Chris PeBenito
52e9d4daf0 filesystem, systemd: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-09-30 20:57:29 -04:00
Chris PeBenito
1a124285df Merge pull request #112 from fishilico/systemd-sd-executor-use 2019-09-30 20:43:01 -04:00
Chris PeBenito
1a30ab4fd8 Merge pull request #111 from fishilico/filesystem-fs_rw_cgroup_files-follow-symlink 2019-09-30 20:42:21 -04:00
Chris PeBenito
7d4bdb86ce Merge pull request #108 from fishilico/systemd-user-2019-09 2019-09-30 20:41:35 -04:00
Chris PeBenito
291f68a119 various: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-09-30 20:39:31 -04:00
Chris PeBenito
61ecff5c31 Remove old aliases.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-09-30 20:02:43 -04:00
Chris PeBenito
d6c7154f1c Reorder declarations based on *_runtime_t renaming.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-09-30 20:02:43 -04:00
Chris PeBenito
69a403cd97 Rename *_var_run_t types to *_runtime_t.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-09-30 20:02:43 -04:00
Nicolas Iooss
ea816582f0
systemd: allow user environment helpers to communicate with systemd --user
"systemd --user" spawns programs from
/usr/lib/systemd/user-environment-generators/ in order to gather
environment variables. On a Debian 10 virtual machine which gnupg, this
directory contains:

    $ ls -Z /usr/lib/systemd/user-environment-generators
    system_u:object_r:bin_t 30-systemd-environment-d-generator
    system_u:object_r:bin_t 90gpg-agent

For sysadm, these programs are run as sysadm_t (because there is a
transition in systemd_role_template() in systemd.if:
corecmd_bin_domtrans($1_systemd_t, $3)) but use file descriptors created
by their parent process, which runs as sysadm_systemd_t. This leads to:

    type=AVC msg=audit(1569756917.537:244): avc:  denied  { use } for
    pid=9713 comm="30-systemd-envi"
    path=2F6D656D66643A33302D73797374656D642D656E7669726F6E6D656E742D642D67656E657261746F72202864656C6574656429
    dev="tmpfs" ino=24859 scontext=sysadm_u:sysadm_r:sysadm_t
    tcontext=sysadm_u:sysadm_r:sysadm_systemd_t tclass=fd permissive=0

    type=AVC msg=audit(1569756917.537:244): avc:  denied  { use } for
    pid=9713 comm="30-systemd-envi"
    path="/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator"
    dev="vda1" ino=655822 scontext=sysadm_u:sysadm_r:sysadm_t
    tcontext=sysadm_u:sysadm_r:sysadm_systemd_t tclass=fd permissive=0

    type=SYSCALL msg=audit(1569756917.537:244): arch=c000003e syscall=59
    success=no exit=-13 a0=5647d12cf020 a1=7ffc605b1fb0 a2=7ffc605b2420
    a3=0 items=0 ppid=9712 pid=9713 auid=1000 uid=1000 gid=1000
    euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000
    tty=(none) ses=10 comm="30-systemd-envi"
    exe="/usr/lib/systemd/user-environment-generators/30-systemd-environment-d-generator"
    subj=sysadm_u:sysadm_r:sysadm_t key=(null)

    [...]

    type=AVC msg=audit(1569756917.541:246): avc:  denied  { use } for
    pid=9714 comm="90gpg-agent"
    path=2F6D656D66643A39306770672D6167656E74202864656C6574656429
    dev="tmpfs" ino=24860 scontext=sysadm_u:sysadm_r:sysadm_t
    tcontext=sysadm_u:sysadm_r:sysadm_systemd_t tclass=fd permissive=0

    type=AVC msg=audit(1569756917.541:246): avc:  denied  { use } for
    pid=9714 comm="90gpg-agent" path="/usr/bin/bash" dev="vda1"
    ino=524662 scontext=sysadm_u:sysadm_r:sysadm_t
    tcontext=sysadm_u:sysadm_r:sysadm_systemd_t tclass=fd permissive=0

In systemd's source, here are the relevant functions:

* manager_run_environment_generators() calls execute_directories(paths,
  DEFAULT_TIMEOUT_USEC, gather_environment, ...) [1], with
  gather_environment a global table defined in exec-util.c [2]

* execute_directories() opens a "serialization fd" [3], that creates a
  memfd for communication with the child processes [4].

* execute_directories() calls fork() and do_execute() [5] in order to
  run each child process, providing them with the memfd descriptor in
  order to gather their output.

* When a child process is executed, its context transitions from
  sysadm_systemd_t to sysadm_t. The child then writes environment
  variables to its output.

* The parent process (systemd --user) collects the environment variables
  that have been written, and "consumes" the produced output in order to
  override its environment variables.

[1] https://github.com/systemd/systemd/blob/v243/src/core/manager.c#L3836
[2] https://github.com/systemd/systemd/blob/v243/src/shared/exec-util.c#L413
[3] https://github.com/systemd/systemd/blob/v243/src/shared/exec-util.c#L213
[4] https://github.com/systemd/systemd/blob/v243/src/shared/serialize.c#L200
[5] https://github.com/systemd/systemd/blob/v243/src/shared/exec-util.c#L226

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-30 22:43:31 +02:00
Nicolas Iooss
d2c553d528
filesystem: allow following symlinks with fs_rw_cgroup_files()
fs_read_cgroup_files() grants access to reading files and to following
symlinks (with "read_lnk_files_pattern($1, cgroup_t, cgroup_t)").
fs_rw_cgroup_files() does not include such a rule, which is needed in
order to transparently use symlinks such as /sys/fs/cgroup/cpu. This
access is currently denied, for example to "systemd --user" daemon:

    type=AVC msg=audit(1569756917.537:242): avc:  denied  { getattr }
    for  pid=9710 comm="systemd" path="/sys/fs/cgroup/cpu" dev="tmpfs"
    ino=9683 scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:cgroup_t tclass=lnk_file permissive=0

    type=SYSCALL msg=audit(1569756917.537:242): arch=c000003e
    syscall=262 success=no exit=-13 a0=ffffff9c a1=7ffc605b1f70
    a2=7ffc605b1ea0 a3=100 items=0 ppid=1 pid=9710 auid=1000 uid=1000
    gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000
    fsgid=1000 tty=(none) ses=10 comm="systemd"
    exe="/usr/lib/systemd/systemd"
    subj=sysadm_u:sysadm_r:sysadm_systemd_t key=(null)

    type=PROCTITLE msg=audit(1569756917.537:242):
    proctitle=2F6C69622F73797374656D642F73797374656D64002D2D75736572

On this system (Debian 10), /sys/fs/cgroup/cpu is a symlink to
/sys/fs/cgroup/cpu,cpuacct.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-30 22:42:40 +02:00
Nicolas Iooss
7b61521c4c
systemd: remove unnecessary init_write_runtime_socket()
init_write_runtime_socket(systemd_user_session_type) is redundant with
init_dgram_send(systemd_user_session_type).

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-19 23:06:58 +02:00
Nicolas Iooss
e942a3171e
systemd: allow more accesses to systemd --user
systemd --user needs to:

* run statfs() on /sys/fs/cgroup, which is a tmpfs on Debian 10:

    type=AVC msg=audit(1568544950.691:309): avc:  denied  { getattr }
    for  pid=10128 comm="systemd" name="/" dev="tmpfs" ino=9656
    scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:tmpfs_t tclass=filesystem permissive=0

    type=SYSCALL msg=audit(1568544950.691:309): arch=c000003e
    syscall=137 success=no exit=-13 a0=7f96e8b23ddb a1=7ffefbffb410
    a2=7f96e7b3c2a0 a3=0 items=0 ppid=1 pid=10128 auid=1000 uid=1000
    gid=1000 euid=1000 suid=1000 fsuid=1000 egid=1000 sgid=1000
    fsgid=1000 tty=(none) ses=14 comm="systemd"
    exe="/usr/lib/systemd/systemd"
    subj=sysadm_u:sysadm_r:sysadm_systemd_t key=(null)

    type=PROCTITLE msg=audit(1568544950.691:309):
    proctitle=2F6C69622F73797374656D642F73797374656D64002D2D75736572

    # ls -Zdi /sys/fs/cgroup  # ino=9656 is /sys/fs/cgroup
    9656 system_u:object_r:cgroup_t /sys/fs/cgroup

    # findmnt /sys/fs/cgroup
    /sys/fs/cgroup tmpfs  tmpfs  ro,nosuid,nodev,noexec,seclabel,mode=755

* read /proc/sys/fs/nr_open:

    type=AVC msg=audit(1568545206.580:392): avc:  denied  { search } for
    pid=19003 comm="systemd" name="fs" dev="proc" ino=9699
    scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:sysctl_fs_t tclass=dir permissive=1

    type=AVC msg=audit(1568545206.580:392): avc:  denied  { read } for
    pid=19003 comm="systemd" name="nr_open" dev="proc" ino=14620
    scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:sysctl_fs_t tclass=file permissive=1

    type=AVC msg=audit(1568545206.580:392): avc:  denied  { open } for
    pid=19003 comm="systemd" path="/proc/sys/fs/nr_open" dev="proc"
    ino=14620 scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:sysctl_fs_t tclass=file permissive=1

    type=SYSCALL msg=audit(1568545206.580:392): arch=c000003e
    syscall=257 success=yes exit=4 a0=ffffff9c a1=7fe0d8a8665f a2=80000
    a3=0 items=0 ppid=1 pid=19003 auid=1000 uid=1000 gid=1000 euid=1000
    suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none)
    ses=16 comm="systemd" exe="/usr/lib/systemd/systemd"
    subj=sysadm_u:sysadm_r:sysadm_systemd_t key=(null)

    type=PROCTITLE msg=audit(1568545206.580:392):
    proctitle=2F6C69622F73797374656D642F73797374656D64002D2D75736572

* notify systemd like services (this was not allowed because *_systemd_t
  is not associated with attribute "daemon"):

    type=AVC msg=audit(1568545206.748:410): avc:  denied  { write } for
    pid=19003 comm="systemd" name="notify" dev="tmpfs" ino=9840
    scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:init_runtime_t tclass=sock_file
    permissive=1

    type=AVC msg=audit(1568545206.748:410): avc:  denied  { sendto } for
    pid=19003 comm="systemd" path="/run/systemd/notify"
    scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:system_r:init_t tclass=unix_dgram_socket
    permissive=1

    type=SERVICE_START msg=audit(1568545206.756:411): pid=1 uid=0
    auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t
    msg='unit=user@1000 comm="systemd" exe="/usr/lib/systemd/systemd"
    hostname=? addr=? terminal=? res=success'

    type=SYSCALL msg=audit(1568545206.748:410): arch=c000003e syscall=46
    success=yes exit=36 a0=1e a1=7ffe70f2abf0 a2=4000 a3=7ffe70f2ab84
    items=0 ppid=1 pid=19003 auid=1000 uid=1000 gid=1000 euid=1000
    suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none)
    ses=16 comm="systemd" exe="/usr/lib/systemd/systemd"
    subj=sysadm_u:sysadm_r:sysadm_systemd_t key=(null)

    type=PROCTITLE msg=audit(1568545206.748:410):
    proctitle=2F6C69622F73797374656D642F73797374656D64002D2D75736572

* use /sys/fs/selinux/create to help define its own sockcreate
  attribute:

    type=AVC msg=audit(1568545206.748:406): avc:  denied  { write } for
    pid=19003 comm="systemd" name="create" dev="selinuxfs" ino=7
    scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:security_t tclass=file permissive=1
    type=SYSCALL msg=audit(1568545206.748:406): arch=c000003e
    syscall=257 success=yes exit=12 a0=ffffff9c a1=7ffe70f29da0 a2=80002
    a3=0 items=0 ppid=1 pid=19003 auid=1000 uid=1000 gid=1000 euid=1000
    suid=1000 fsuid=1000 egid=1000 sgid=1000 fsgid=1000 tty=(none)
    ses=16 comm="systemd" exe="/usr/lib/systemd/systemd"
    subj=sysadm_u:sysadm_r:sysadm_systemd_t key=(null)
    type=PROCTITLE msg=audit(1568545206.748:406):
    proctitle=2F6C69622F73797374656D642F73797374656D64002D2D75736572

    type=AVC msg=audit(1568545206.748:407): avc:  denied  {
    compute_create } for  pid=19003 comm="systemd"
    scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=system_u:object_r:security_t tclass=security permissive=1
    type=SYSCALL msg=audit(1568545206.748:407): arch=c000003e syscall=1
    success=yes exit=71 a0=c a1=5555d61eadb0 a2=47 a3=0 items=0 ppid=1
    pid=19003 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000
    egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=16 comm="systemd"
    exe="/usr/lib/systemd/systemd"
    subj=sysadm_u:sysadm_r:sysadm_systemd_t key=(null)
    type=PROCTITLE msg=audit(1568545206.748:407):
    proctitle=2F6C69622F73797374656D642F73797374656D64002D2D75736572

    type=AVC msg=audit(1568545206.748:408): avc:  denied  {
    setsockcreate } for  pid=19003 comm="systemd"
    scontext=sysadm_u:sysadm_r:sysadm_systemd_t
    tcontext=sysadm_u:sysadm_r:sysadm_systemd_t tclass=process
    permissive=1
    type=SYSCALL msg=audit(1568545206.748:408): arch=c000003e syscall=1
    success=yes exit=35 a0=c a1=5555d61e1320 a2=23 a3=3 items=0 ppid=1
    pid=19003 auid=1000 uid=1000 gid=1000 euid=1000 suid=1000 fsuid=1000
    egid=1000 sgid=1000 fsgid=1000 tty=(none) ses=16 comm="systemd"
    exe="/usr/lib/systemd/systemd"
    subj=sysadm_u:sysadm_r:sysadm_systemd_t key=(null)
    type=PROCTITLE msg=audit(1568545206.748:408):
    proctitle=2F6C69622F73797374656D642F73797374656D64002D2D75736572

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-19 21:20:57 +02:00
Chris PeBenito
4f1346357a portage, selinuxutil: Module version bump. 2019-09-18 19:40:17 -04:00
Chris PeBenito
454fb463cf Merge pull request #87 from fishilico/portage-consoletype-optional 2019-09-18 19:39:53 -04:00
Petr Lautrbach
e0813db519 newrole: allow newrole to use setcap to drop capabilities
Commit 61b72e0796 ("selinuxutil: adjustments") removed negative permission
matching for newrole_t:process. One of the removed permission was setcap which
is needed by newrole as it tries to drop capabilities:

    $ newrole -r sysadm_r
    Sorry, newrole failed to drop capabilities
    : Permission denied

    type=PROCTITLE msg=audit(09/06/2019 15:07:01.908:10821) : proctitle=newrole -r sysadm_r

    type=SYSCALL msg=audit(09/06/2019 15:07:01.908:10821) : arch=x86_64
    syscall=capset success=no exit=EACCES(Permission denied) a0=0x7fbe17d4cb6c
    a1=0x7fbe17d4cb74 a2=0x7fbe17d4d5d0 a3=0x0 items=0 ppid=4981 pid=7255
    auid=admin uid=admin gid=admin euid=admin
    suid=admin fsuid=admin egid=admin sgid=admin fsgid=admin tty=tty1 ses=6
    comm=newrole exe=/usr/bin/newrole subj=staff_u:staff_r:newrole_t:s0
    key=(null)

    type=AVC msg=audit(09/06/2019 15:07:01.908:10821) : avc:  denied  { setcap }
    for  pid=7255 comm=newrole scontext=staff_u:staff_r:newrole_t:s0
    tcontext=staff_u:staff_r:newrole_t:s0 tclass=process permissive=0

Signed-off-by: Petr Lautrbach <plautrba@redhat.com>
2019-09-18 15:34:29 +02:00
Chris PeBenito
ab4ec89d70 sudo, systemd, udev: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-09-14 16:28:14 -04:00
Chris PeBenito
4de8b76b2f Merge pull request #102 from fishilico/systemd-networkd-hostnamed 2019-09-14 16:22:43 -04:00
Chris PeBenito
9021670648 Merge pull request #103 from fishilico/systemd-networkd-generic-netlink 2019-09-14 16:22:42 -04:00
Chris PeBenito
df6870c51b Merge pull request #104 from fishilico/sudo-sigwinch 2019-09-14 16:22:40 -04:00
Nicolas Iooss
a6d13cd456
systemd: allow detecting Windows Subsystem for Linux
Since systemd 242 (commit
6c8a2c6793),
systemd and its services read /proc/sys/kernel/osrelease in order to
detect whether they are running in Microsoft's WSL (Windows Subsystem
for Linux).

This leads to logs such as:

    type=AVC msg=audit(1568445663.990:10): avc:  denied  { read } for
    pid=401 comm="systemd-modules" name="osrelease" dev="proc" ino=13319
    scontext=system_u:system_r:systemd_modules_load_t
    tcontext=system_u:object_r:sysctl_kernel_t tclass=file permissive=1

    type=AVC msg=audit(1568445663.990:10): avc:  denied  { open } for
    pid=401 comm="systemd-modules" path="/proc/sys/kernel/osrelease"
    dev="proc" ino=13319
    scontext=system_u:system_r:systemd_modules_load_t
    tcontext=system_u:object_r:sysctl_kernel_t tclass=file permissive=1

    type=AVC msg=audit(1568445663.990:11): avc:  denied  { getattr } for
    pid=401 comm="systemd-modules" path="/proc/sys/kernel/osrelease"
    dev="proc" ino=13319
    scontext=system_u:system_r:systemd_modules_load_t
    tcontext=system_u:object_r:sysctl_kernel_t tclass=file permissive=1

Add kernel_read_kernel_sysctls() to services that read
/proc/sys/kernel/osrelease. These services have been identified by
running "grep osrelease < /var/log/audit/audit.log | audit2allow" on an
Arch Linux test system.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-14 14:36:13 +02:00
Nicolas Iooss
1097ce0e24
sudo: allow using CAP_KILL for SIGWINCH
With the following process tree:

    LABEL                           UID    PID  PPID  TTY   CMD
    sysadm_u:sysadm_r:sysadm_t      root  18146 12404 pts/0 /usr/bin/zsh
    sysadm_u:sysadm_r:sysadm_sudo_t root  18441 18146 pts/0 sudo -su user
    sysadm_u:sysadm_r:sysadm_sudo_t root  18443 18441 pts/1 sudo -su user
    sysadm_u:sysadm_r:sysadm_t      user  18444 18443 pts/1 /usr/bin/zsh

When the terminal window of the first process is resized, SIGWINCH is
forwarded by process 18443, which requests capability CAP_KILL:

    type=AVC msg=audit(1567881640.754:13839): avc:  denied  { kill } for
    pid=18443 comm="sudo" capability=5
    scontext=sysadm_u:sysadm_r:sysadm_sudo_t
    tcontext=sysadm_u:sysadm_r:sysadm_sudo_t tclass=capability
    permissive=0

    type=SYSCALL msg=audit(1567881640.754:13839): arch=c000003e
    syscall=62 success=no exit=-1 a0=ffffb7f4 a1=1c a2=ffffffff a3=100
    items=0 ppid=18441 pid=18443 auid=1000 uid=0 gid=1000 euid=0 suid=0
    fsuid=0 egid=1000 sgid=1000 fsgid=1000 tty=pts1 ses=690 comm="sudo"
    exe="/usr/bin/sudo" subj=sysadm_u:sysadm_r:sysadm_sudo_t key=(null)

    type=PROCTITLE msg=audit(1567881640.754:13839):
    proctitle=7375646F002D73750075736572

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-14 14:00:58 +02:00
Nicolas Iooss
42b966d2df
sudo: allow transmitting SIGWINCH to its child
When resizing the X11 window of a terminal running sudo on a remote
Debian 10 system (through ssh), sudo forwards SIGWINCH to its children
(this behavior might be caused by using "Defaults use_pty" in
/etc/sudoers). This leads to the following audit logs:

    type=AVC msg=audit(1567880108.988:13823): avc:  denied  { signal }
    for pid=15670 comm="sudo" scontext=sysadm_u:sysadm_r:sysadm_sudo_t
    tcontext=sysadm_u:sysadm_r:sysadm_t tclass=process permissive=0

    type=SYSCALL msg=audit(1567880108.988:13823): arch=c000003e
    syscall=62 success=no exit=-13 a0=ffffc2c9 a1=1c a2=ffffffff a3=100
    items=0 ppid=15607 pid=15670 auid=1000 uid=0 gid=0 euid=0 suid=0
    fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts6 ses=721 comm="sudo"
    exe="/usr/bin/sudo" subj=sysadm_u:sysadm_r:sysadm_sudo_t key=(null)

    type=PROCTITLE msg=audit(1567880108.988:13823):
    proctitle=2F7573722F62696E2F7375646F002D73

The process tree (ps -ef, edited) on this remote system was:

    LABEL                           UID    PID  PPID  TTY   CMD
    system_u:system_r:sshd_t        user  15519 15480 ?     sshd: user@pts/5
    sysadm_u:sysadm_r:sysadm_t      user  15524 15519 pts/5 -zsh
    sysadm_u:sysadm_r:sysadm_sudo_t root  15607 15524 pts/5 /usr/bin/sudo -s
    sysadm_u:sysadm_r:sysadm_sudo_t root  15670 15607 pts/6 /usr/bin/sudo -s
    sysadm_u:sysadm_r:sysadm_t      root  15671 15670 pts/6 /usr/bin/zsh

The denied syscall was:

* syscall=62: int kill(pid_t pid, int sig)
* a0=ffffc2c9: pid = -15671 (process group of sudo's child)
* a1=1c: sig = 28 = SIGWINCH

Allow such a signal to be transmitted.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-14 13:58:39 +02:00
Nicolas Iooss
19542fd26a
systemd-networkd: allow communicating with hostnamed
When systemd-netwokd receives DHCP option 12 (hostname), it changes the
hostname by calling method SetHostname from interface
org.freedesktop.hostname1 provided by systemd-hostnamed:
https://github.com/systemd/systemd/blob/v243/src/network/networkd-manager.c#L1946

This access is currently denied and reported:

    type=USER_AVC msg=audit(1568403789.952:36): pid=288 uid=105
    auid=4294967295 ses=4294967295 subj=system_u:system_r:system_dbusd_t
    msg='avc:  denied  { send_msg } for msgtype=method_call
    interface=org.freedesktop.hostname1 member=SetHostname
    dest=org.freedesktop.hostname1 spid=233 tpid=317
    scontext=system_u:system_r:systemd_networkd_t
    tcontext=system_u:system_r:systemd_hostnamed_t tclass=dbus
    permissive=1  exe="/usr/bin/dbus-daemon" sauid=105 hostname=? addr=?
    terminal=?'

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-14 13:55:57 +02:00
Nicolas Iooss
ba45fc06c8
systemd-networkd: allow creating a generic netlink socket
Since systemd 237 (commit
05d0c2e3cf),
systemd-networkd requires a generic netlink socket in order to start.
Otherwise, it fails to start and systemd's journal contains:

    audit[19262]: AVC avc:  denied  { create } for  pid=19262
    comm="systemd-network" scontext=system_u:system_r:systemd_networkd_t
    tcontext=system_u:system_r:systemd_networkd_t
    tclass=netlink_generic_socket permissive=0

    audit[19262]: SYSCALL arch=c000003e syscall=41 success=no exit=-13
    a0=10 a1=80803 a2=10 a3=20 items=0 ppid=1 pid=19262 auid=4294967295
    uid=102 gid=103 euid=102 suid=102 fsuid=102 egid=103 sgid=103
    fsgid=103 tty=(none) ses=4294967295 comm="systemd-network"
    exe="/usr/lib/systemd/systemd-networkd"
    subj=system_u:system_r:systemd_networkd_t key=(null)

    audit: PROCTITLE proctitle="/lib/systemd/systemd-networkd"

    systemd-networkd[19262]: Could not create manager: Permission denied

For information, "syscall=41 a0=10 a1=80803 a2=10" means:

    socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_GENERIC);

... which matches the call to sd_genl_socket_open(&m->genl); in
https://github.com/systemd/systemd/blob/v243/src/network/networkd-manager.c#L1143

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2019-09-14 13:53:17 +02:00
Chris PeBenito
a5dab43a85 various: Module version bump.
Signed-off-by: Chris PeBenito <pebenito@ieee.org>
2019-09-11 06:52:32 -04:00
Chris PeBenito
c6396d5a79 Merge pull request #88 from fishilico/usr-bin-fc 2019-09-11 06:26:24 -04:00