rtnetlink: make sure to refresh master_dev/m_ops in __rtnl_newlink()
Subsystems (2)
PATCH 1/1 rtnetlink: make sure to refresh master_dev/m_ops in __rtnl_newlink()
From: Eric Dumazet <[email protected]>
While looking at one unrelated syzbot bug, I found the replay logic in __rtnl_newlink() to potentially trigger use-after-free.
It is better to clear master_dev and m_ops inside the loop, in case we have to replay it.
--- net/core/rtnetlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
net/core/rtnetlink.c +4 -2
@@ -3275,8 +3275,8 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,struct nlattr *slave_attr[RTNL_SLAVE_MAX_TYPE +1 ];unsigned char name_assign_type =NET_NAME_USER ;struct nlattr *linkinfo[IFLA_INFO_MAX +1 ]; -const struct rtnl_link_ops *m_ops =NULL ; -struct net_device *master_dev =NULL ; +const struct rtnl_link_ops *m_ops; +struct net_device *master_dev;struct net *net =sock_net (skb->sk);const struct rtnl_link_ops *ops;struct nlattr *tb[IFLA_MAX +1 ];
@@ -3314,6 +3314,8 @@ static int __rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh,else dev =NULL ; + master_dev =NULL ; + m_ops =NULL ;if (dev) { master_dev =netdev_master_upper_dev_get (dev);if (master_dev)
Signature · 1 line
2.35.0.rc2.247.g8bbb082509-goog
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 31 Jan 2022 17:21:06 -0800 you wrote:
From: Eric Dumazet <[email protected]>
While looking at one unrelated syzbot bug, I found the replay logic in
__rtnl_newlink()to potentially trigger use-after-free.It is better to clear
master_devandm_opsinside the loop, in case we have to replay it.[...]
Here is the summary with links:
- [net] rtnetlink: make sure to refresh master_dev/m_ops in __rtnl_newlink()
https://git.kernel.org/netdev/net/c/c6f6f2444bdb
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html