mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bradley Morgan <brads@mainlining.org>
To: eadavis@sina.com
Cc: kernelfans@gmail.com, linux-kernel@vger.kernel.org,
	syzbot+1f0fbc2561b3e5d51b91@syzkaller.appspotmail.com,
	syzkaller-bugs@googlegroups.com, akpm@linux-foundation.org
Subject: Re: [PATCH] kernel/reboot: Avoid potential deadlocks during suspension
Date: Tue, 20 Oct 2026 16:06:27 +0100	[thread overview]
Message-ID: <082E174D-618D-4DAF-9CA6-FD953D9194B9@mainlining.org> (raw)
In-Reply-To: <20261020010559.23031-1-eadavis@sina.com>

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

      reply	other threads:[~2026-10-20 15:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=082E174D-618D-4DAF-9CA6-FD953D9194B9@mainlining.org \
    --to=brads@mainlining.org \
    --cc=akpm@linux-foundation.org \
    --cc=eadavis@sina.com \
    --cc=kernelfans@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+1f0fbc2561b3e5d51b91@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®