audit: refactor audit_receive_msg() to clarify AUDIT_*_RULE* cases
authorRichard Guy Briggs <rgb@redhat.com>
Wed, 20 Nov 2013 19:01:53 +0000 (14:01 -0500)
committerEric Paris <eparis@redhat.com>
Tue, 14 Jan 2014 03:31:22 +0000 (22:31 -0500)
audit_receive_msg() needlessly contained a fallthrough case that called
audit_receive_filter(), containing no common code between the cases.  Separate
them to make the logic clearer.  Refactor AUDIT_LIST_RULES, AUDIT_ADD_RULE,
AUDIT_DEL_RULE cases to create audit_rule_change(), audit_list_rules_send()
functions.  This should not functionally change the logic.

Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Eric Paris <eparis@redhat.com>
include/linux/audit.h
kernel/audit.c
kernel/auditfilter.c

index 1690f95..6976219 100644 (file)
@@ -461,8 +461,10 @@ extern int             audit_update_lsm_rules(void);
                                /* Private API (for audit.c only) */
 extern int audit_filter_user(int type);
 extern int audit_filter_type(int type);
-extern int  audit_receive_filter(int type, __u32 portid, int seq,
+extern int audit_rule_change(int type, __u32 portid, int seq,
                                void *data, size_t datasz);
+extern int audit_list_rules_send(__u32 portid, int seq);
+
 extern int audit_enabled;
 #else /* CONFIG_AUDIT */
 static inline __printf(4, 5)
index fdb8528..c460f33 100644 (file)
@@ -903,11 +903,12 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
                        audit_log_end(ab);
                        return -EPERM;
                }
-               /* fallthrough */
-       case AUDIT_LIST_RULES:
-               err = audit_receive_filter(msg_type, NETLINK_CB(skb).portid,
+               err = audit_rule_change(msg_type, NETLINK_CB(skb).portid,
                                           seq, data, nlmsg_len(nlh));
                break;
+       case AUDIT_LIST_RULES:
+               err = audit_list_rules_send(NETLINK_CB(skb).portid, seq);
+               break;
        case AUDIT_TRIM:
                audit_trim_trees();
                audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE);
Simple merge