NetLabel audit fixup
Subsystems (5)
cover NetLabel audit fixup
This patch is against the current net-2.6 tree and should address the issues that Steve Grubb had with the original patch. Please consider this for the 2.6.19 release.
Dave - you may want to wait until Steve explicitly ACKs this ...
Steve - can you please explicitly ACK (or complain) about this patch ...
Thanks for your patience guys.
--
paul moore
linux security @ hp
PATCH 1/1 NetLabel: audit fixups due to delayed feedback
Fix some issues Steve Grubb had with the way NetLabel was using the audit subsystem. This should make NetLabel more consistent with other kernel generated audit messages specifying configuration changes.
--- include/linux/audit.h | 11 ++-- include/net/cipso_ipv4.h | 4 - include/net/netlabel.h | 8 +++ net/ipv4/cipso_ipv4.c | 4 - net/netlabel/netlabel_cipso_v4.c | 48 +++++++++++++-------- net/netlabel/netlabel_domainhash.c | 82 +++++++++++++++++++------------------ net/netlabel/netlabel_domainhash.h | 8 ++- net/netlabel/netlabel_mgmt.c | 27 ++++++++---- net/netlabel/netlabel_unlabeled.c | 34 ++++++++++----- net/netlabel/netlabel_user.c | 66 +++-------------------------- net/netlabel/netlabel_user.h | 16 ++++++- 11 files changed, 157 insertions(+), 151 deletions(-)
include/linux/audit.h +5 -6
@@ -95,12 +95,11 @@#define AUDIT_MAC_POLICY_LOAD 1403/* Policy file load */ #define AUDIT_MAC_STATUS 1404/* Changed enforcing,permissive,off */ #define AUDIT_MAC_CONFIG_CHANGE 1405/* Changes to booleans */ -#define AUDIT_MAC_UNLBL_ACCEPT 1406/* NetLabel: allow unlabeled traffic */ -#define AUDIT_MAC_UNLBL_DENY 1407/* NetLabel: deny unlabeled traffic */ -#define AUDIT_MAC_CIPSOV4_ADD 1408/* NetLabel: add CIPSOv4 DOI entry */ -#define AUDIT_MAC_CIPSOV4_DEL 1409/* NetLabel: del CIPSOv4 DOI entry */ -#define AUDIT_MAC_MAP_ADD 1410/* NetLabel: add LSM domain mapping */ -#define AUDIT_MAC_MAP_DEL 1411/* NetLabel: del LSM domain mapping */ +#define AUDIT_MAC_UNLBL_ALLOW 1406/* NetLabel: allow unlabeled traffic */ +#define AUDIT_MAC_CIPSOV4_ADD 1407/* NetLabel: add CIPSOv4 DOI entry */ +#define AUDIT_MAC_CIPSOV4_DEL 1408/* NetLabel: del CIPSOv4 DOI entry */ +#define AUDIT_MAC_MAP_ADD 1409/* NetLabel: add LSM domain mapping */ +#define AUDIT_MAC_MAP_DEL 1410/* NetLabel: del LSM domain mapping */ #define AUDIT_FIRST_KERN_ANOM_MSG 1700#define AUDIT_LAST_KERN_ANOM_MSG 1799
include/net/cipso_ipv4.h +2 -2
@@ -129,7 +129,7 @@ extern int cipso_v4_rbm_strictvalid;#ifdef CONFIG_NETLABEL int cipso_v4_doi_add (struct cipso_v4_doi *doi_def);int cipso_v4_doi_remove (u32 doi, -u32 audit_secid, +struct netlbl_audit *audit_info,void (*callback) (struct rcu_head * head));struct cipso_v4_doi *cipso_v4_doi_getdef (u32 doi); int cipso_v4_doi_walk(u32 *skip_cnt,
@@ -145,7 +145,7 @@ static inline int cipso_v4_doi_add(struc }static inline int cipso_v4_doi_remove (u32 doi, -u32 audit_secid, +struct netlbl_audit *audit_info,void (*callback) (struct rcu_head * head)) {return 0 ;
include/net/netlabel.h +7 -1
@@ -92,11 +92,17 @@* */ +/* NetLabel audit information */ +struct netlbl_audit { +u32 secid; +uid_t loginuid; +}; +/* Domain mapping definition struct */ struct netlbl_dom_map ;/* Domain mapping operations */ -int netlbl_domhsh_remove (const char *domain,u32 audit_secid); +int netlbl_domhsh_remove (const char *domain,struct netlbl_audit *audit_info);/* LSM security attributes */ struct netlbl_lsm_cache {
net/ipv4/cipso_ipv4.c +2 -2
@@ -485,7 +485,7 @@ doi_add_failure_rlock:* */ int cipso_v4_doi_remove (u32 doi, -u32 audit_secid, +struct netlbl_audit *audit_info,void (*callback) (struct rcu_head * head)) {struct cipso_v4_doi *doi_def;
@@ -506,7 +506,7 @@ int cipso_v4_doi_remove(u32 doi,list_for_each_entry_rcu (dom_iter, &doi_def->dom_list, list)if (dom_iter->valid)netlbl_domhsh_remove (dom_iter->domain, - audit_secid); + audit_info);cipso_v4_cache_invalidate ();rcu_read_unlock ();
net/netlabel/netlabel_cipso_v4.c +29 -19
73 lines not on this page · raw message
net/netlabel/netlabel_domainhash.c +43 -39
146 lines not on this page · raw message
net/netlabel/netlabel_domainhash.h +5 -3
@@ -57,9 +57,11 @@ struct netlbl_dom_map {int netlbl_domhsh_init (u32 size);/* Manipulate the domain hash table */ -int netlbl_domhsh_add (struct netlbl_dom_map *entry,u32 audit_secid); -int netlbl_domhsh_add_default (struct netlbl_dom_map *entry,u32 audit_secid); -int netlbl_domhsh_remove_default (u32 audit_secid); +int netlbl_domhsh_add (struct netlbl_dom_map *entry, +struct netlbl_audit *audit_info); +int netlbl_domhsh_add_default (struct netlbl_dom_map *entry, +struct netlbl_audit *audit_info); +int netlbl_domhsh_remove_default (struct netlbl_audit *audit_info);struct netlbl_dom_map *netlbl_domhsh_getentry (const char *domain); int netlbl_domhsh_walk(u32 *skip_bkt, u32 *skip_chain,
net/netlabel/netlabel_mgmt.c +19 -8
@@ -87,11 +87,14 @@ static int netlbl_mgmt_add(struct sk_bufstruct netlbl_dom_map *entry =NULL ;size_t tmp_size;u32 tmp_val; +struct netlbl_audit audit_info;if (!info->attrs[NLBL_MGMT_A_DOMAIN ] || !info->attrs[NLBL_MGMT_A_PROTOCOL ]) goto add_failure; +netlbl_netlink_auditinfo (skb, &audit_info); + entry =kzalloc (sizeof (*entry),GFP_KERNEL );if (entry ==NULL ) { ret_val = -ENOMEM ;
@@ -108,7 +111,7 @@ static int netlbl_mgmt_add(struct sk_bufswitch (entry->type) {case NETLBL_NLTYPE_UNLABELED : - ret_val =netlbl_domhsh_add (entry,NETLINK_CB (skb).sid); + ret_val =netlbl_domhsh_add (entry, &audit_info);break ;case NETLBL_NLTYPE_CIPSOV4 :if (!info->attrs[NLBL_MGMT_A_CV4DOI ])
@@ -125,7 +128,7 @@ static int netlbl_mgmt_add(struct sk_bufrcu_read_unlock (); goto add_failure; } - ret_val =netlbl_domhsh_add (entry,NETLINK_CB (skb).sid); + ret_val =netlbl_domhsh_add (entry, &audit_info);rcu_read_unlock ();break ;default :
@@ -156,12 +159,15 @@ add_failure:static int netlbl_mgmt_remove (struct sk_buff *skb,struct genl_info *info) {char *domain; +struct netlbl_audit audit_info;if (!info->attrs[NLBL_MGMT_A_DOMAIN ])return -EINVAL ; +netlbl_netlink_auditinfo (skb, &audit_info); + domain =nla_data (info->attrs[NLBL_MGMT_A_DOMAIN ]); -return netlbl_domhsh_remove (domain,NETLINK_CB (skb).sid); +return netlbl_domhsh_remove (domain, &audit_info); }/**
@@ -264,10 +270,13 @@ static int netlbl_mgmt_adddef(struct sk_int ret_val = -EINVAL ;struct netlbl_dom_map *entry =NULL ;u32 tmp_val; +struct netlbl_audit audit_info;if (!info->attrs[NLBL_MGMT_A_PROTOCOL ]) goto adddef_failure; +netlbl_netlink_auditinfo (skb, &audit_info); + entry =kzalloc (sizeof (*entry),GFP_KERNEL );if (entry ==NULL ) { ret_val = -ENOMEM ;
@@ -277,8 +286,7 @@ static int netlbl_mgmt_adddef(struct sk_switch (entry->type) {case NETLBL_NLTYPE_UNLABELED : - ret_val =netlbl_domhsh_add_default (entry, -NETLINK_CB (skb).sid); + ret_val =netlbl_domhsh_add_default (entry, &audit_info);break ;case NETLBL_NLTYPE_CIPSOV4 :if (!info->attrs[NLBL_MGMT_A_CV4DOI ])
@@ -295,8 +303,7 @@ static int netlbl_mgmt_adddef(struct sk_rcu_read_unlock (); goto adddef_failure; } - ret_val =netlbl_domhsh_add_default (entry, -NETLINK_CB (skb).sid); + ret_val =netlbl_domhsh_add_default (entry, &audit_info);rcu_read_unlock ();break ;default :
@@ -324,7 +331,11 @@ adddef_failure:*/ static int netlbl_mgmt_removedef (struct sk_buff *skb,struct genl_info *info) { -return netlbl_domhsh_remove_default (NETLINK_CB (skb).sid); +struct netlbl_audit audit_info; + +netlbl_netlink_auditinfo (skb, &audit_info); + +return netlbl_domhsh_remove_default (&audit_info); }/**
net/netlabel/netlabel_unlabeled.c +23 -11
@@ -70,18 +70,25 @@ static struct nla_policy netlbl_unlabel_/** * netlbl_unlabel_acceptflg_set - Set the unlabeled accept flag * @value: desired value -* @audit_secid: the LSM secid to use in the audit message +* @audit_info: NetLabel audit information * * Description: * Set the value of the unlabeled accept flag to @value. * */ -static void netlbl_unlabel_acceptflg_set (u8 value,u32 audit_secid) +static void netlbl_unlabel_acceptflg_set (u8 value, +struct netlbl_audit *audit_info) { +struct audit_buffer *audit_buf; +u8 old_val; + + old_val =atomic_read (&netlabel_unlabel_accept_flg);atomic_set (&netlabel_unlabel_accept_flg, value); -netlbl_audit_nomsg ((value ? -AUDIT_MAC_UNLBL_ACCEPT :AUDIT_MAC_UNLBL_DENY ), - audit_secid); + + audit_buf =netlbl_audit_start_common (AUDIT_MAC_UNLBL_ALLOW , + audit_info); +audit_log_format (audit_buf," unlbl_accept=%u old=%u" , value, old_val); +audit_log_end (audit_buf); }/*
@@ -101,12 +108,13 @@ static void netlbl_unlabel_acceptflg_setstatic int netlbl_unlabel_accept (struct sk_buff *skb,struct genl_info *info) {u8 value; +struct netlbl_audit audit_info;if (info->attrs[NLBL_UNLABEL_A_ACPTFLG ]) { value =nla_get_u8 (info->attrs[NLBL_UNLABEL_A_ACPTFLG ]);if (value ==1 || value ==0 ) { -netlbl_unlabel_acceptflg_set (value, -NETLINK_CB (skb).sid); +netlbl_netlink_auditinfo (skb, &audit_info); +netlbl_unlabel_acceptflg_set (value, &audit_info);return 0 ; } }
@@ -250,19 +258,23 @@ int netlbl_unlabel_defconf(void) {int ret_val;struct netlbl_dom_map *entry; -u32 secid; +struct netlbl_audit audit_info; -security_task_getsecid (current, &secid); +/* Only the kernel is allowed to call this function and the only time +* it is called is at bootup before the audit subsystem is reporting +* messages so don't worry to much about these values. */ +security_task_getsecid (current, &audit_info.secid); + audit_info.loginuid =0 ; entry =kzalloc (sizeof (*entry),GFP_KERNEL );if (entry ==NULL )return -ENOMEM ; entry->type =NETLBL_NLTYPE_UNLABELED ; - ret_val =netlbl_domhsh_add_default (entry, secid); + ret_val =netlbl_domhsh_add_default (entry, &audit_info);if (ret_val !=0 )return ret_val; -netlbl_unlabel_acceptflg_set (1 , secid); +netlbl_unlabel_acceptflg_set (1 , &audit_info);return 0 ; }
net/netlabel/netlabel_user.c +8 -58
89 lines not on this page · raw message
net/netlabel/netlabel_user.h +14 -2
@@ -72,13 +72,25 @@ static inline void *netlbl_netlink_hdr_p NETLBL_PROTO_VERSION); } +/** +* netlbl_netlink_auditinfo - Fetch the audit information from a NETLINK msg +* @skb: the packet +* @audit_info: NetLabel audit information +*/ +static inline void netlbl_netlink_auditinfo (struct sk_buff *skb, +struct netlbl_audit *audit_info) +{ + audit_info->secid =NETLINK_CB (skb).sid; + audit_info->loginuid =NETLINK_CB (skb).loginuid; +} +/* NetLabel NETLINK I/O functions */ int netlbl_netlink_init (void );/* NetLabel Audit Functions */ -struct audit_buffer *netlbl_audit_start_common (int type,u32 secid); -void netlbl_audit_nomsg (int type,u32 secid); +struct audit_buffer *netlbl_audit_start_common (int type, +struct netlbl_audit *audit_info);#endif
--
paul moore
linux security @ hp
Re: [PATCH 1/1] NetLabel: audit fixups due to delayed feedback
Quoted 2 lines · On Friday 29 September 2006 18:39, [email protected] wrote:
This should make NetLabel more consistent with other kernel generated audit messages specifying configuration changes.
OK, this looks better. We may fine tune the messages later after we try it
out, but all the issues I saw are fixed. ACK.
-Steve
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
David Miller
maintainerRe: [PATCH 1/1] NetLabel: audit fixups due to delayed feedback
From: Steve Grubb <[email protected]>
Date: Fri, 29 Sep 2006 20:00:42 -0400
Quoted 6 lines · On Friday 29 September 2006 18:39, [email protected] wrote:
Quoted 2 lines
This should make NetLabel more consistent with other kernel generated audit messages specifying configuration changes.
OK, this looks better. We may fine tune the messages later after we try it
out, but all the issues I saw are fixed. ACK.
Patch applied.