Updates for RPM module
cover Updates for RPM module
A series of changes for the RPM module. I reviewed the changes that are in the RedHat targeted policy while working on these patches to keep things as similar as possible.
Dave Sugar (5):
grant rpm permission to map rpm_var_lib_t
grant permission for rpm to write to audit log
grant rpm permissions on locale_t
Allow rpm to map file contexts
Allow rpm scripts to alter systemd services
policy/modules/admin/rpm.te | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
Signature · 1 line
2.21.0
PATCH 1/5 grant rpm permission to map rpm_var_lib_t
type=AVC msg=audit(1560913896.432:218): avc: denied { map } for pid=1265 comm="rpm" path="/var/lib/rpm/__db.001" dev="dm-0" ino=2223 scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:object_r:rpm_var_lib_t:s0 tclass=file permissive=1
--- policy/modules/admin/rpm.te | 1 + 1 file changed, 1 insertion(+)
policy/modules/admin/rpm.te +1 -0
@@ -111,6 +111,7 @@ files_lock_filetrans(rpm_t, rpm_lock_t, file) manage_dirs_pattern(rpm_t, rpm_var_lib_t, rpm_var_lib_t) manage_files_pattern(rpm_t, rpm_var_lib_t, rpm_var_lib_t) +mmap_read_files_pattern(rpm_t, rpm_var_lib_t, rpm_var_lib_t) files_var_lib_filetrans(rpm_t, rpm_var_lib_t, { dir file }) manage_dirs_pattern(rpm_t, rpm_var_run_t, rpm_var_run_t)
Signature · 1 line
2.21.0
Re: [PATCH 1/5] grant rpm permission to map rpm_var_lib_t
Quoted 12 lines · David
type=AVC msg=audit(1560913896.432:218): avc: denied { map } for pid=1265 comm="rpm" path="/var/lib/rpm/__db.001" dev="dm-0" ino=2223 scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:object_r:rpm_var_lib_t:s0 tclass=file permissive=1
Signed-off-by Dave Sugar <[email protected]>--- policy/modules/admin/rpm.te | 1 + 1 file changed, 1 insertion(+)policy/modules/admin/rpm.te +0
-0
policy/modules/admin/rpm.te files_lock_filetrans(rpm_t, rpm_lock_t, file) · line 117
Quoted 7 lines
policy/modules/admin/rpm.te +1
-0@@ -111,6 +111,7 @@ files_lock_filetrans(rpm_t, rpm_lock_t, file) manage_dirs_pattern(rpm_t, rpm_var_lib_t, rpm_var_lib_t) manage_files_pattern(rpm_t, rpm_var_lib_t, rpm_var_lib_t) +mmap_read_files_pattern(rpm_t, rpm_var_lib_t, rpm_var_lib_t) files_var_lib_filetrans(rpm_t, rpm_var_lib_t, { dir file }) manage_dirs_pattern(rpm_t, rpm_var_run_t, rpm_var_run_t)
Merged.
Signature · 1 line
Chris PeBenito
PATCH 2/5 grant permission for rpm to write to audit log
In reply to Sugar, DavidMessages like this are added to the audit log when an rpm is installed:
type=SOFTWARE_UPDATE msg=audit(1560913896.581:244): pid=1265 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:rpm_t:s0 msg='sw="ntpdate-4.2.6p5-25.el7_3.2.x86_64" sw_type=rpm key_enforce=0 gpg_res=0 root_dir="/" comm="rpm" exe="/usr/bin/rpm" hostname=? addr=? terminal=? res=success'
These are the denials that I'm seeing:
type=AVC msg=audit(1560913896.581:243): avc: denied { audit_write } for pid=1265 comm="rpm" capability=29 scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=capability permissive=1
type=AVC msg=audit(1561298132.446:240): avc: denied { create } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1
type=AVC msg=audit(1561298132.446:241): avc: denied { write } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1
type=AVC msg=audit(1561298132.446:241): avc: denied { nlmsg_relay } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1
type=AVC msg=audit(1561298132.447:243): avc: denied { read } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1--- policy/modules/admin/rpm.te | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
policy/modules/admin/rpm.te +2 -1
@@ -73,7 +73,7 @@ files_tmpfs_file(rpm_script_tmpfs_t) # rpm Local policy # -allow rpm_t self:capability { chown dac_override fowner fsetid ipc_lock mknod setfcap setgid setuid sys_chroot sys_nice sys_tty_config }; +allow rpm_t self:capability { audit_write chown dac_override fowner fsetid ipc_lock mknod setfcap setgid setuid sys_chroot sys_nice sys_tty_config }; allow rpm_t self:process { transition signal_perms getsched setsched getsession getpgid setpgid getcap setcap share getattr setexec setfscreate noatsecure siginh setrlimit rlimitinh dyntransition execmem setkeycreate setsockcreate getrlimit }; allow rpm_t self:fd use; allow rpm_t self:fifo_file rw_fifo_file_perms;
@@ -87,6 +87,7 @@ allow rpm_t self:msgq create_msgq_perms; allow rpm_t self:msg { send receive }; allow rpm_t self:file rw_file_perms; allow rpm_t self:netlink_kobject_uevent_socket create_socket_perms; +allow rpm_t self:netlink_audit_socket { nlmsg_relay create_socket_perms }; allow rpm_t rpm_log_t:file { append_file_perms create_file_perms setattr_file_perms }; logging_log_filetrans(rpm_t, rpm_log_t, file)
Signature · 1 line
2.21.0
Re: [PATCH 2/5] grant permission for rpm to write to audit log
Quoted 10 lines · David
Messages like this are added to the audit log when an rpm is installed:
type=SOFTWARE_UPDATE msg=audit(1560913896.581:244): pid=1265 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:rpm_t:s0 msg='sw="ntpdate-4.2.6p5-25.el7_3.2.x86_64" sw_type=rpm key_enforce=0 gpg_res=0 root_dir="/" comm="rpm" exe="/usr/bin/rpm" hostname=? addr=? terminal=? res=success'These are the denials that I'm seeing:
type=AVC msg=audit(1560913896.581:243): avc: denied {audit_write} for pid=1265 comm="rpm" capability=29 scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=capability permissive=1type=AVC msg=audit(1561298132.446:240): avc: denied { create } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1 type=AVC msg=audit(1561298132.446:241): avc: denied { write } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1 type=AVC msg=audit(1561298132.446:241): avc: denied { nlmsg_relay } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1 type=AVC msg=audit(1561298132.447:243): avc: denied { read } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1
There is an interface for that: logging_send_audit_msgs(rpm_t)
Quoted 30 lines
Signed-off-by Dave Sugar <[email protected]>--- policy/modules/admin/rpm.te | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)policy/modules/admin/rpm.te +2
-1@@ -73,7 +73,7 @@ files_tmpfs_file(rpm_script_tmpfs_t) # rpm Local policy # -allow rpm_t self:capability { chown dac_override fowner fsetid ipc_lock mknod setfcap setgid setuid sys_chroot sys_nice sys_tty_config }; +allow rpm_t self:capability { audit_write chown dac_override fowner fsetid ipc_lock mknod setfcap setgid setuid sys_chroot sys_nice sys_tty_config }; allow rpm_t self:process { transition signal_perms getsched setsched getsession getpgid setpgid getcap setcap share getattr setexec setfscreate noatsecure siginh setrlimit rlimitinh dyntransition execmem setkeycreate setsockcreate getrlimit }; allow rpm_t self:fd use; allow rpm_t self:fifo_file rw_fifo_file_perms;@@ -87,6 +87,7 @@ allow rpm_t self:msgq create_msgq_perms; allow rpm_t self:msg { send receive }; allow rpm_t self:file rw_file_perms; allow rpm_t self:netlink_kobject_uevent_socket create_socket_perms; +allow rpm_t self:netlink_audit_socket { nlmsg_relay create_socket_perms }; allow rpm_t rpm_log_t:file { append_file_perms create_file_perms setattr_file_perms }; logging_log_filetrans(rpm_t, rpm_log_t, file)Signature · 1 line
2.21.0
Signature · 3 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02 https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02 Dominick Grift
Re: [PATCH 2/5] grant permission for rpm to write to audit log
Quoted 7 lines · Dominick Grift
Quoted 6 lines · David
Messages like this are added to the audit log when an rpm is installed:
type=SOFTWARE_UPDATE msg=audit(1560913896.581:244): pid=1265 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:rpm_t:s0 msg='sw="ntpdate-4.2.6p5-25.el7_3.2.x86_64" sw_type=rpm key_enforce=0 gpg_res=0 root_dir="/" comm="rpm" exe="/usr/bin/rpm" hostname=? addr=? terminal=? res=success'These are the denials that I'm seeing:
type=AVC msg=audit(1560913896.581:243): avc: denied {audit_write} for pid=1265 comm="rpm" capability=29 scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=capability permissive=1
Quoted 7 lines
Quoted 4 lines
type=AVC msg=audit(1561298132.446:240): avc: denied { create } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1 type=AVC msg=audit(1561298132.446:241): avc: denied { write } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1 type=AVC msg=audit(1561298132.446:241): avc: denied { nlmsg_relay } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1 type=AVC msg=audit(1561298132.447:243): avc: denied { read } for pid=1266 comm="rpm" scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:system_r:rpm_t:s0 tclass=netlink_audit_socket permissive=1There is an interface for that:
logging_send_audit_msgs(rpm_t)
Good call, I missed that. I will submit an updated patch shortly.
Quoted 31 lines
Quoted 30 lines
Signed-off-by Dave Sugar <[email protected]>--- policy/modules/admin/rpm.te | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)policy/modules/admin/rpm.te +2
-1@@ -73,7 +73,7 @@ files_tmpfs_file(rpm_script_tmpfs_t) # rpm Local policy # -allow rpm_t self:capability { chown dac_override fowner fsetid ipc_lock mknod setfcap setgid setuid sys_chroot sys_nice sys_tty_config }; +allow rpm_t self:capability { audit_write chown dac_override fowner fsetid ipc_lock mknod setfcap setgid setuid sys_chroot sys_nice sys_tty_config }; allow rpm_t self:process { transition signal_perms getsched setsched getsession getpgid setpgid getcap setcap share getattr setexec setfscreate noatsecure siginh setrlimit rlimitinh dyntransition execmem setkeycreate setsockcreate getrlimit }; allow rpm_t self:fd use; allow rpm_t self:fifo_file rw_fifo_file_perms;@@ -87,6 +87,7 @@ allow rpm_t self:msgq create_msgq_perms; allow rpm_t self:msg { send receive }; allow rpm_t self:file rw_file_perms; allow rpm_t self:netlink_kobject_uevent_socket create_socket_perms; +allow rpm_t self:netlink_audit_socket { nlmsg_relay create_socket_perms }; allow rpm_t rpm_log_t:file { append_file_perms create_file_perms setattr_file_perms }; logging_log_filetrans(rpm_t, rpm_log_t, file)Signature · 1 line
2.21.0
PATCH 3/5 grant rpm permissions to map locale_t
In reply to Sugar, Davidtype=AVC msg=audit(1560913896.408:217): avc: denied { map } for pid=1265 comm="rpm" path="/usr/lib/locale/locale-archive" dev="dm-0" ino=24721 scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:object_r:locale_t:s0 tclass=file permissive=1
--- policy/modules/admin/rpm.te | 2 ++ 1 file changed, 2 insertions(+)
policy/modules/admin/rpm.te +2 -0
@@ -207,6 +207,8 @@ libs_run_ldconfig(rpm_t, rpm_roles) logging_send_syslog_msg(rpm_t) +miscfiles_read_localization(rpm_t) + seutil_manage_src_policy(rpm_t) seutil_manage_bin_policy(rpm_t)
Signature · 1 line
2.21.0
Re: [PATCH 3/5] grant rpm permissions to map locale_t
Quoted 12 lines · David
type=AVC msg=audit(1560913896.408:217): avc: denied { map } for pid=1265 comm="rpm" path="/usr/lib/locale/locale-archive" dev="dm-0" ino=24721 scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:object_r:locale_t:s0 tclass=file permissive=1
Signed-off-by Dave Sugar <[email protected]>--- policy/modules/admin/rpm.te | 2 ++ 1 file changed, 2 insertions(+)policy/modules/admin/rpm.te +0
-0
policy/modules/admin/rpm.te libs_run_ldconfig(rpm_t, rpm_roles) · line 213
Quoted 7 lines
policy/modules/admin/rpm.te +2
-0@@ -207,6 +207,8 @@ libs_run_ldconfig(rpm_t, rpm_roles) logging_send_syslog_msg(rpm_t) +miscfiles_read_localization(rpm_t) + seutil_manage_src_policy(rpm_t) seutil_manage_bin_policy(rpm_t)
Merged.
Signature · 1 line
Chris PeBenito
PATCH 4/5 Allow rpm to map file contexts
In reply to Sugar, Davidtype=AVC msg=audit(1560944465.365:270): avc: denied { map } for pid=1265 comm="rpm" path="/etc/selinux/clip/contexts/files/file_contexts.bin" dev="dm-0" ino=44911 scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:object_r:file_context_t:s0 tclass=file permissive=1
--- policy/modules/admin/rpm.te | 1 + 1 file changed, 1 insertion(+)
policy/modules/admin/rpm.te +1 -0
@@ -211,6 +211,7 @@ miscfiles_read_localization(rpm_t) seutil_manage_src_policy(rpm_t) seutil_manage_bin_policy(rpm_t) +seutil_read_file_contexts(rpm_t) userdom_use_user_terminals(rpm_t) userdom_use_unpriv_users_fds(rpm_t)
Signature · 1 line
2.21.0
Re: [PATCH 4/5] Allow rpm to map file contexts
Quoted 12 lines · David
type=AVC msg=audit(1560944465.365:270): avc: denied { map } for pid=1265 comm="rpm" path="/etc/selinux/clip/contexts/files/file_contexts.bin" dev="dm-0" ino=44911 scontext=system_u:system_r:rpm_t:s0 tcontext=system_u:object_r:file_context_t:s0 tclass=file permissive=1
Signed-off-by Dave Sugar <[email protected]>--- policy/modules/admin/rpm.te | 1 + 1 file changed, 1 insertion(+)policy/modules/admin/rpm.te +0
-0
policy/modules/admin/rpm.te miscfiles_read_localization(rpm_t) · line 217
Quoted 7 lines
policy/modules/admin/rpm.te +1
-0@@ -211,6 +211,7 @@ miscfiles_read_localization(rpm_t) seutil_manage_src_policy(rpm_t) seutil_manage_bin_policy(rpm_t) +seutil_read_file_contexts(rpm_t) userdom_use_user_terminals(rpm_t) userdom_use_unpriv_users_fds(rpm_t)
Merged.
Signature · 1 line
Chris PeBenito
PATCH 5/5 Allow rpm scripts to alter systemd services
In reply to Sugar, DavidIn RPM scripts it is common to enable/start services that are being installed. This allows rpm_script_t to manage sysemd units
type=USER_AVC msg=audit(1561033935.758:283): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: denied { enable } for auid=n/a uid=0 gid=0 path="/usr/lib/systemd/system/ntpdate.service" cmdline="systemctl preset ntpdate.service" scontext=system_u:system_r:rpm_script_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=service exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
type=USER_AVC msg=audit(1561033935.837:286): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: denied { enable } for auid=n/a uid=0 gid=0 path="/usr/lib/systemd/system/ntpd.service" cmdline="systemctl preset ntpd.service" scontext=system_u:system_r:rpm_script_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=service exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'type=USER_AVC msg=audit(1561059114.937:239): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: denied { reload } for auid=n/a uid=0 gid=0 cmdline="systemctl preset ntpdate.service" scontext=system_u:system_r:rpm_script_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=system exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
--- policy/modules/admin/rpm.te | 2 ++ 1 file changed, 2 insertions(+)
policy/modules/admin/rpm.te +2 -0
@@ -345,6 +345,8 @@ auth_dontaudit_getattr_shadow(rpm_script_t) auth_use_nsswitch(rpm_script_t) init_domtrans_script(rpm_script_t) +init_manage_all_units(rpm_script_t) +init_reload(rpm_script_t) init_telinit(rpm_script_t) libs_exec_ld_so(rpm_script_t)
Signature · 1 line
2.21.0
Re: [PATCH 5/5] Allow rpm scripts to alter systemd services
Quoted 18 lines · David
In RPM scripts it is common to enable/start services that are being installed. This allows
rpm_script_tto manage sysemd unitstype=USER_AVC msg=audit(1561033935.758:283): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: denied { enable } for auid=n/a uid=0 gid=0 path="/usr/lib/systemd/system/ntpdate.service" cmdline="systemctl preset ntpdate.service" scontext=system_u:system_r:rpm_script_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=service exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?' type=USER_AVC msg=audit(1561033935.837:286): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: denied { enable } for auid=n/a uid=0 gid=0 path="/usr/lib/systemd/system/ntpd.service" cmdline="systemctl preset ntpd.service" scontext=system_u:system_r:rpm_script_t:s0 tcontext=system_u:object_r:ntpd_unit_t:s0 tclass=service exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'type=USER_AVC msg=audit(1561059114.937:239): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 msg='avc: denied { reload } for auid=n/a uid=0 gid=0 cmdline="systemctl preset ntpdate.service" scontext=system_u:system_r:rpm_script_t:s0 tcontext=system_u:system_r:init_t:s0 tclass=system exe="/usr/lib/systemd/systemd" sauid=0 hostname=? addr=? terminal=?'
Signed-off-by Dave Sugar <[email protected]>--- policy/modules/admin/rpm.te | 2 ++ 1 file changed, 2 insertions(+)policy/modules/admin/rpm.te +0
-0
policy/modules/admin/rpm.te auth_dontaudit_getattr_shadow(rpm_script_t) · line 352
Quoted 8 lines
policy/modules/admin/rpm.te +2
-0@@ -345,6 +345,8 @@ auth_dontaudit_getattr_shadow(rpm_script_t) auth_use_nsswitch(rpm_script_t) init_domtrans_script(rpm_script_t) +init_manage_all_units(rpm_script_t) +init_reload(rpm_script_t) init_telinit(rpm_script_t) libs_exec_ld_so(rpm_script_t)
Merged.
Signature · 1 line
Chris PeBenito