* [PATCH v3 0/2] resolve gtp possible deadlock warning
@ 2024-10-14 7:30 Daniel Yang
2024-10-14 7:30 ` [PATCH v3 1/2] Patch from Daniel Yang
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Daniel Yang @ 2024-10-14 7:30 UTC (permalink / raw)
To: Wenjia Zhang, Jan Karcher, D. Wythe, Tony Lu, Wen Gu,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-s390, netdev, linux-kernel
Cc: danielyangkang
Fixes deadlock described in this bug:
https://syzkaller.appspot.com/bug?extid=e953a8f3071f5c0a28fd.
Specific crash report here:
https://syzkaller.appspot.com/text?tag=CrashReport&x=14670e07980000.
This bug is a false positive lockdep warning since gtp and smc use
completely different socket protocols.
Lockdep thinks that lock_sock() in smc will deadlock with gtp's
lock_sock() acquisition.
Adding lockdep annotations on smc socket creation prevents these false
positives.
Daniel Yang (2):
Patch from D. Wythe <alibuda@linux.alibaba.com>
Move lockdep annotation to separate function for readability.
net/smc/smc_inet.c | 29 ++++++++++++++++++++++++++++-
1 file changed, 28 insertions(+), 1 deletion(-)
--
2.39.2
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3 1/2] Patch from
2024-10-14 7:30 [PATCH v3 0/2] resolve gtp possible deadlock warning Daniel Yang
@ 2024-10-14 7:30 ` Daniel Yang
2024-10-14 7:30 ` [PATCH v3 2/2] Move lockdep annotation to separate function for readability Daniel Yang
2024-10-15 17:54 ` [PATCH v3 0/2] resolve gtp possible deadlock warning Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Yang @ 2024-10-14 7:30 UTC (permalink / raw)
To: Wenjia Zhang, Jan Karcher, D. Wythe, Tony Lu, Wen Gu,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-s390, netdev, linux-kernel
Cc: danielyangkang, syzbot+e953a8f3071f5c0a28fd
From: D. Wythe <alibuda@linux.alibaba.com>
Adds lockdep annotations on smc inet socket creation
Tested-by: Daniel Yang <danielyangkang@gmail.com>
Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
Reported-by: syzbot+e953a8f3071f5c0a28fd@syzkaller.appspotmail.com
---
net/smc/smc_inet.c | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/net/smc/smc_inet.c b/net/smc/smc_inet.c
index a5b204160..7ae49ffd2 100644
--- a/net/smc/smc_inet.c
+++ b/net/smc/smc_inet.c
@@ -108,14 +108,39 @@ static struct inet_protosw smc_inet6_protosw = {
};
#endif /* CONFIG_IPV6 */
+static struct lock_class_key smc_slock_keys[2];
+static struct lock_class_key smc_keys[2];
+
static int smc_inet_init_sock(struct sock *sk)
{
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;
+
+ switch (sk->sk_family) {
+ case AF_INET:
+ sock_lock_init_class_and_name(sk, "slock-AF_INET-SMC",
+ &smc_slock_keys[0],
+ "sk_lock-AF_INET-SMC",
+ &smc_keys[0]);
+ break;
+ case AF_INET6:
+ sock_lock_init_class_and_name(sk, "slock-AF_INET6-SMC",
+ &smc_slock_keys[1],
+ "sk_lock-AF_INET6-SMC",
+ &smc_keys[1]);
+ break;
+ default:
+ WARN_ON_ONCE(1);
+ }
+
+ return 0;
}
int __init smc_inet_init(void)
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v3 2/2] Move lockdep annotation to separate function for readability.
2024-10-14 7:30 [PATCH v3 0/2] resolve gtp possible deadlock warning Daniel Yang
2024-10-14 7:30 ` [PATCH v3 1/2] Patch from Daniel Yang
@ 2024-10-14 7:30 ` Daniel Yang
2024-10-15 17:54 ` [PATCH v3 0/2] resolve gtp possible deadlock warning Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Daniel Yang @ 2024-10-14 7:30 UTC (permalink / raw)
To: Wenjia Zhang, Jan Karcher, D. Wythe, Tony Lu, Wen Gu,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
linux-s390, netdev, linux-kernel
Cc: danielyangkang, syzbot+e953a8f3071f5c0a28fd
From: Daniel Yang <danielyangkang@gmail.com>
Moved lockdep annotation to separate function for readability.
Signed-off-by: Daniel Yang <danielyangkang@gmail.com>
Reported-by: syzbot+e953a8f3071f5c0a28fd@syzkaller.appspotmail.com
---
net/smc/smc_inet.c | 28 +++++++++++++++-------------
1 file changed, 15 insertions(+), 13 deletions(-)
diff --git a/net/smc/smc_inet.c b/net/smc/smc_inet.c
index 7ae49ffd2..b3eedc3b0 100644
--- a/net/smc/smc_inet.c
+++ b/net/smc/smc_inet.c
@@ -111,18 +111,7 @@ static struct inet_protosw smc_inet6_protosw = {
static struct lock_class_key smc_slock_keys[2];
static struct lock_class_key smc_keys[2];
-static int smc_inet_init_sock(struct sock *sk)
-{
- struct net *net = sock_net(sk);
- int rc;
-
- /* init common smc sock */
- smc_sk_init(net, sk, IPPROTO_SMC);
- /* create clcsock */
- rc = smc_create_clcsk(net, sk, sk->sk_family);
- if (rc)
- return rc;
-
+static inline void smc_inet_lockdep_annotate(struct sock *sk)
+{
switch (sk->sk_family) {
case AF_INET:
sock_lock_init_class_and_name(sk, "slock-AF_INET-SMC",
@@ -139,8 +128,21 @@ static int smc_inet_init_sock(struct sock *sk)
default:
WARN_ON_ONCE(1);
}
+}
- return 0;
+static int smc_inet_init_sock(struct sock *sk)
+{
+ struct net *net = sock_net(sk);
+ int rc;
+
+ /* init common smc sock */
+ smc_sk_init(net, sk, IPPROTO_SMC);
+ /* create clcsock */
+ rc = smc_create_clcsk(net, sk, sk->sk_family);
+ if (!rc)
+ smc_inet_lockdep_annotate(sk);
+
+ return rc;
}
int __init smc_inet_init(void)
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v3 0/2] resolve gtp possible deadlock warning
2024-10-14 7:30 [PATCH v3 0/2] resolve gtp possible deadlock warning Daniel Yang
2024-10-14 7:30 ` [PATCH v3 1/2] Patch from Daniel Yang
2024-10-14 7:30 ` [PATCH v3 2/2] Move lockdep annotation to separate function for readability Daniel Yang
@ 2024-10-15 17:54 ` Jakub Kicinski
2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2024-10-15 17:54 UTC (permalink / raw)
To: Daniel Yang
Cc: Wenjia Zhang, Jan Karcher, D. Wythe, Tony Lu, Wen Gu,
David S. Miller, Eric Dumazet, Paolo Abeni, linux-s390, netdev,
linux-kernel
On Mon, 14 Oct 2024 00:30:36 -0700 Daniel Yang wrote:
> Fixes deadlock described in this bug:
> https://syzkaller.appspot.com/bug?extid=e953a8f3071f5c0a28fd.
> Specific crash report here:
> https://syzkaller.appspot.com/text?tag=CrashReport&x=14670e07980000.
>
> This bug is a false positive lockdep warning since gtp and smc use
> completely different socket protocols.
>
> Lockdep thinks that lock_sock() in smc will deadlock with gtp's
> lock_sock() acquisition.
>
> Adding lockdep annotations on smc socket creation prevents these false
> positives.
This posting looks corrupted, please fix and repost, if it's
not accidental.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-15 17:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-14 7:30 [PATCH v3 0/2] resolve gtp possible deadlock warning Daniel Yang
2024-10-14 7:30 ` [PATCH v3 1/2] Patch from Daniel Yang
2024-10-14 7:30 ` [PATCH v3 2/2] Move lockdep annotation to separate function for readability Daniel Yang
2024-10-15 17:54 ` [PATCH v3 0/2] resolve gtp possible deadlock warning Jakub Kicinski
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.