[RFC PATCH 1/4] audit: combine audit_receive() and audit_receive_skb()

Richard Guy Briggs rgb at redhat.com
Mon Apr 10 03:38:20 UTC 2017


On 2017-03-21 14:58, Paul Moore wrote:
> From: Paul Moore <paul at paul-moore.com>
> 
> There is no reason to have both of these functions, combine the two.
> 
> Signed-off-by: Paul Moore <paul at paul-moore.com>

Reviewed-by: Richard Guy Briggs <rgb at redhat.com>

> ---
>  kernel/audit.c |   19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/kernel/audit.c b/kernel/audit.c
> index 2f4964cfde0b..4037869b4b64 100644
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -1381,11 +1381,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;
>  	/*
> @@ -1398,6 +1401,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 */
> @@ -1406,13 +1410,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);
>  }
>  
> 
> --
> Linux-audit mailing list
> Linux-audit at redhat.com
> https://www.redhat.com/mailman/listinfo/linux-audit

- RGB

--
Richard Guy Briggs <rgb at redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635




More information about the Linux-audit mailing list