commit:     b093761cac708c6320ea8588f089cb98fd974a24
Author:     Christian Göttsche <cgzones <AT> googlemail <DOT> com>
AuthorDate: Thu Feb 22 17:00:44 2024 +0000
Commit:     Kenton Groombridge <concord <AT> gentoo <DOT> org>
CommitDate: Fri Mar  1 17:05:50 2024 +0000
URL:        
https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=b093761c

systemd: binfmt updates

    type=PROCTITLE msg=audit(21/02/24 22:54:36.708:53) : 
proctitle=/usr/lib/systemd/systemd-binfmt
    type=SYSCALL msg=audit(21/02/24 22:54:36.708:53) : arch=x86_64 
syscall=fstatfs success=yes exit=0 a0=0x5 a1=0x7ffc547fbda0 a2=0x0 a3=0x0 
items=0 ppid=1 pid=694 auid=unset uid=root gid=root euid=root suid=root 
fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset 
comm=systemd-binfmt exe=/usr/lib/systemd/systemd-binfmt 
subj=system_u:system_r:systemd_binfmt_t:s0 key=(null)
    type=AVC msg=audit(21/02/24 22:54:36.708:53) : avc:  denied  { getattr } 
for  pid=694 comm=systemd-binfmt name=/ dev=binfmt_misc ino=1 
scontext=system_u:system_r:systemd_binfmt_t:s0 
tcontext=system_u:object_r:binfmt_misc_fs_t:s0 tclass=filesystem permissive=1

    type=PROCTITLE msg=audit(21/02/24 22:54:36.708:54) : 
proctitle=/usr/lib/systemd/systemd-binfmt
    type=PATH msg=audit(21/02/24 22:54:36.708:54) : item=0 name=/proc/self/fd/4 
inode=1 dev=00:27 mode=dir,755 ouid=root ogid=root rdev=00:00 
obj=system_u:object_r:binfmt_misc_fs_t:s0 nametype=NORMAL cap_fp=none 
cap_fi=none cap_fe=0 cap_fver=0 cap_frootid=0
    type=CWD msg=audit(21/02/24 22:54:36.708:54) : cwd=/
    type=SYSCALL msg=audit(21/02/24 22:54:36.708:54) : arch=x86_64 
syscall=access success=yes exit=0 a0=0x7ffc547fbdf0 a1=W_OK a2=0x0 a3=0x0 
items=1 ppid=1 pid=694 auid=unset uid=root gid=root euid=root suid=root 
fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset 
comm=systemd-binfmt exe=/usr/lib/systemd/systemd-binfmt 
subj=system_u:system_r:systemd_binfmt_t:s0 key=(null)
    type=AVC msg=audit(21/02/24 22:54:36.708:54) : avc:  denied  { write } for  
pid=694 comm=systemd-binfmt name=/ dev=binfmt_misc ino=1 
scontext=system_u:system_r:systemd_binfmt_t:s0 
tcontext=system_u:object_r:binfmt_misc_fs_t:s0 tclass=dir permissive=1

Signed-off-by: Christian Göttsche <cgzones <AT> googlemail.com>
Signed-off-by: Kenton Groombridge <concord <AT> gentoo.org>

 policy/modules/kernel/filesystem.if | 37 +++++++++++++++++++++++++++++++++++++
 policy/modules/system/systemd.te    |  6 ++++++
 2 files changed, 43 insertions(+)

diff --git a/policy/modules/kernel/filesystem.if 
b/policy/modules/kernel/filesystem.if
index 08ad5503d..ae022b6c0 100644
--- a/policy/modules/kernel/filesystem.if
+++ b/policy/modules/kernel/filesystem.if
@@ -602,6 +602,24 @@ interface(`fs_manage_autofs_symlinks',`
        manage_lnk_files_pattern($1, autofs_t, autofs_t)
 ')
 
+########################################
+## <summary>
+##     Get the attributes of binfmt_misc filesystems.
+## </summary>
+## <param name="domain">
+##     <summary>
+##     Domain allowed access.
+##     </summary>
+## </param>
+#
+interface(`fs_getattr_binfmt_misc_fs',`
+       gen_require(`
+               type binfmt_misc_fs_t;
+       ')
+
+       allow $1 binfmt_misc_fs_t:filesystem getattr;
+')
+
 ########################################
 ## <summary>
 ##     Get the attributes of directories on
@@ -622,6 +640,25 @@ interface(`fs_getattr_binfmt_misc_dirs',`
 
 ')
 
+########################################
+## <summary>
+##     Check for permissions using access(2) of directories on
+##     binfmt_misc filesystems.
+## </summary>
+## <param name="domain">
+##     <summary>
+##     Domain allowed access.
+##     </summary>
+## </param>
+#
+interface(`fs_check_write_binfmt_misc_dirs',`
+       gen_require(`
+               type binfmt_misc_fs_t;
+       ')
+
+       allow $1 binfmt_misc_fs_t:dir { getattr write };
+')
+
 ########################################
 ## <summary>
 ##     Register an interpreter for new binary

diff --git a/policy/modules/system/systemd.te b/policy/modules/system/systemd.te
index 6d07466e6..63fef177b 100644
--- a/policy/modules/system/systemd.te
+++ b/policy/modules/system/systemd.te
@@ -401,6 +401,7 @@ fs_search_cgroup_dirs(systemd_backlight_t)
 #
 
 kernel_read_kernel_sysctls(systemd_binfmt_t)
+kernel_getattr_proc(systemd_binfmt_t)
 
 systemd_log_parse_environment(systemd_binfmt_t)
 
@@ -409,6 +410,11 @@ files_read_etc_files(systemd_binfmt_t)
 
 fs_register_binary_executable_type(systemd_binfmt_t)
 
+fs_getattr_binfmt_misc_fs(systemd_binfmt_t)
+fs_check_write_binfmt_misc_dirs(systemd_binfmt_t)
+
+fs_getattr_cgroup(systemd_binfmt_t)
+fs_search_cgroup_dirs(systemd_binfmt_t)
 
 ######################################
 #

Reply via email to