mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [syzbot] possible deadlock in lock_system_sleep (2)
@ 2026-10-19 18:08 syzbot
  2026-10-20  0:37 ` Edward Adam Davis
  2026-10-20  1:05 ` [PATCH] kernel/reboot: Avoid potential deadlocks during suspension Edward Adam Davis
  0 siblings, 2 replies; 5+ messages in thread
From: syzbot @ 2026-10-19 18:08 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    32c52ec87d62 x86/insn-eval: Fix shadowed segment index in ..
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=120a93a9580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c4b098695335c89f
dashboard link: https://syzkaller.appspot.com/bug?extid=1f0fbc2561b3e5d51b91
compiler:       Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=141d098e580000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+1f0fbc2561b3e5d51b91@syzkaller.appspotmail.com

============================================
WARNING: possible recursive locking detected
syzkaller #0 Not tainted
--------------------------------------------
syz.3.5755/5950 is trying to acquire lock:
ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: lock_system_sleep+0x49/0x70 kernel/power/main.c:71

but task is already holding lock:
ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __do_sys_reboot kernel/reboot.c:774 [inline]
ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __se_sys_reboot+0x223/0x460 kernel/reboot.c:738

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(system_transition_mutex);
  lock(system_transition_mutex);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

locks held by syz.3.5755/5950: 1, last CPU#0:
 #0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __do_sys_reboot kernel/reboot.c:774 [inline]
 #0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __se_sys_reboot+0x223/0x460 kernel/reboot.c:738

stack backtrace:
CPU: 0 UID: 0 PID: 5950 Comm: syz.3.5755 Not tainted syzkaller #0 PREEMPT(full) 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/07/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 print_deadlock_bug+0x27a/0x290 kernel/locking/lockdep.c:3085
 check_deadlock kernel/locking/lockdep.c:3137 [inline]
 validate_chain kernel/locking/lockdep.c:3939 [inline]
 __lock_acquire+0x25db/0x2de0 kernel/locking/lockdep.c:5288
 lock_acquire+0x115/0x350 kernel/locking/lockdep.c:5942
 __mutex_lock_common kernel/locking/mutex.c:646 [inline]
 __mutex_lock+0x19d/0x1550 kernel/locking/mutex.c:821
 lock_system_sleep+0x49/0x70 kernel/power/main.c:71
 hibernate+0x162/0x680 kernel/power/hibernate.c:784
 __do_sys_reboot kernel/reboot.c:816 [inline]
 __se_sys_reboot+0x2ba/0x460 kernel/reboot.c:738
 do_syscall_x64 arch/x86/entry/syscall_64.c:61 [inline]
 do_syscall_64+0x166/0x520 arch/x86/entry/syscall_64.c:84
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7fdb2419f809
Code: c0 79 93 eb d5 48 8d 7c 1d 00 eb 99 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 d8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffff22cee98 EFLAGS: 00000246 ORIG_RAX: 00000000000000a9
RAX: ffffffffffffffda RBX: 00007ffff22cefc8 RCX: 00007fdb2419f809
RDX: 00000000d000fce2 RSI: 0000000028121969 RDI: 00000000fee1dead
RBP: 0000000000000001 R08: 0000000000000000 R09: 00007ffff22cefc8
R10: 0000000000000000 R11: 0000000000000246 R12: 00007ffff22cefb8
R13: 0000000000000002 R14: 00007fdb24222cc0 R15: 0000000000000002
 </TASK>


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

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

* Re: [syzbot] possible deadlock in lock_system_sleep (2)
  2026-10-19 18:08 [syzbot] possible deadlock in lock_system_sleep (2) syzbot
