Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5c2bb9b6 authored by Florian Westphal's avatar Florian Westphal Committed by David S. Miller
Browse files

rtnetlink: do not use RTM_GETLINK directly



Userspace sends RTM_GETLINK type, but the kernel substracts
RTM_BASE from this, i.e. 'type' doesn't contain RTM_GETLINK
anymore but instead RTM_GETLINK - RTM_BASE.

This caused the calcit callback to not be invoked when it
should have been (and vice versa).

While at it, also fix a off-by one when checking family index. vs
handler array size.

Fixes: e1fa6d21 ("rtnetlink: call rtnl_calcit directly")
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 377cb248
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -4167,7 +4167,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,
	if (kind != 2 && !netlink_net_capable(skb, CAP_NET_ADMIN))
	if (kind != 2 && !netlink_net_capable(skb, CAP_NET_ADMIN))
		return -EPERM;
		return -EPERM;


	if (family > ARRAY_SIZE(rtnl_msg_handlers))
	if (family >= ARRAY_SIZE(rtnl_msg_handlers))
		family = PF_UNSPEC;
		family = PF_UNSPEC;


	rcu_read_lock();
	rcu_read_lock();
@@ -4196,7 +4196,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh,


		refcount_inc(&rtnl_msg_handlers_ref[family]);
		refcount_inc(&rtnl_msg_handlers_ref[family]);


		if (type == RTM_GETLINK)
		if (type == RTM_GETLINK - RTM_BASE)
			min_dump_alloc = rtnl_calcit(skb, nlh);
			min_dump_alloc = rtnl_calcit(skb, nlh);


		rcu_read_unlock();
		rcu_read_unlock();