diff mbox series

hams: Fix deadlock caused by unsafe-irq lock in sp_get()

Message ID 20240418173037.6714-1-aha310510@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series hams: Fix deadlock caused by unsafe-irq lock in sp_get() | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 986 this patch: 17
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: pabeni@redhat.com
netdev/build_clang fail Errors and warnings before: 940 this patch: 18
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 No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 1001 this patch: 17
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 15 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

Commit Message

Jeongjun Park April 18, 2024, 5:30 p.m. UTC
read_lock() present in sp_get() is interrupt-vulnerable, so the function needs to be modified.


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

Comments

Dan Carpenter April 22, 2024, 12:47 p.m. UTC | #1
On Fri, Apr 19, 2024 at 02:30:37AM +0900, Jeongjun Park wrote:
> 
> read_lock() present in sp_get() is interrupt-vulnerable, so the function needs to be modified.
> 
> 
> Reported-by: syzbot+8e03da5d64bc85098811@syzkaller.appspotmail.com
> Signed-off-by: Jeongjun Park <aha310510@gmail.com>
> ---
>  drivers/net/hamradio/6pack.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
> index 6ed38a3cdd73..f882682ff0c8 100644
> --- a/drivers/net/hamradio/6pack.c
> +++ b/drivers/net/hamradio/6pack.c
> @@ -372,12 +372,13 @@ static DEFINE_RWLOCK(disc_data_lock);
>  static struct sixpack *sp_get(struct tty_struct *tty)
>  {
>  	struct sixpack *sp;
> +	unsigned long flags;
>  
> -	read_lock(&disc_data_lock);
> +	flags = read_lock_irqsave(&disc_data_lock);

This doesn't compile.  At least build test your patches.

regards,
dan carpenter
diff mbox series

Patch

diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c
index 6ed38a3cdd73..f882682ff0c8 100644
--- a/drivers/net/hamradio/6pack.c
+++ b/drivers/net/hamradio/6pack.c
@@ -372,12 +372,13 @@  static DEFINE_RWLOCK(disc_data_lock);
 static struct sixpack *sp_get(struct tty_struct *tty)
 {
 	struct sixpack *sp;
+	unsigned long flags;
 
-	read_lock(&disc_data_lock);
+	flags = read_lock_irqsave(&disc_data_lock);
 	sp = tty->disc_data;
 	if (sp)
 		refcount_inc(&sp->refcnt);
-	read_unlock(&disc_data_lock);
+	read_unlock_irqrestore(&disc_data_lock, flags);
 
 	return sp;
 }