@ 2026-10-20  0:37 ` Edward Adam Davis
  2026-10-20  1:47   ` syzbot
  2026-10-20  1:05 ` [PATCH] kernel/reboot: Avoid potential deadlocks during suspension Edward Adam Davis
  1 sibling, 1 reply; 5+ messages in thread
From: Edward Adam Davis @ 2026-10-20  0:37 UTC (permalink / raw)
  To: syzbot+1f0fbc2561b3e5d51b91; +Cc: linux-kernel, syzkaller-bugs

From: Edward Aadm Davis <eadavis@sina.com>

#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 32c52ec87d62

diff --git a/kernel/reboot.c b/kernel/reboot.c
index 5b9691f45f5f..bc2716677a6c 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -813,8 +813,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
 
 #ifdef CONFIG_HIBERNATION
 	case LINUX_REBOOT_CMD_SW_SUSPEND:
-		ret = hibernate();
-		break;
+		mutex_unlock(&system_transition_mutex);
+		return hibernate();
 #endif
 
 	default:

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

* [PATCH] kernel/reboot: Avoid potential deadlocks during suspension
  2026-10-19 18:08 [syzbot] possible deadlock in lock_system_sleep (2) syzbot
  2026-10-20  0:37 ` Edward Adam Davis
@ 2026-10-20  1:05 ` Edward Adam Davis
  2026-10-20 15:06   ` Bradley Morgan
  1 sibling, 1 reply; 5+ messages in thread
From: Edward Adam Davis @ 2026-10-20  1:05 UTC (permalink / raw)
  To: syzbot+1f0fbc2561b3e5d51b91; +Cc: linux-kernel, syzkaller-bugs, kernelfans

Invoking reboot with LINUX_REBOOT_CMD_SW_SUSPEND causes kernel/reboot.c
to acquire system_transition_mutex and invoke hibernate(). hibernate()
calls lock_system_sleep(), which sets PF_NOFREEZE on current and attempts
to acquire system_transition_mutex again, potentially hitting:

WARNING: possible recursive locking detected
--------------------------------------------
syz.3.5755/5950 is trying to acquire lock:
ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: lock_system_sleep+0x49/0x70 kernel/power/main.c:71

but task is already holding lock:
ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __do_sys_reboot kernel/reboot.c:774 [inline]
ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __se_sys_reboot+0x223/0x460 kernel/reboot.c:738

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(system_transition_mutex);
  lock(system_transition_mutex);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

locks held by syz.3.5755/5950: 1, last CPU#0:
 #0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __do_sys_reboot kernel/reboot.c:774 [inline]
 #0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at: __se_sys_reboot+0x223/0x460 kernel/reboot.c:738

Call Trace:
 lock_system_sleep+0x49/0x70 kernel/power/main.c:71
 hibernate+0x162/0x680 kernel/power/hibernate.c:784
 __do_sys_reboot kernel/reboot.c:816 [inline]

Move the suspension operation outside the scope protected by lock
system_transition_mutex.

Fixes: 55f2503c3b69 ("PM / reboot: Eliminate race between reboot and suspend")
Reported-by: syzbot+1f0fbc2561b3e5d51b91@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=1f0fbc2561b3e5d51b91
Signed-off-by: Edward Adam Davis <eadavis@sina.com>
---
 kernel/reboot.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/reboot.c b/kernel/reboot.c
index 5b9691f45f5f..bc2716677a6c 100644
--- a/kernel/reboot.c
+++ b/kernel/reboot.c
@@ -813,8 +813,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
 
 #ifdef CONFIG_HIBERNATION
 	case LINUX_REBOOT_CMD_SW_SUSPEND:
-		ret = hibernate();
-		break;
+		mutex_unlock(&system_transition_mutex);
+		return hibernate();
 #endif
 
 	default:
-- 
2.43.0


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

* Re: [syzbot] possible deadlock in lock_system_sleep (2)
  2026-10-20  0:37 ` Edward Adam Davis
@ 2026-10-20  1:47   ` syzbot
  0 siblings, 0 replies; 5+ messages in thread
From: syzbot @ 2026-10-20  1:47 UTC (permalink / raw)
  To: eadavis, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+1f0fbc2561b3e5d51b91@syzkaller.appspotmail.com
Tested-by: syzbot+1f0fbc2561b3e5d51b91@syzkaller.appspotmail.com

Tested on:

commit:         32c52ec8 x86/insn-eval: Fix shadowed segment index in ..
git tree:       git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=17ef3831580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=c4b098695335c89f
dashboard link: https://syzkaller.appspot.com/bug?extid=1f0fbc2561b3e5d51b91
compiler:       Debian clang version 22.1.8 (1~deb13u4), Debian LLD 22.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=148f298e580000

Note: testing is done by a robot and is best-effort only.

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

* Re: [PATCH] kernel/reboot: Avoid potential deadlocks during suspension
  2026-10-20  1:05 ` [PATCH] kernel/reboot: Avoid potential deadlocks during suspension Edward Adam Davis
@ 2026-10-20 15:06   ` Bradley Morgan
  0 siblings, 0 replies; 5+ messages in thread
From: Bradley Morgan @ 2026-10-20 15:06 UTC (permalink / raw)
  To: eadavis
  Cc: kernelfans, linux-kernel, syzbot+1f0fbc2561b3e5d51b91,
	syzkaller-bugs, akpm

On 20 October 2026 02:05:59 BST, Edward Adam Davis <eadavis@sina.com>
wrote:
>Invoking reboot with LINUX_REBOOT_CMD_SW_SUSPEND causes kernel/reboot.c
>to acquire system_transition_mutex and invoke hibernate(). hibernate()
>calls lock_system_sleep(), which sets PF_NOFREEZE on current and attempts
>to acquire system_transition_mutex again, potentially hitting:
>
>WARNING: possible recursive locking detected
>--------------------------------------------
>syz.3.5755/5950 is trying to acquire lock:
>ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at:
>lock_system_sleep+0x49/0x70 kernel/power/main.c:71
>
>but task is already holding lock:
>ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at:
>__do_sys_reboot kernel/reboot.c:774 [inline]
>ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at:
>__se_sys_reboot+0x223/0x460 kernel/reboot.c:738
>
>other info that might help us debug this:
> Possible unsafe locking scenario:
>
>       CPU0
>       ----
>  lock(system_transition_mutex);
>  lock(system_transition_mutex);
>
> *** DEADLOCK ***
>
> May be due to missing lock nesting notation
>
>locks held by syz.3.5755/5950: 1, last CPU#0:
> #0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at:
> __do_sys_reboot kernel/reboot.c:774 [inline]
> #0: ffffffff8fc04760 (system_transition_mutex){+.+.}-{4:4}, at:
> __se_sys_reboot+0x223/0x460 kernel/reboot.c:738
>
>Call Trace:
> lock_system_sleep+0x49/0x70 kernel/power/main.c:71
> hibernate+0x162/0x680 kernel/power/hibernate.c:784
> __do_sys_reboot kernel/reboot.c:816 [inline]
>
>Move the suspension operation outside the scope protected by lock
>system_transition_mutex.
>
>Fixes: 55f2503c3b69 ("PM / reboot: Eliminate race between reboot and suspend")
>Reported-by: syzbot+1f0fbc2561b3e5d51b91@syzkaller.appspotmail.com
>Closes: https://syzkaller.appspot.com/bug?extid=1f0fbc2561b3e5d51b91

CC akpm:

>Signed-off-by: Edward Adam Davis <eadavis@sina.com>
>---
> kernel/reboot.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/kernel/reboot.c b/kernel/reboot.c
>index 5b9691f45f5f..bc2716677a6c 100644
>--- a/kernel/reboot.c
>+++ b/kernel/reboot.c
>@@ -813,8 +813,8 @@ SYSCALL_DEFINE4(reboot, int, magic1, int, magic2, unsigned int, cmd,
> 
> #ifdef CONFIG_HIBERNATION
> 	case LINUX_REBOOT_CMD_SW_SUSPEND:
>-		ret = hibernate();
>-		break;
>+		mutex_unlock(&system_transition_mutex);
>+		return hibernate();

Well, this fixes the issue in hand, 

Reviewed-by: Bradley Morgan <brads@mainlining.org>


> #endif
> 
> 	default:
>

--- Thanks!
"I'm not a very positive person" - Linus torvalds

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

end of thread, other threads:[~2026-10-20 15:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-19 18:08 [syzbot] possible deadlock in lock_system_sleep (2) syzbot
2026-10-20  0:37 ` Edward Adam Davis
2026-10-20  1:47   ` syzbot
2026-10-20  1:05 ` [PATCH] kernel/reboot: Avoid potential deadlocks during suspension Edward Adam Davis
2026-10-20 15:06   ` Bradley Morgan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®