2019-07-02 15:31:05

by Sugar, David

[permalink] [raw]
Subject: [PATCH 2/5] grant permission for rpm to write to audit log

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

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

Signed-off-by: Dave Sugar <[email protected]>
---
policy/modules/admin/rpm.te | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/policy/modules/admin/rpm.te b/policy/modules/admin/rpm.te
index 0e6e9c03..a28a24d3 100644
--- a/policy/modules/admin/rpm.te
+++ b/policy/modules/admin/rpm.te
@@ -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)
--
2.21.0


2019-07-02 16:03:59

by Dac Override

[permalink] [raw]
Subject: Re: [PATCH 2/5] grant permission for rpm to write to audit log

On Tue, Jul 02, 2019 at 03:30:30PM +0000, Sugar, David wrote:
> 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
>
> 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

There is an interface for that: logging_send_audit_msgs(rpm_t)

>
> Signed-off-by: Dave Sugar <[email protected]>
> ---
> policy/modules/admin/rpm.te | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/policy/modules/admin/rpm.te b/policy/modules/admin/rpm.te
> index 0e6e9c03..a28a24d3 100644
> --- a/policy/modules/admin/rpm.te
> +++ b/policy/modules/admin/rpm.te
> @@ -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)
> --
> 2.21.0
>

--
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift


Attachments:
(No filename) (3.20 kB)
signature.asc (673.00 B)
Download all attachments

2019-07-02 17:40:44

by Sugar, David

[permalink] [raw]
Subject: Re: [PATCH 2/5] grant permission for rpm to write to audit log



On 7/2/19 12:03 PM, Dominick Grift wrote:
> On Tue, Jul 02, 2019 at 03:30:30PM +0000, Sugar, David wrote:
>> 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
>>
>> 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
>
> There is an interface for that: logging_send_audit_msgs(rpm_t)
>

Good call, I missed that. I will submit an updated patch shortly.

>>
>> Signed-off-by: Dave Sugar <[email protected]>
>> ---
>> policy/modules/admin/rpm.te | 3 ++-
>> 1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/policy/modules/admin/rpm.te b/policy/modules/admin/rpm.te
>> index 0e6e9c03..a28a24d3 100644
>> --- a/policy/modules/admin/rpm.te
>> +++ b/policy/modules/admin/rpm.te
>> @@ -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)
>> --
>> 2.21.0
>>
>