Skip to content

Commit

Permalink
selinux: netlink: Move away from NLMSG_PUT().
Browse files Browse the repository at this point in the history
And use nlmsg_data() while we're here too.

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jun 27, 2012
1 parent b61bb01 commit 01f534d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions security/selinux/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include <linux/netlink.h>
#include <linux/selinux_netlink.h>
#include <net/net_namespace.h>
#include <net/netlink.h>

#include "security.h"

Expand Down Expand Up @@ -47,15 +48,15 @@ static void selnl_add_payload(struct nlmsghdr *nlh, int len, int msgtype, void *
{
switch (msgtype) {
case SELNL_MSG_SETENFORCE: {
struct selnl_msg_setenforce *msg = NLMSG_DATA(nlh);
struct selnl_msg_setenforce *msg = nlmsg_data(nlh);

memset(msg, 0, len);
msg->val = *((int *)data);
break;
}

case SELNL_MSG_POLICYLOAD: {
struct selnl_msg_policyload *msg = NLMSG_DATA(nlh);
struct selnl_msg_policyload *msg = nlmsg_data(nlh);

memset(msg, 0, len);
msg->seqno = *((u32 *)data);
Expand All @@ -81,15 +82,17 @@ static void selnl_notify(int msgtype, void *data)
goto oom;

tmp = skb->tail;
nlh = NLMSG_PUT(skb, 0, 0, msgtype, len);
nlh = nlmsg_put(skb, 0, 0, msgtype, len, 0);
if (!nlh)
goto out_kfree_skb;
selnl_add_payload(nlh, len, msgtype, data);
nlh->nlmsg_len = skb->tail - tmp;
NETLINK_CB(skb).dst_group = SELNLGRP_AVC;
netlink_broadcast(selnl, skb, 0, SELNLGRP_AVC, GFP_USER);
out:
return;

nlmsg_failure:
out_kfree_skb:
kfree_skb(skb);
oom:
printk(KERN_ERR "SELinux: OOM in %s\n", __func__);
Expand Down

0 comments on commit 01f534d

Please sign in to comment.