Re: [syzbot] Re: [syzbot] [net?] possible deadlock in rtnl_lock (8)

From: syzbot
Date: Wed Sep 11 2024 - 05:48:17 EST


For archival purposes, forwarding an incoming command email to
linux-kernel@xxxxxxxxxxxxxxx, syzkaller-bugs@xxxxxxxxxxxxxxxx.

***

Subject: Re: [syzbot] [net?] possible deadlock in rtnl_lock (8)
Author: alibuda@xxxxxxxxxxxxxxxxx

#syz test

Make Lockdep happy with IPPROTO_SMC

---
 net/smc/smc_inet.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/net/smc/smc_inet.c b/net/smc/smc_inet.c
index bece346..281f0450 100644
--- a/net/smc/smc_inet.c
+++ b/net/smc/smc_inet.c
@@ -102,14 +102,29 @@
 };
 #endif /* CONFIG_IPV6 */

+static struct lock_class_key smc_clcsk_slock_keys[2];
+static struct lock_class_key smc_clcsk_keys[2];
+
 static int smc_inet_init_sock(struct sock *sk)
 {
+   bool is_ipv6 = sk->sk_family == AF_INET6;
    struct net *net = sock_net(sk);
+   int rc;

    /* init common smc sock */
    smc_sk_init(net, sk, IPPROTO_SMC);
    /* create clcsock */
-   return smc_create_clcsk(net, sk, sk->sk_family);
+   rc = smc_create_clcsk(net, sk, sk->sk_family);
+   if (rc)
+       return rc;
+
+   sock_lock_init_class_and_name(smc_sk(sk)->clcsk,
+                     is_ipv6 ? "slock-AF_INET6-SMC-CLCSK" :
"slock-AF_INET-SMC-CLCSK",
+                     &smc_clcsk_slock_keys[is_ipv6],
+                     is_ipv6 ? "sk_lock-AF_INET6-SMC-CLCSK" :
"sk_lock-AF_INET-SMC-CLCSK",
+                     &smc_clcsk_keys[is_ipv6]);
+
+   return 0;
 }

 int __init smc_inet_init(void)
--
1.8.3.1