Skip to content

Commit

Permalink
audit: combine audit_receive() and audit_receive_skb()
Browse files Browse the repository at this point in the history
There is no reason to have both of these functions, combine the two.

Signed-off-by: Paul Moore <paul@paul-moore.com>
Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
  • Loading branch information
Paul Moore committed May 2, 2017
1 parent bd120de commit a9d1620
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions kernel/audit.c
Original file line number Diff line number Diff line change
Expand Up @@ -1378,11 +1378,14 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
return err < 0 ? err : 0;
}

/*
* Get message from skb. Each message is processed by audit_receive_msg.
* Malformed skbs with wrong length are discarded silently.
/**
* audit_receive - receive messages from a netlink control socket
* @skb: the message buffer
*
* Parse the provided skb and deal with any messages that may be present,
* malformed skbs are discarded.
*/
static void audit_receive_skb(struct sk_buff *skb)
static void audit_receive(struct sk_buff *skb)
{
struct nlmsghdr *nlh;
/*
Expand All @@ -1395,6 +1398,7 @@ static void audit_receive_skb(struct sk_buff *skb)
nlh = nlmsg_hdr(skb);
len = skb->len;

mutex_lock(&audit_cmd_mutex);
while (nlmsg_ok(nlh, len)) {
err = audit_receive_msg(skb, nlh);
/* if err or if this message says it wants a response */
Expand All @@ -1403,13 +1407,6 @@ static void audit_receive_skb(struct sk_buff *skb)

nlh = nlmsg_next(nlh, &len);
}
}

/* Receive messages from netlink socket. */
static void audit_receive(struct sk_buff *skb)
{
mutex_lock(&audit_cmd_mutex);
audit_receive_skb(skb);
mutex_unlock(&audit_cmd_mutex);
}

Expand Down

0 comments on commit a9d1620

Please sign in to comment.