Re: [PATCH 5.10 04/79] tty: n_gsm: avoid call of sleeping functions from atomic context

Pavel Machek
2022-09-14T12:38:42Z

[-- Attachment #1: Type: text/plain, Size: 1261 bytes --]

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
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]