[PATCH net,v3] net: hams: Fix deadlock caused by unsafe-irq lock in sp_get()

Jeongjun Park posted 1 patch 1 year, 9 months ago
There is a newer version of this series
drivers/net/hamradio/6pack.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH net,v3] net: hams: Fix deadlock caused by unsafe-irq lock in sp_get()
Posted by Jeongjun Park 1 year, 9 months ago

read_lock() present in sp_get() is interrupt-vulnerable, so the function needs to be modified.


Reported-by: syzbot+8e03da5d64bc85098811@syzkaller.appspotmail.com
Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
Signed-off-by: Jeongjun Park <aha310510@gmail.com>
---
 drivers/net/hamradio/6pack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 6ed38a3cdd73..fee583b1e59a 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -373,11 +373,11 @@ static struct sixpack *sp_get(struct tty_struct *tty)
 {
 	struct sixpack *sp;
 
-	read_lock(&disc_data_lock);
+	read_lock_irq(&disc_data_lock);
 	sp = tty->disc_data;
 	if (sp)
 		refcount_inc(&sp->refcnt);
-	read_unlock(&disc_data_lock);
+	read_unlock_irq(&disc_data_lock);
 
 	return sp;
 }
-- 
2.34.1
Re: [PATCH net,v3] net: hams: Fix deadlock caused by unsafe-irq lock in sp_get()
Posted by Jakub Kicinski 1 year, 9 months ago
On Sat, 20 Apr 2024 04:14:38 +0900 Jeongjun Park wrote:
> read_lock() present in sp_get() is interrupt-vulnerable, so the function needs to be modified.

I was going to make the same comments as on the other submission 
but then I realized this doesn't even build.

Please don't spam the list with completely untested code. You can
submit patches to syzbot for testing without CCing the list
or developers.

> Reported-by: syzbot+8e03da5d64bc85098811@syzkaller.appspotmail.com
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Signed-off-by: Jeongjun Park <aha310510@gmail.com>
> ---
>  drivers/net/hamradio/6pack.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
> index 6ed38a3cdd73..fee583b1e59a 100644
> --- a/drivers/net/hamradio/6pack.c
> +++ b/drivers/net/hamradio/6pack.c
> @@ -373,11 +373,11 @@ static struct sixpack *sp_get(struct tty_struct *tty)
>  {
>  	struct sixpack *sp;
>  
> -	read_lock(&disc_data_lock);
> +	read_lock_irq(&disc_data_lock);
>  	sp = tty->disc_data;
>  	if (sp)
>  		refcount_inc(&sp->refcnt);
> -	read_unlock(&disc_data_lock);
> +	read_unlock_irq(&disc_data_lock);
>  
>  	return sp;
>  }
Re: [PATCH net,v3] net: hams: Fix deadlock caused by unsafe-irq lock in sp_get()
Posted by Jeongjun Park 1 year, 9 months ago
After looking at this email and testing everything, I have confirmed 
that both patches are running without any problems in my environment,
and the patchwork test outputs an unknown error in the patch 
in ap_get().

But the patch for sp_get() is confirmed to have no problem,
can you tell me more about the problem?

Thanks.
Re: [PATCH net,v3] net: hams: Fix deadlock caused by unsafe-irq lock in sp_get()
Posted by Dan Carpenter 1 year, 9 months ago
The ealier versions didn't build.  I feel like switching from _irqsave()
to _irq() was wrong but you just did it because you couldn't figure out
how to make _irqsave() compile...

On Sat, Apr 20, 2024 at 05:21:02PM +0900, Jeongjun Park wrote:
> After looking at this email and testing everything, I have confirmed
> that both patches are running without any problems in my environment,
> and the patchwork test outputs an unknown error in the patch
> in ap_get().

What does "the patchwork test outputs an unknown error in the patch in
ap_get()" mean?

> 
> But the patch for sp_get() is confirmed to have no problem,
> can you tell me more about the problem?
> 
> Thanks.

You say that it was tested but syzbot says that it doesn't have a
reproducer for this warning.

regards,
dan carpenter