Re: [PATCH V2] module: replace the mutex lock acquisition method

From: Rafael J. Wysocki
Date: Fri Feb 21 2025 - 15:08:49 EST


On Fri, Feb 21, 2025 at 1:35 PM Lizhi Xu <lizhi.xu@xxxxxxxxxxxxx> wrote:
>
> syzbot reported a deadlock in lock_system_sleep. [1]
>
> The write operation to "/sys/module/hibernate/parameters/compressor"
> conflicts with the registration of ieee80211 device, resulting in a deadlock
> in the lock param_lock.
>
> Since the conflict cannot be avoided, the way to obtain param_lock is changed
> to trylock to avoid deadlock.

An alternative way to avoid the deadlock would be to replace
lock_system_sleep() in hibernate_compressor_param_set() with
mutex_trylock(&system_transition_mutex) (and analogously for the
unlock operation). Why have you not done that?

It is arguably better to fail a write to the module param with -EBUSY
than to fail ieee80211_register_hw() IMV.