diff mbox series

[v1,net] mctp: Use __mctp_dev_get() in mctp_fill_link_af().

Message ID 20240815204254.49813-1-kuniyu@amazon.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series [v1,net] mctp: Use __mctp_dev_get() in mctp_fill_link_af(). | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-08-16--00-00 (tests: 706)

Commit Message

Kuniyuki Iwashima Aug. 15, 2024, 8:42 p.m. UTC
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")
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 net/mctp/device.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jakub Kicinski Aug. 16, 2024, 1:39 a.m. UTC | #1
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.
Kuniyuki Iwashima Aug. 16, 2024, 3:08 a.m. UTC | #2
From: Jakub Kicinski <kuba@kernel.org>
Date: Thu, 15 Aug 2024 18:39:46 -0700
> 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.

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

Thanks!
diff mbox series

Patch

diff --git a/net/mctp/device.c b/net/mctp/device.c
index acb97b257428..7ffddab01e97 100644
--- a/net/mctp/device.c
+++ b/net/mctp/device.c
@@ -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))