233 Star 874 Fork 430

GVPopenEuler / kernel

 / 详情

[OLK-5.10] tty: fix possible deadlock in console_unlock

Done
Task
Opened this issue  
2021-11-29 09:57

Syzkaller hit 'possible deadlock in console_unlock' for several times.
Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&(&port->lock)->rlock);
                               lock(&port_lock_key);
                               lock(&(&port->lock)->rlock);
  lock(console_owner);

The problem is that call_console_driver->console_driver also can do
this thing

   uart_port->lock
    tty_wakeup
     tty_port->lock

So we can have the following:

tty_write
 tty_port->lock
  printk
   call_console_driver
    console_driver
     uart_port->lock
      tty_wakeup
       tty_port->lock      << deadlock

To solve this problem,  switch to printk_safe mode around that kmalloc(),
this will redirect all printk()-s from kmalloc() to a special per-CPU
buffer, which will be flushed later from a safe context (irq work).

Comments (3)

Hi hw-wupeng, welcome to the openEuler Community.
I'm the Bot here serving you. You can find the instructions on how to interact with me at
https://gitee.com/openeuler/community/blob/master/en/sig-infrastructure/command.md.
If you have any questions, please contact the SIG: Kernel, and any of the maintainers: @XieXiuQi , @YangYingliang , @成坚 (CHENG Jian) .

wupeng created任务
openeuler-ci-bot added
 
sig/Kernel
label
Expand operation logs

诚邀Issue的创建人,负责人,协作人以及评论人对此次Issue解决过程给予评价:

   0   1   2   3   4   5   6   7   8   9   10  

 不满意                        非常满意

Sign in to comment

Status
Assignees
Projects
Milestones
Pull Requests
Successfully merging a pull request will close this issue.
Branches
Planed to start   -   Planed to end
-
Top level
Priority
Duration (hours)
参与者(4)
5329419 openeuler ci bot 1632792936 9968373 openeuler survey bot 1637036855
C
1
https://toscode.gitee.com/openeuler/kernel.git
git@toscode.gitee.com:openeuler/kernel.git
openeuler
kernel
kernel

Search