init: allow systemd to relabel /dev and /run
PATCH 1/2 init: allow systemd to relabel /dev and /run
systemd relabels everything in /dev and /run after loading the policy. In these directories there is a socket file for udev, /run/udev/control, which is not allowed to be relabelled from tmpfs_t:
avc: denied { relabelfrom } for pid=1 comm="systemd" name="control" dev="tmpfs" ino=7027 scontext=system_u:system_r:init_t tcontext=system_u:object_r:tmpfs_t tclass=sock_file permissive=1
avc: denied { relabelto } for pid=1 comm="systemd" name="control" dev="tmpfs" ino=7027 scontext=system_u:system_r:init_t tcontext=system_u:object_r:udev_var_run_t tclass=sock_file permissive=1
/run/tmpfiles.d directory (used by systemd-tmpfiles service) is also relabelled.
--- policy/modules/kernel/filesystem.if | 18 +++++++++++++++++ policy/modules/system/init.te | 3 +++ policy/modules/system/systemd.if | 39 +++++++++++++++++++++++++++++++++++++ policy/modules/system/udev.if | 1 + 4 files changed, 61 insertions(+)
policy/modules/kernel/filesystem.if +18 -0
@@ -4553,6 +4553,24 @@ interface(`fs_read_tmpfs_symlinks',` read_lnk_files_pattern($1, tmpfs_t, tmpfs_t) ') +######################################## +## <summary> +## Relabelfrom socket files on tmpfs filesystems. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`fs_relabelfrom_tmpfs_sockets',` + gen_require(` + type tmpfs_t; + ') + + allow $1 tmpfs_t:sock_file relabelfrom_sock_file_perms; +') + ######################################## ## <summary> ## Relabelfrom tmpfs link files.
policy/modules/system/init.te +3 -0
@@ -301,6 +301,7 @@ ifdef(`init_systemd',` # for privatetmp functions fs_relabel_tmpfs_dirs(init_t) fs_relabel_tmpfs_files(init_t) + fs_relabelfrom_tmpfs_sockets(init_t) # mount-setup fs_unmount_autofs(init_t) fs_getattr_pstore_dirs(init_t)
@@ -322,6 +323,8 @@ ifdef(`init_systemd',` systemd_manage_passwd_runtime_symlinks(init_t) systemd_use_passwd_agent(init_t) + systemd_tmpfiles_list_conf(init_t) + systemd_tmpfiles_relabelto_conf(init_t) term_create_devpts(init_t)
policy/modules/system/systemd.if +39 -0
@@ -463,6 +463,45 @@ interface(`systemd_tmpfiles_conf_filetrans',` filetrans_pattern($1, systemd_tmpfiles_conf_t, $2, $3, $4) ') +######################################## +## <summary> +## List systemd tmpfiles config directory. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`systemd_tmpfiles_list_conf',` + gen_require(` + type systemd_tmpfiles_conf_t; + ') + + allow $1 systemd_tmpfiles_conf_t:dir list_dir_perms; +') + +######################################## +## <summary> +## Relabel to systemd tmpfiles config directory +## and files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`systemd_tmpfiles_relabelto_conf',` + gen_require(` + attribute systemd_tmpfiles_conf_type; + type systemd_tmpfiles_conf_t; + ') + + allow $1 systemd_tmpfiles_conf_t:dir relabelto_dir_perms; + allow $1 systemd_tmpfiles_conf_type:file relabelto_file_perms; +') + ####################################### ## <summary> ## Allow systemd_tmpfiles_t to manage filesystem objects
policy/modules/system/udev.if +1 -0
@@ -259,6 +259,7 @@ interface(`udev_relabelto_db',` files_search_pids($1) allow $1 udev_var_run_t:file relabelto_file_perms; allow $1 udev_var_run_t:lnk_file relabelto_file_perms; + allow $1 udev_var_run_t:sock_file relabelto_sock_file_perms; ') ########################################
Signature · 1 line
2.14.1
PATCH 2/2 corecommands: label Arch Linux pacman's scripts as bin_t
On Arch Linux, the package manager uses hooks which execute scripts in /usr/share/libalpm/scripts.
--- policy/modules/kernel/corecommands.fc | 1 + 1 file changed, 1 insertion(+)
policy/modules/kernel/corecommands.fc +1 -0
@@ -300,6 +300,7 @@ ifdef(`distro_gentoo',` /usr/share/gnucash/finance-quote-helper -- gen_context(system_u:object_r:bin_t,s0) /usr/share/hal/device-manager/hal-device-manager -- gen_context(system_u:object_r:bin_t,s0) /usr/share/hal/scripts(/.*)? gen_context(system_u:object_r:bin_t,s0) +/usr/share/libalpm/scripts(/.*)? gen_context(system_u:object_r:bin_t,s0) /usr/share/mc/extfs/.* -- gen_context(system_u:object_r:bin_t,s0) /usr/share/Modules/init(/.*)? gen_context(system_u:object_r:bin_t,s0) /usr/share/org.gnome.Weather/org\.gnome\.Weather\.Application -- gen_context(system_u:object_r:bin_t,s0)
Signature · 1 line
2.14.1
PATCH 2/2 corecommands: label Arch Linux pacman's scripts as bin_t
Quoted 11 lines · Nicolas Iooss via refpolicy
On Arch Linux, the package manager uses hooks which execute scripts in
/usr/share/libalpm/scripts.--- policy/modules/kernel/corecommands.fc | 1 + 1 file changed, 1 insertion(+)policy/modules/kernel/corecommands.fc +0
-0
policy/modules/kernel/corecommands.fc ifdef(`distro_gentoo',` · line 306
Quoted 7 lines
policy/modules/kernel/corecommands.fc +1
-0@@ -300,6 +300,7 @@ ifdef(`distro_gentoo',` /usr/share/gnucash/finance-quote-helper -- gen_context(system_u:object_r:bin_t,s0) /usr/share/hal/device-manager/hal-device-manager -- gen_context(system_u:object_r:bin_t,s0) /usr/share/hal/scripts(/.*)? gen_context(system_u:object_r:bin_t,s0) +/usr/share/libalpm/scripts(/.*)? gen_context(system_u:object_r:bin_t,s0) /usr/share/mc/extfs/.* -- gen_context(system_u:object_r:bin_t,s0) /usr/share/Modules/init(/.*)? gen_context(system_u:object_r:bin_t,s0) /usr/share/org.gnome.Weather/org\.gnome\.Weather\.Application -- gen_context(system_u:object_r:bin_t,s0)
Merged.
Signature · 1 line
Chris PeBenito
PATCH 1/2 init: allow systemd to relabel /dev and /run
In reply to Nicolas IoossQuoted 82 lines · Nicolas Iooss via refpolicy
systemd relabels everything in /dev and /run after loading the policy. In these directories there is a socket file for udev,
/run/udev/control, which is not allowed to be relabelled fromtmpfs_t:avc: denied { relabelfrom } for pid=1 comm="systemd" name="control" dev="tmpfs" ino=7027 scontext=system_u:system_r:init_t tcontext=system_u:object_r:tmpfs_t tclass=sock_file permissive=1
avc: denied { relabelto } for pid=1 comm="systemd" name="control" dev="tmpfs" ino=7027 scontext=system_u:system_r:init_t tcontext=system_u:object_r:udev_var_run_t tclass=sock_file permissive=1
/run/tmpfiles.ddirectory (used by systemd-tmpfiles service) is also relabelled.--- policy/modules/kernel/filesystem.if | 18 +++++++++++++++++ policy/modules/system/init.te | 3 +++ policy/modules/system/systemd.if | 39 +++++++++++++++++++++++++++++++++++++ policy/modules/system/udev.if | 1 + 4 files changed, 61 insertions(+)policy/modules/kernel/filesystem.if +18
-0@@ -4553,6 +4553,24 @@ interface(`fs_read_tmpfs_symlinks',` read_lnk_files_pattern($1, tmpfs_t, tmpfs_t) ') +######################################## +## <summary> +## Relabelfrom socket files on tmpfs filesystems. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`fs_relabelfrom_tmpfs_sockets',` + gen_require(` + type tmpfs_t; + ') + + allow $1 tmpfs_t:sock_file relabelfrom_sock_file_perms; +') + ######################################## ## <summary> ## Relabelfrom tmpfs link files.policy/modules/system/init.te +3
-0@@ -301,6 +301,7 @@ ifdef(`init_systemd',` # for privatetmp functions fs_relabel_tmpfs_dirs(init_t) fs_relabel_tmpfs_files(init_t) + fs_relabelfrom_tmpfs_sockets(init_t) # mount-setup fs_unmount_autofs(init_t) fs_getattr_pstore_dirs(init_t)@@ -322,6 +323,8 @@ ifdef(`init_systemd',` systemd_manage_passwd_runtime_symlinks(init_t) systemd_use_passwd_agent(init_t) + systemd_tmpfiles_list_conf(init_t) + systemd_tmpfiles_relabelto_conf(init_t) term_create_devpts(init_t)policy/modules/system/systemd.if +1
-0@@ -463,6 +463,45 @@ interface(`systemd_tmpfiles_conf_filetrans',` filetrans_pattern($1, systemd_tmpfiles_conf_t, $2, $3, $4) ') +########################################
policy/modules/system/systemd.if interface(`systemd_tmpfiles_conf_filetrans',` · line 476
Quoted 10 lines
policy/modules/system/systemd.if +10
-0+## <summary> +## List systemd tmpfiles config directory. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`systemd_tmpfiles_list_conf',`
Should be systemd_list_tmpfiles_conf
Quoted 9 lines
policy/modules/system/systemd.if +9
-0+ gen_require(` + type systemd_tmpfiles_conf_t; + ') + + allow $1 systemd_tmpfiles_conf_t:dir list_dir_perms; +') + +######################################## +## <summary>
policy/modules/system/systemd.if interface(`systemd_tmpfiles_conf_filetrans',` · line 495
Quoted 10 lines
policy/modules/system/systemd.if +10
-0+## Relabel to systemd tmpfiles config directory +## and files. +## </summary> +## <param name="domain"> +## <summary> +## Domain allowed access. +## </summary> +## </param> +# +interface(`systemd_tmpfiles_relabelto_conf',`
Should be 2 interfaces: systemd_relabelto_tmpfiles_conf_files and systemd_relabelto_tmpfiles_conf_dirs
Quoted 17 lines
policy/modules/system/systemd.if +9
-0+ gen_require(` + attribute systemd_tmpfiles_conf_type; + type systemd_tmpfiles_conf_t; + ') + + allow $1 systemd_tmpfiles_conf_t:dir relabelto_dir_perms; + allow $1 systemd_tmpfiles_conf_type:file relabelto_file_perms; +') + ####################################### ## <summary> ## Allow systemd_tmpfiles_t to manage filesystem objectspolicy/modules/system/udev.if +0
-0
policy/modules/system/udev.if interface(`udev_relabelto_db',` · line 262
Quoted 4 lines
policy/modules/system/udev.if +1
-0@@ -259,6 +259,7 @@ interface(`udev_relabelto_db',` files_search_pids($1) allow $1 udev_var_run_t:file relabelto_file_perms; allow $1 udev_var_run_t:lnk_file relabelto_file_perms; + allow $1 udev_var_run_t:sock_file relabelto_sock_file_perms;
Should be a separate interface.
The patch also needs a rebase.
Signature · 1 line
Chris PeBenito