Fix audit control message checks
Subsystems (4)
PATCH 1/1 Fix audit control message checks
The audit control messages are sent over netlink. Permission checks are done on the process receiving the message, which may not be the same as the process sending the message. This patch switches the netlink_send security hooks to calculate the effective capabilities based on the sender. Then audit_receive_msg performs capability checks based on that.
It also introduces the CAP_AUDIT_WRITE and CAP_AUDIT_CONTROL capabilities, and replaces the previous CAP_SYS_ADMIN checks in audit code with the appropriate checks.
Please apply.
Changelog:
1/15/2005: Simplified dummy_netlink_send given that dummy now
keeps track of capabilities.
1/14/2005: Many fixes based on feedback from [email protected]
list.
1/14/2005: Removed the netlink_msg_type helper function. 1/07/2005: Swith to using CAP_AUDIT_WRITE and CAP_AUDIT_CONTROL.
thanks,
-serge
include/linux/capability.h +4 -0
@@ -284,6 +284,10 @@ typedef __u32 kernel_cap_t;#define CAP_LEASE 28 +#define CAP_AUDIT_WRITE 29 + +#define CAP_AUDIT_CONTROL 30 +#ifdef __KERNEL__/* * Bounding set
kernel/audit.c +46 -7
92 lines not on this page · raw message
kernel/auditsc.c +0 -2
@@ -250,8 +250,6 @@ int audit_receive_filter(int type, int paudit_send_reply (pid, seq,AUDIT_LIST ,1 ,1 ,NULL ,0 );break ;case AUDIT_ADD : -if (!capable (CAP_SYS_ADMIN )) -return -EPERM ;if (!(entry =kmalloc (sizeof (*entry),GFP_KERNEL )))return -ENOMEM ;if (audit_copy_rule (&entry->rule, data)) {
security/dummy.c +1 -4
@@ -685,10 +685,7 @@ static int dummy_sem_semop (struct sem_astatic int dummy_netlink_send (struct sock *sk,struct sk_buff *skb) { -if (current->euid ==0 ) -cap_raise (NETLINK_CB (skb).eff_cap,CAP_NET_ADMIN ); -else -NETLINK_CB (skb).eff_cap =0 ; +NETLINK_CB (skb).eff_cap = current->cap_effective;return 0 ; }
security/selinux/hooks.c +13 -5
@@ -3502,12 +3502,20 @@ static inline int selinux_nlmsg_perm(strstatic int selinux_netlink_send (struct sock *sk,struct sk_buff *skb) { -int err =0 ; +struct task_security_struct *tsec; +struct av_decision avd; +int err; -if (capable (CAP_NET_ADMIN )) -cap_raise (NETLINK_CB (skb).eff_cap,CAP_NET_ADMIN ); -else -NETLINK_CB (skb).eff_cap =0 ; + err = secondary_ops->netlink_send (sk, skb); +if (err) +return err; + + tsec = current->security; + + avd.allowed =0 ; + (void )avc_has_perm_noaudit (tsec->sid, tsec->sid, +SECCLASS_CAPABILITY , ~0 , &avd); +cap_mask (NETLINK_CB (skb).eff_cap, avd.allowed);if (policydb_loaded_version >=POLICYDB_VERSION_NLCLASS ) err =selinux_nlmsg_perm (sk, skb);
Quoted 21 lines · Serge E. Hallyn
The audit control messages are sent over netlink. Permission checks are done on the process receiving the message, which may not be the same as the process sending the message. This patch switches the
netlink_sendsecurity hooks to calculate the effective capabilities based on the sender. Thenaudit_receive_msgperforms capability checks based on that.It also introduces the
CAP_AUDIT_WRITEandCAP_AUDIT_CONTROLcapabilities, and replaces the previousCAP_SYS_ADMINchecks in audit code with the appropriate checks.Please apply.
Changelog:
1/15/2005: Simplifieddummy_netlink_sendgiven that dummy now
keeps track of capabilities.
1/14/2005: Many fixes based on feedback from [email protected]
list.
1/14/2005: Removed thenetlink_msg_typehelper function. 1/07/2005: Swith to usingCAP_AUDIT_WRITEandCAP_AUDIT_CONTROL.
Quoted 4 lines
thanks,
-sergeSigned-off-by Serge Hallyn <[email protected]>
Signature · 2 lines
Stephen Smalley <[email protected]> National Security Agency
Quoted 22 lines · * Stephen Smalley ([email protected]) wrote:
Quoted 21 lines · Serge E. Hallyn
The audit control messages are sent over netlink. Permission checks are done on the process receiving the message, which may not be the same as the process sending the message. This patch switches the
netlink_sendsecurity hooks to calculate the effective capabilities based on the sender. Thenaudit_receive_msgperforms capability checks based on that.It also introduces the
CAP_AUDIT_WRITEandCAP_AUDIT_CONTROLcapabilities, and replaces the previousCAP_SYS_ADMINchecks in audit code with the appropriate checks.Please apply.
Changelog:
1/15/2005: Simplifieddummy_netlink_sendgiven that dummy now
keeps track of capabilities.
1/14/2005: Many fixes based on feedback from [email protected]
list.
1/14/2005: Removed thenetlink_msg_typehelper function. 1/07/2005: Swith to usingCAP_AUDIT_WRITEandCAP_AUDIT_CONTROL.
Quoted 6 lines
Quoted 4 lines
thanks,
-sergeSigned-off-by Serge Hallyn <[email protected]>Signed-off-by Stephen Smalley <[email protected]>
thanks,
-chris
Signature · 1 line
Linux Security Modules http://lsm.immunix.org http://lsm.bkbits.net