mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
synced 2025-01-01 10:42:11 +00:00
phonet: Don't hold RTNL for route_doit().
Now only __dev_get_by_index() depends on RTNL in route_doit(). Let's use dev_get_by_index_rcu() and register route_doit() with RTNL_FLAG_DOIT_UNLOCKED. Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com> Reviewed-by: Eric Dumazet <edumazet@google.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
This commit is contained in:
parent
3deec3b4af
commit
17a1ac0018
@ -245,8 +245,6 @@ static int route_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||||||
if (!netlink_capable(skb, CAP_SYS_ADMIN))
|
if (!netlink_capable(skb, CAP_SYS_ADMIN))
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
ASSERT_RTNL();
|
|
||||||
|
|
||||||
err = nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX,
|
err = nlmsg_parse_deprecated(nlh, sizeof(*rtm), tb, RTA_MAX,
|
||||||
rtm_phonet_policy, extack);
|
rtm_phonet_policy, extack);
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
@ -262,16 +260,25 @@ static int route_doit(struct sk_buff *skb, struct nlmsghdr *nlh,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ifindex = nla_get_u32(tb[RTA_OIF]);
|
ifindex = nla_get_u32(tb[RTA_OIF]);
|
||||||
dev = __dev_get_by_index(net, ifindex);
|
|
||||||
if (dev == NULL)
|
rcu_read_lock();
|
||||||
|
|
||||||
|
dev = dev_get_by_index_rcu(net, ifindex);
|
||||||
|
if (!dev) {
|
||||||
|
rcu_read_unlock();
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
if (nlh->nlmsg_type == RTM_NEWROUTE)
|
if (nlh->nlmsg_type == RTM_NEWROUTE)
|
||||||
err = phonet_route_add(dev, dst);
|
err = phonet_route_add(dev, dst);
|
||||||
else
|
else
|
||||||
err = phonet_route_del(dev, dst);
|
err = phonet_route_del(dev, dst);
|
||||||
|
|
||||||
|
rcu_read_unlock();
|
||||||
|
|
||||||
if (!err)
|
if (!err)
|
||||||
rtm_phonet_notify(net, nlh->nlmsg_type, ifindex, dst);
|
rtm_phonet_notify(net, nlh->nlmsg_type, ifindex, dst);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,9 +315,9 @@ static const struct rtnl_msg_handler phonet_rtnl_msg_handlers[] __initdata_or_mo
|
|||||||
{.owner = THIS_MODULE, .protocol = PF_PHONET, .msgtype = RTM_GETADDR,
|
{.owner = THIS_MODULE, .protocol = PF_PHONET, .msgtype = RTM_GETADDR,
|
||||||
.dumpit = getaddr_dumpit, .flags = RTNL_FLAG_DUMP_UNLOCKED},
|
.dumpit = getaddr_dumpit, .flags = RTNL_FLAG_DUMP_UNLOCKED},
|
||||||
{.owner = THIS_MODULE, .protocol = PF_PHONET, .msgtype = RTM_NEWROUTE,
|
{.owner = THIS_MODULE, .protocol = PF_PHONET, .msgtype = RTM_NEWROUTE,
|
||||||
.doit = route_doit},
|
.doit = route_doit, .flags = RTNL_FLAG_DOIT_UNLOCKED},
|
||||||
{.owner = THIS_MODULE, .protocol = PF_PHONET, .msgtype = RTM_DELROUTE,
|
{.owner = THIS_MODULE, .protocol = PF_PHONET, .msgtype = RTM_DELROUTE,
|
||||||
.doit = route_doit},
|
.doit = route_doit, .flags = RTNL_FLAG_DOIT_UNLOCKED},
|
||||||
{.owner = THIS_MODULE, .protocol = PF_PHONET, .msgtype = RTM_GETROUTE,
|
{.owner = THIS_MODULE, .protocol = PF_PHONET, .msgtype = RTM_GETROUTE,
|
||||||
.dumpit = route_dumpit, .flags = RTNL_FLAG_DUMP_UNLOCKED},
|
.dumpit = route_dumpit, .flags = RTNL_FLAG_DUMP_UNLOCKED},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user