Hi!
From: Fedor Pchelkin pchelkin@ispras.ru
commit 902e02ea9385373ce4b142576eef41c642703955 upstream.
Syzkaller reports the following problem:
BUG: sleeping function called from invalid context at kernel/printk/printk.c:2347 in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 1105, name: syz-executor423 3 locks held by syz-executor423/1105:
Does this happen in 5.10, too? printk locking changed significantly in recent years.
The problem happens in the following control flow:
gsmld_write(...) spin_lock_irqsave(&gsm->tx_lock, flags) // taken a spinlock on TX data con_write(...) do_con_write(...) console_lock() might_sleep() // -> bug
As far as console_lock() might sleep it should not be called with spinlock held.
Ok.
The patch replaces tx_lock spinlock with mutex in order to avoid the problem.
Are you sure you can do that? Original code disabled interrupts, because parts of protected data were accessed from interrupt context, and you simply removed that protection.
Best regards, Pavel