From: Greg KH <gregkh@linuxfoundation.org>
To: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de,
hpa@zytor.com, x86@kernel.org, jpoimboe@kernel.org,
vlovejoy@redhat.com, oleg@redhat.com,
linux-kernel@vger.kernel.org, CobeChen@zhaoxin.com,
TimGuo@zhaoxin.com, LeoLiu-oc@zhaoxin.com
Subject: Re: [PATCH] linux-4.19.y/printk: Avoid logbuf_lock deadlock in oops_end()
Date: Tue, 28 May 2024 14:47:57 +0200 [thread overview]
Message-ID: <2024052839-tipped-fragility-2799@gregkh> (raw)
In-Reply-To: <20240528101957.7277-1-TonyWWang-oc@zhaoxin.com>
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@zhaoxin.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>
prev parent reply other threads:[~2024-05-28 12:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 10:19 Tony W Wang-oc
2024-05-28 12:47 ` Greg KH [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=2024052839-tipped-fragility-2799@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=CobeChen@zhaoxin.com \
--cc=LeoLiu-oc@zhaoxin.com \
--cc=TimGuo@zhaoxin.com \
--cc=TonyWWang-oc@zhaoxin.com \
--cc=bp@alien8.de \
--cc=hpa@zytor.com \
--cc=jpoimboe@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=vlovejoy@redhat.com \
--cc=x86@kernel.org \
/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®