linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* (no subject)
@ 2024-10-15 22:48 Daniel Yang
  2024-10-15 22:48 ` [PATCH v3 1/2 RESEND] resolve gtp possible deadlock warning Daniel Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Daniel Yang @ 2024-10-15 22:48 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

Date: Tue, 15 Oct 2024 15:31:12 -0700
Subject: [PATCH v3 0/2 RESEND] resolve gtp possible deadlock warning

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] 8+ messages in thread

* [PATCH v3 1/2 RESEND] resolve gtp possible deadlock warning
  2024-10-15 22:48 Daniel Yang
@ 2024-10-15 22:48 ` Daniel Yang
  2024-10-15 22:48 ` [PATCH v3 2/2 " Daniel Yang
  2024-10-16  1:27 ` Jakub Kicinski
  2 siblings, 0 replies; 8+ messages in thread
From: Daniel Yang @ 2024-10-15 22:48 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] 8+ messages in thread

* [PATCH v3 2/2 RESEND] resolve gtp possible deadlock warning
  2024-10-15 22:48 Daniel Yang
  2024-10-15 22:48 ` [PATCH v3 1/2 RESEND] resolve gtp possible deadlock warning Daniel Yang
@ 2024-10-15 22:48 ` Daniel Yang
  2024-10-16  0:03   ` Kuniyuki Iwashima
  2024-10-22  2:00   ` D. Wythe
  2024-10-16  1:27 ` Jakub Kicinski
  2 siblings, 2 replies; 8+ messages in thread
From: Daniel Yang @ 2024-10-15 22:48 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] 8+ messages in thread

* Re: [PATCH v3 2/2 RESEND] resolve gtp possible deadlock warning
  2024-10-15 22:48 ` [PATCH v3 2/2 " Daniel Yang
@ 2024-10-16  0:03   ` Kuniyuki Iwashima
  2024-10-16  0:24     ` Daniel Yang
  2024-10-22  2:00   ` D. Wythe
  1 sibling, 1 reply; 8+ messages in thread
From: Kuniyuki Iwashima @ 2024-10-16  0:03 UTC (permalink / raw)
  To: danielyangkang
  Cc: alibuda, davem, edumazet, guwen, jaka, kuba, linux-kernel,
	linux-s390, netdev, pabeni, syzbot+e953a8f3071f5c0a28fd, tonylu,
	wenjia

From: Daniel Yang <danielyangkang@gmail.com>
Date: Tue, 15 Oct 2024 15:48:05 -0700
> 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

This tag is bogus, why not squash to patch 1 ?

Also, patch 1 needs Fixes: tag.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2 RESEND] resolve gtp possible deadlock warning
  2024-10-16  0:03   ` Kuniyuki Iwashima
@ 2024-10-16  0:24     ` Daniel Yang
  2024-10-16  0:30       ` Daniel Yang
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel Yang @ 2024-10-16  0:24 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: alibuda, davem, edumazet, guwen, jaka, kuba, linux-kernel,
	linux-s390, netdev, pabeni, syzbot+e953a8f3071f5c0a28fd, tonylu,
	wenjia

On Tue, Oct 15, 2024 at 5:03 PM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
>
> From: Daniel Yang <danielyangkang@gmail.com>
> Date: Tue, 15 Oct 2024 15:48:05 -0700
> > 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
>
> This tag is bogus, why not squash to patch 1 ?
>
> Also, patch 1 needs Fixes: tag.

I wanted to split them up since D. Wythe suggested the fix when I was
having trouble finding where the packets were being created so I
wanted to give credit.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2 RESEND] resolve gtp possible deadlock warning
  2024-10-16  0:24     ` Daniel Yang
@ 2024-10-16  0:30       ` Daniel Yang
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel Yang @ 2024-10-16  0:30 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: alibuda, davem, edumazet, guwen, jaka, kuba, linux-kernel,
	linux-s390, netdev, pabeni, syzbot+e953a8f3071f5c0a28fd, tonylu,
	wenjia

On Tue, Oct 15, 2024 at 5:24 PM Daniel Yang <danielyangkang@gmail.com> wrote:
>
> On Tue, Oct 15, 2024 at 5:03 PM Kuniyuki Iwashima <kuniyu@amazon.com> wrote:
> >
> > From: Daniel Yang <danielyangkang@gmail.com>
> > Date: Tue, 15 Oct 2024 15:48:05 -0700
> > > 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
> >
> > This tag is bogus, why not squash to patch 1 ?
> >
> > Also, patch 1 needs Fixes: tag.
>
> I wanted to split them up since D. Wythe suggested the fix when I was
> having trouble finding where the packets were being created so I
> wanted to give credit.

I'll squash and resend with the Fixes: tag and put him in the
Suggested-by: or something since it matters to you.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re:
  2024-10-15 22:48 Daniel Yang
  2024-10-15 22:48 ` [PATCH v3 1/2 RESEND] resolve gtp possible deadlock warning Daniel Yang
  2024-10-15 22:48 ` [PATCH v3 2/2 " Daniel Yang
@ 2024-10-16  1:27 ` Jakub Kicinski
  2 siblings, 0 replies; 8+ messages in thread
From: Jakub Kicinski @ 2024-10-16  1:27 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 Tue, 15 Oct 2024 15:48:03 -0700 Daniel Yang wrote:
> Subject: 
> Date: Tue, 15 Oct 2024 15:48:03 -0700
> X-Mailer: git-send-email 2.39.2
> 
> Date: Tue, 15 Oct 2024 15:31:12 -0700
> Subject: [PATCH v3 0/2 RESEND] resolve gtp possible deadlock warning

This is garbled as well. 

Before you repost please make sure you take a look at:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html#tl-dr
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v3 2/2 RESEND] resolve gtp possible deadlock warning
  2024-10-15 22:48 ` [PATCH v3 2/2 " Daniel Yang
  2024-10-16  0:03   ` Kuniyuki Iwashima
@ 2024-10-22  2:00   ` D. Wythe
  1 sibling, 0 replies; 8+ messages in thread
From: D. Wythe @ 2024-10-22  2:00 UTC (permalink / raw)
  To: Daniel Yang, Wenjia Zhang, Jan Karcher, Tony Lu, Wen Gu,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	linux-s390, netdev, linux-kernel
  Cc: syzbot+e953a8f3071f5c0a28fd



On 10/16/24 6:48 AM, Daniel Yang wrote:
> 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)

I need to check why you said Wang Cong's patch cannot fix the issue.
As soon as I reach a conclusion, I'll inform you right away.

D. Wythe

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-10-22  2:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-15 22:48 Daniel Yang
2024-10-15 22:48 ` [PATCH v3 1/2 RESEND] resolve gtp possible deadlock warning Daniel Yang
2024-10-15 22:48 ` [PATCH v3 2/2 " Daniel Yang
2024-10-16  0:03   ` Kuniyuki Iwashima
2024-10-16  0:24     ` Daniel Yang
2024-10-16  0:30       ` Daniel Yang
2024-10-22  2:00   ` D. Wythe
2024-10-16  1:27 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).