Commit 9ed19f33 authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by David S. Miller

[NETLINK]: Set correct pid for ioctl originating netlink events

This patch ensures that netlink events created as a result of programns
using ioctls (such as ifconfig, route etc) contains the correct PID of
those events.
Signed-off-by: default avatarJamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e431b8c0
...@@ -452,7 +452,7 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change) ...@@ -452,7 +452,7 @@ void rtmsg_ifinfo(int type, struct net_device *dev, unsigned change)
if (!skb) if (!skb)
return; return;
if (rtnetlink_fill_ifinfo(skb, dev, type, 0, 0, change, 0) < 0) { if (rtnetlink_fill_ifinfo(skb, dev, type, current->pid, 0, change, 0) < 0) {
kfree_skb(skb); kfree_skb(skb);
return; return;
} }
......
...@@ -1112,7 +1112,7 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa) ...@@ -1112,7 +1112,7 @@ static void rtmsg_ifa(int event, struct in_ifaddr* ifa)
if (!skb) if (!skb)
netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, ENOBUFS); netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, ENOBUFS);
else if (inet_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) { else if (inet_fill_ifaddr(skb, ifa, current->pid, 0, event, 0) < 0) {
kfree_skb(skb); kfree_skb(skb);
netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, EINVAL); netlink_set_err(rtnl, 0, RTMGRP_IPV4_IFADDR, EINVAL);
} else { } else {
......
...@@ -276,7 +276,7 @@ void rtmsg_fib(int event, u32 key, struct fib_alias *fa, ...@@ -276,7 +276,7 @@ void rtmsg_fib(int event, u32 key, struct fib_alias *fa,
struct nlmsghdr *n, struct netlink_skb_parms *req) struct nlmsghdr *n, struct netlink_skb_parms *req)
{ {
struct sk_buff *skb; struct sk_buff *skb;
u32 pid = req ? req->pid : 0; u32 pid = req ? req->pid : n->nlmsg_pid;
int size = NLMSG_SPACE(sizeof(struct rtmsg)+256); int size = NLMSG_SPACE(sizeof(struct rtmsg)+256);
skb = alloc_skb(size, GFP_KERNEL); skb = alloc_skb(size, GFP_KERNEL);
...@@ -1035,7 +1035,7 @@ fib_convert_rtentry(int cmd, struct nlmsghdr *nl, struct rtmsg *rtm, ...@@ -1035,7 +1035,7 @@ fib_convert_rtentry(int cmd, struct nlmsghdr *nl, struct rtmsg *rtm,
} }
nl->nlmsg_flags = NLM_F_REQUEST; nl->nlmsg_flags = NLM_F_REQUEST;
nl->nlmsg_pid = 0; nl->nlmsg_pid = current->pid;
nl->nlmsg_seq = 0; nl->nlmsg_seq = 0;
nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm)); nl->nlmsg_len = NLMSG_LENGTH(sizeof(*rtm));
if (cmd == SIOCDELRT) { if (cmd == SIOCDELRT) {
......
...@@ -2873,7 +2873,7 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa) ...@@ -2873,7 +2873,7 @@ static void inet6_ifa_notify(int event, struct inet6_ifaddr *ifa)
netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, ENOBUFS); netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, ENOBUFS);
return; return;
} }
if (inet6_fill_ifaddr(skb, ifa, 0, 0, event, 0) < 0) { if (inet6_fill_ifaddr(skb, ifa, current->pid, 0, event, 0) < 0) {
kfree_skb(skb); kfree_skb(skb);
netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, EINVAL); netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFADDR, EINVAL);
return; return;
...@@ -3008,7 +3008,7 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev) ...@@ -3008,7 +3008,7 @@ void inet6_ifinfo_notify(int event, struct inet6_dev *idev)
netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, ENOBUFS); netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, ENOBUFS);
return; return;
} }
if (inet6_fill_ifinfo(skb, idev, 0, 0, event, 0) < 0) { if (inet6_fill_ifinfo(skb, idev, current->pid, 0, event, 0) < 0) {
kfree_skb(skb); kfree_skb(skb);
netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, EINVAL); netlink_set_err(rtnl, 0, RTMGRP_IPV6_IFINFO, EINVAL);
return; return;
...@@ -3065,7 +3065,7 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev, ...@@ -3065,7 +3065,7 @@ static void inet6_prefix_notify(int event, struct inet6_dev *idev,
netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, ENOBUFS); netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, ENOBUFS);
return; return;
} }
if (inet6_fill_prefix(skb, idev, pinfo, 0, 0, event, 0) < 0) { if (inet6_fill_prefix(skb, idev, pinfo, current->pid, 0, event, 0) < 0) {
kfree_skb(skb); kfree_skb(skb);
netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, EINVAL); netlink_set_err(rtnl, 0, RTMGRP_IPV6_PREFIX, EINVAL);
return; return;
......
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