Commit ee080e6c authored by Eric Paris's avatar Eric Paris Committed by Al Viro

Audit: cleanup netlink mesg handling

The audit handling of netlink messages is all over the place.  Clean things
up, use predetermined macros, generally make it more readable.
Signed-off-by: default avatarEric Paris <eparis@redhat.com>
parent 038cbcf6
...@@ -528,22 +528,20 @@ struct sk_buff *audit_make_reply(int pid, int seq, int type, int done, ...@@ -528,22 +528,20 @@ struct sk_buff *audit_make_reply(int pid, int seq, int type, int done,
{ {
struct sk_buff *skb; struct sk_buff *skb;
struct nlmsghdr *nlh; struct nlmsghdr *nlh;
int len = NLMSG_SPACE(size);
void *data; void *data;
int flags = multi ? NLM_F_MULTI : 0; int flags = multi ? NLM_F_MULTI : 0;
int t = done ? NLMSG_DONE : type; int t = done ? NLMSG_DONE : type;
skb = alloc_skb(len, GFP_KERNEL); skb = nlmsg_new(size, GFP_KERNEL);
if (!skb) if (!skb)
return NULL; return NULL;
nlh = NLMSG_PUT(skb, pid, seq, t, size); nlh = NLMSG_NEW(skb, pid, seq, t, size, flags);
nlh->nlmsg_flags = flags; data = NLMSG_DATA(nlh);
data = NLMSG_DATA(nlh);
memcpy(data, payload, size); memcpy(data, payload, size);
return skb; return skb;
nlmsg_failure: /* Used by NLMSG_PUT */ nlmsg_failure: /* Used by NLMSG_NEW */
if (skb) if (skb)
kfree_skb(skb); kfree_skb(skb);
return NULL; return NULL;
...@@ -1083,18 +1081,20 @@ static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx, ...@@ -1083,18 +1081,20 @@ static struct audit_buffer * audit_buffer_alloc(struct audit_context *ctx,
goto err; goto err;
} }
ab->skb = alloc_skb(AUDIT_BUFSIZ, gfp_mask);
if (!ab->skb)
goto err;
ab->ctx = ctx; ab->ctx = ctx;
ab->gfp_mask = gfp_mask; ab->gfp_mask = gfp_mask;
nlh = (struct nlmsghdr *)skb_put(ab->skb, NLMSG_SPACE(0));
nlh->nlmsg_type = type; ab->skb = nlmsg_new(AUDIT_BUFSIZ, gfp_mask);
nlh->nlmsg_flags = 0; if (!ab->skb)
nlh->nlmsg_pid = 0; goto nlmsg_failure;
nlh->nlmsg_seq = 0;
nlh = NLMSG_NEW(ab->skb, 0, 0, type, 0, 0);
return ab; return ab;
nlmsg_failure: /* Used by NLMSG_NEW */
kfree_skb(ab->skb);
ab->skb = NULL;
err: err:
audit_buffer_free(ab); audit_buffer_free(ab);
return NULL; return NULL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment