Skip to contentSkip to conversation

mctp: Use __mctp_dev_get() in mctp_fill_link_af().

PATCH In review Kuniyuki Iwashima 2 participants 3 messages Aug 15, 2024 – Aug 16, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mctp: Use __mctp_dev_get() in mctp_fill_link_af().

Since commit 5fa85a09390c ("net: core: rcu-ify rtnl af_ops"), af_ops->fill_link_af() is called under RCU.

mctp_fill_link_af() calls mctp_dev_get_rtnl() that uses rtnl_dereference(), so lockdep should complain about it.

Let's use __mctp_dev_get() instead.

Fixes 583be982d934 ("mctp: Add device handling and netlink interface")
---
 net/mctp/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/mctp/device.c +1 -1
index acb97b257428..7ffddab01e97 100644
@@ -366,7 +366,7 @@ static int mctp_fill_link_af(struct sk_buff *skb,
 {
 	struct mctp_dev *mdev;
 
-	mdev = mctp_dev_get_rtnl(dev);
+	mdev = __mctp_dev_get(dev);
 	if (!mdev)
 		return -ENODATA;
 	if (nla_put_u32(skb, IFLA_MCTP_NET, mdev->net))
Signature · 1 line
2.30.2
maintainer
#1 lore raw
Quoted 7 lines · On Thu, 15 Aug 2024 13:42:54 -0700 Kuniyuki Iwashima wrote:

Since commit 5fa85a09390c ("net: core: rcu-ify rtnl af_ops"), af_ops->fill_link_af() is called under RCU.

mctp_fill_link_af() calls mctp_dev_get_rtnl() that uses rtnl_dereference(), so lockdep should complain about it.

Let's use __mctp_dev_get() instead.

And this is what crashes kunit tests, I reckon.

Signature · 1 line
pw-bot: cr
#2 lore raw

From: Jakub Kicinski <[email protected]>
Date: Thu, 15 Aug 2024 18:39:46 -0700

Quoted 10 lines · On Thu, 15 Aug 2024 13:42:54 -0700 Kuniyuki Iwashima wrote:
Quoted 7 lines

Since commit 5fa85a09390c ("net: core: rcu-ify rtnl af_ops"), af_ops->fill_link_af() is called under RCU.

mctp_fill_link_af() calls mctp_dev_get_rtnl() that uses rtnl_dereference(), so lockdep should complain about it.

Let's use __mctp_dev_get() instead.

And this is what crashes kunit tests, I reckon.

Exactly, I missed that the helper increments the dev refcnt. I'll use bare rcu_dereference().

Thanks!