Bug 9425 - [devel-5.10] printk: Avoid logbuf_lock deadlock in oops_end()
Summary: [devel-5.10] printk: Avoid logbuf_lock deadlock in oops_end()
Status: NEW
Alias: None
Product: ANCK 5.10 Dev
Classification: ANCK
Component: X86 (show other bugs) X86
Version: unspecified
Hardware: All Linux
: P3-Medium S3-normal
Target Milestone: ---
Assignee: Guanjun
QA Contact: shuming
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-06-25 19:07 UTC by LeoLiu-oc
Modified: 2024-06-25 19:10 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description LeoLiu-oc zhaoxin_group 2024-06-25 19:07:29 UTC
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.
Comment 1 小龙 admin 2024-06-25 19:10:04 UTC
The PR Link: https://gitee.com/anolis/cloud-kernel/pulls/3431