linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel/kexec: remove the lock operation of system_transition_mutex
@ 2021-01-22  7:42 Baoquan He
  2021-01-25  9:05 ` Pingfan Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Baoquan He @ 2021-01-22  7:42 UTC (permalink / raw)
  To: linux-pm; +Cc: kexec, rafael, dan.carpenter, kernelfans, bhe

Function kernel_kexec() is called with lock system_transition_mutex held
in reboot system call. While inside kernel_kexec(), it will acquire
system_transition_mutex agin. This will lead to dead lock.

The dead lock should be easily triggered, it hasn't caused any failure
report just because the feature 'kexec jump' is almost not used by anyone
as far as I know. An inquiry can be made about who is using 'kexec jump'
and where it's used. Before that, let's simply remove the lock operation
inside CONFIG_KEXEC_JUMP ifdeffery scope.

Signed-off-by: Baoquan He <bhe@redhat.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Pingfan Liu <kernelfans@gmail.com>
---
 kernel/kexec_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 80905e5aa8ae..a0b6780740c8 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -1134,7 +1134,6 @@ int kernel_kexec(void)
 
 #ifdef CONFIG_KEXEC_JUMP
 	if (kexec_image->preserve_context) {
-		lock_system_sleep();
 		pm_prepare_console();
 		error = freeze_processes();
 		if (error) {
@@ -1197,7 +1196,6 @@ int kernel_kexec(void)
 		thaw_processes();
  Restore_console:
 		pm_restore_console();
-		unlock_system_sleep();
 	}
 #endif
 
-- 
2.17.2


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

* Re: [PATCH] kernel/kexec: remove the lock operation of system_transition_mutex
  2021-01-22  7:42 [PATCH] kernel/kexec: remove the lock operation of system_transition_mutex Baoquan He
@ 2021-01-25  9:05 ` Pingfan Liu
  2021-01-25 17:45   ` Rafael J. Wysocki
  0 siblings, 1 reply; 3+ messages in thread
From: Pingfan Liu @ 2021-01-25  9:05 UTC (permalink / raw)
  To: Baoquan He; +Cc: linux-pm, Kexec Mailing List, Rafael Wysocki, Dan Carpenter

On Fri, Jan 22, 2021 at 3:42 PM Baoquan He <bhe@redhat.com> wrote:
>
> Function kernel_kexec() is called with lock system_transition_mutex held
> in reboot system call. While inside kernel_kexec(), it will acquire
> system_transition_mutex agin. This will lead to dead lock.
>
> The dead lock should be easily triggered, it hasn't caused any failure
> report just because the feature 'kexec jump' is almost not used by anyone
> as far as I know. An inquiry can be made about who is using 'kexec jump'
> and where it's used. Before that, let's simply remove the lock operation
> inside CONFIG_KEXEC_JUMP ifdeffery scope.
>
> Signed-off-by: Baoquan He <bhe@redhat.com>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Reviewed-by: Pingfan Liu <kernelfans@gmail.com>
> ---
>  kernel/kexec_core.c | 2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> index 80905e5aa8ae..a0b6780740c8 100644
> --- a/kernel/kexec_core.c
> +++ b/kernel/kexec_core.c
> @@ -1134,7 +1134,6 @@ int kernel_kexec(void)
>
>  #ifdef CONFIG_KEXEC_JUMP
>         if (kexec_image->preserve_context) {
> -               lock_system_sleep();
>                 pm_prepare_console();
>                 error = freeze_processes();
>                 if (error) {
> @@ -1197,7 +1196,6 @@ int kernel_kexec(void)
>                 thaw_processes();
>   Restore_console:
>                 pm_restore_console();
> -               unlock_system_sleep();
>         }
>  #endif
>
> --
> 2.17.2
>
Reviewed-by: Pingfan Liu <kernelfans@gmail.com>

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

* Re: [PATCH] kernel/kexec: remove the lock operation of system_transition_mutex
  2021-01-25  9:05 ` Pingfan Liu
@ 2021-01-25 17:45   ` Rafael J. Wysocki
  0 siblings, 0 replies; 3+ messages in thread
From: Rafael J. Wysocki @ 2021-01-25 17:45 UTC (permalink / raw)
  To: Pingfan Liu, Baoquan He
  Cc: Linux PM, Kexec Mailing List, Rafael Wysocki, Dan Carpenter

On Mon, Jan 25, 2021 at 10:05 AM Pingfan Liu <kernelfans@gmail.com> wrote:
>
> On Fri, Jan 22, 2021 at 3:42 PM Baoquan He <bhe@redhat.com> wrote:
> >
> > Function kernel_kexec() is called with lock system_transition_mutex held
> > in reboot system call. While inside kernel_kexec(), it will acquire
> > system_transition_mutex agin. This will lead to dead lock.
> >
> > The dead lock should be easily triggered, it hasn't caused any failure
> > report just because the feature 'kexec jump' is almost not used by anyone
> > as far as I know. An inquiry can be made about who is using 'kexec jump'
> > and where it's used. Before that, let's simply remove the lock operation
> > inside CONFIG_KEXEC_JUMP ifdeffery scope.
> >
> > Signed-off-by: Baoquan He <bhe@redhat.com>
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Reviewed-by: Pingfan Liu <kernelfans@gmail.com>
> > ---
> >  kernel/kexec_core.c | 2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> > index 80905e5aa8ae..a0b6780740c8 100644
> > --- a/kernel/kexec_core.c
> > +++ b/kernel/kexec_core.c
> > @@ -1134,7 +1134,6 @@ int kernel_kexec(void)
> >
> >  #ifdef CONFIG_KEXEC_JUMP
> >         if (kexec_image->preserve_context) {
> > -               lock_system_sleep();
> >                 pm_prepare_console();
> >                 error = freeze_processes();
> >                 if (error) {
> > @@ -1197,7 +1196,6 @@ int kernel_kexec(void)
> >                 thaw_processes();
> >   Restore_console:
> >                 pm_restore_console();
> > -               unlock_system_sleep();
> >         }
> >  #endif
> >
> > --
> > 2.17.2
> >
> Reviewed-by: Pingfan Liu <kernelfans@gmail.com>

Applied as 5.11-rc material, thanks!

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

end of thread, other threads:[~2021-01-26 19:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-22  7:42 [PATCH] kernel/kexec: remove the lock operation of system_transition_mutex Baoquan He
2021-01-25  9:05 ` Pingfan Liu
2021-01-25 17:45   ` Rafael J. Wysocki

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).