Commit 01f534d0 authored by David S. Miller's avatar David S. Miller

selinux: netlink: Move away from NLMSG_PUT().

And use nlmsg_data() while we're here too.
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b61bb019
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/selinux_netlink.h> #include <linux/selinux_netlink.h>
#include <net/net_namespace.h> #include <net/net_namespace.h>
#include <net/netlink.h>
#include "security.h" #include "security.h"
...@@ -47,7 +48,7 @@ static void selnl_add_payload(struct nlmsghdr *nlh, int len, int msgtype, void * ...@@ -47,7 +48,7 @@ static void selnl_add_payload(struct nlmsghdr *nlh, int len, int msgtype, void *
{ {
switch (msgtype) { switch (msgtype) {
case SELNL_MSG_SETENFORCE: { case SELNL_MSG_SETENFORCE: {
struct selnl_msg_setenforce *msg = NLMSG_DATA(nlh); struct selnl_msg_setenforce *msg = nlmsg_data(nlh);
memset(msg, 0, len); memset(msg, 0, len);
msg->val = *((int *)data); msg->val = *((int *)data);
...@@ -55,7 +56,7 @@ static void selnl_add_payload(struct nlmsghdr *nlh, int len, int msgtype, void * ...@@ -55,7 +56,7 @@ static void selnl_add_payload(struct nlmsghdr *nlh, int len, int msgtype, void *
} }
case SELNL_MSG_POLICYLOAD: { case SELNL_MSG_POLICYLOAD: {
struct selnl_msg_policyload *msg = NLMSG_DATA(nlh); struct selnl_msg_policyload *msg = nlmsg_data(nlh);
memset(msg, 0, len); memset(msg, 0, len);
msg->seqno = *((u32 *)data); msg->seqno = *((u32 *)data);
...@@ -81,7 +82,9 @@ static void selnl_notify(int msgtype, void *data) ...@@ -81,7 +82,9 @@ static void selnl_notify(int msgtype, void *data)
goto oom; goto oom;
tmp = skb->tail; 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); selnl_add_payload(nlh, len, msgtype, data);
nlh->nlmsg_len = skb->tail - tmp; nlh->nlmsg_len = skb->tail - tmp;
NETLINK_CB(skb).dst_group = SELNLGRP_AVC; NETLINK_CB(skb).dst_group = SELNLGRP_AVC;
...@@ -89,7 +92,7 @@ static void selnl_notify(int msgtype, void *data) ...@@ -89,7 +92,7 @@ static void selnl_notify(int msgtype, void *data)
out: out:
return; return;
nlmsg_failure: out_kfree_skb:
kfree_skb(skb); kfree_skb(skb);
oom: oom:
printk(KERN_ERR "SELinux: OOM in %s\n", __func__); printk(KERN_ERR "SELinux: OOM in %s\n", __func__);
......
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