lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Tue, 28 May 2024 14:47:57 +0200
From: Greg KH <gregkh@...uxfoundation.org>
To: Tony W Wang-oc <TonyWWang-oc@...oxin.com>
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de, hpa@...or.com,
	x86@...nel.org, jpoimboe@...nel.org, vlovejoy@...hat.com,
	oleg@...hat.com, linux-kernel@...r.kernel.org, CobeChen@...oxin.com,
	TimGuo@...oxin.com, LeoLiu-oc@...oxin.com
Subject: Re: [PATCH] linux-4.19.y/printk: Avoid logbuf_lock deadlock in
 oops_end()

On Tue, May 28, 2024 at 06:19:57PM +0800, Tony W Wang-oc wrote:
> A CPU executing vprintk_emit might be interrupted by #PF exception,
> this may leads to logbuf_lock deadlock:
> 
> CPU x:                            CPU x:
> ----                              ----
> vprintk_emit()
>   logbuf_lock_irqsave()
>     printk_safe_enter_irqsave()
> A:  raw_spin_lock(&logbuf_lock)
>   vprintk_store()                 #PF
>                                   do_page_fault
>                                     ...
>                                     oops_end
>                                       bust_spinlocks(0)
>                                         console_unlock()
>                                           ...
>                                           printk_safe_enter_irqsave()
> B:                                        raw_spin_lock(&logbuf_lock)
> 
> logbuf_lock is taken at A and the deadlock happends at B.
> 
> Pass 1 to bust_spinlocks() in the oops_end() to avoid this deadlock.
> 
> Signed-off-by: Tony W Wang-oc <TonyWWang-oc@...oxin.com>
> ---
>  arch/x86/kernel/dumpstack.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
> index 7e698c45760c..b4c145ee9536 100644
> --- a/arch/x86/kernel/dumpstack.c
> +++ b/arch/x86/kernel/dumpstack.c
> @@ -336,7 +336,7 @@ void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
>  	if (regs && kexec_should_crash(current))
>  		crash_kexec(regs);
>  
> -	bust_spinlocks(0);
> +	bust_spinlocks(1);
>  	die_owner = -1;
>  	add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
>  	die_nest_count--;
> -- 
> 2.25.1
> 

<formletter>

This is not the correct way to submit patches for inclusion in the
stable kernel tree.  Please read:
    https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.

</formletter>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