mirror of
https://github.com/LineageOS/android_kernel_fxtec_sm6115.git
synced 2026-08-18 12:41:04 +00:00
phonet: Pass net and ifindex to phonet_address_notify().
[ Upstream commit 68ed5c38b512b734caf3da1f87db4a99fcfe3002 ] Currently, phonet_address_notify() fetches netns and ifindex from dev. Once addr_doit() is converted to RCU, phonet_address_notify() will be called outside of RCU due to GFP_KERNEL, and dev will be unavailable there. Let's pass net and ifindex to phonet_address_notify(). Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com> Stable-dep-of: 71de0177b28d ("net: phonet: free phonet_device after RCU grace period") Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Ulrich Hecht <uli@kernel.org>
This commit is contained in:
committed by
Ulrich Hecht
parent
151232b887
commit
bdbfd3ba48
@ -46,7 +46,7 @@ int phonet_address_add(struct net_device *dev, u8 addr);
|
||||
int phonet_address_del(struct net_device *dev, u8 addr);
|
||||
u8 phonet_address_get(struct net_device *dev, u8 addr);
|
||||
int phonet_address_lookup(struct net *net, u8 addr);
|
||||
void phonet_address_notify(int event, struct net_device *dev, u8 addr);
|
||||
void phonet_address_notify(struct net *net, int event, u32 ifindex, u8 addr);
|
||||
|
||||
int phonet_route_add(struct net_device *dev, u8 daddr);
|
||||
int phonet_route_del(struct net_device *dev, u8 daddr);
|
||||
|
||||
@ -113,10 +113,13 @@ static void phonet_device_destroy(struct net_device *dev)
|
||||
mutex_unlock(&pndevs->lock);
|
||||
|
||||
if (pnd) {
|
||||
struct net *net = dev_net(dev);
|
||||
u32 ifindex = dev->ifindex;
|
||||
u8 addr;
|
||||
|
||||
for_each_set_bit(addr, pnd->addrs, 64)
|
||||
phonet_address_notify(RTM_DELADDR, dev, addr);
|
||||
phonet_address_notify(net, RTM_DELADDR, ifindex, addr);
|
||||
|
||||
kfree(pnd);
|
||||
}
|
||||
}
|
||||
@ -260,8 +263,9 @@ static int phonet_device_autoconf(struct net_device *dev)
|
||||
ret = phonet_address_add(dev, req.ifr_phonet_autoconf.device);
|
||||
if (ret)
|
||||
return ret;
|
||||
phonet_address_notify(RTM_NEWADDR, dev,
|
||||
req.ifr_phonet_autoconf.device);
|
||||
|
||||
phonet_address_notify(dev_net(dev), RTM_NEWADDR, dev->ifindex,
|
||||
req.ifr_phonet_autoconf.device);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@
|
||||
static int fill_addr(struct sk_buff *skb, u32 ifindex, u8 addr,
|
||||
u32 portid, u32 seq, int event);
|
||||
|
||||
void phonet_address_notify(int event, struct net_device *dev, u8 addr)
|
||||
void phonet_address_notify(struct net *net, int event, u32 ifindex, u8 addr)
|
||||
{
|
||||
struct sk_buff *skb;
|
||||
int err = -ENOBUFS;
|
||||
@ -45,17 +45,17 @@ void phonet_address_notify(int event, struct net_device *dev, u8 addr)
|
||||
if (skb == NULL)
|
||||
goto errout;
|
||||
|
||||
err = fill_addr(skb, dev->ifindex, addr, 0, 0, event);
|
||||
err = fill_addr(skb, ifindex, addr, 0, 0, event);
|
||||
if (err < 0) {
|
||||
WARN_ON(err == -EMSGSIZE);
|
||||
kfree_skb(skb);
|
||||
goto errout;
|
||||
}
|
||||
rtnl_notify(skb, dev_net(dev), 0,
|
||||
RTNLGRP_PHONET_IFADDR, NULL, GFP_KERNEL);
|
||||
|
||||
rtnl_notify(skb, net, 0, RTNLGRP_PHONET_IFADDR, NULL, GFP_KERNEL);
|
||||
return;
|
||||
errout:
|
||||
rtnl_set_sk_err(dev_net(dev), RTNLGRP_PHONET_IFADDR, err);
|
||||
rtnl_set_sk_err(net, RTNLGRP_PHONET_IFADDR, err);
|
||||
}
|
||||
|
||||
static const struct nla_policy ifa_phonet_policy[IFA_MAX+1] = {
|
||||
@ -102,7 +102,7 @@ static int addr_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
|
||||
else
|
||||
err = phonet_address_del(dev, pnaddr);
|
||||
if (!err)
|
||||
phonet_address_notify(nlh->nlmsg_type, dev, pnaddr);
|
||||
phonet_address_notify(net, nlh->nlmsg_type, ifm->ifa_index, pnaddr);
|
||||
return err;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user