ALSA: timer: Don't take register_mutex with copy_from/to_user()
authorTakashi Iwai <tiwai@suse.de>
Fri, 21 Mar 2025 17:26:52 +0000 (18:26 +0100)
committerTakashi Iwai <tiwai@suse.de>
Fri, 21 Mar 2025 17:28:28 +0000 (18:28 +0100)
commit3424c8f53bc63c87712a7fc22dc13d0cc85fb0d6
tree0ab7e2e7f6d6d15ab38cbb66125adb10e24e3806
parente8e472d0c5a410227bbde2bba6eb0f428eaf761c
ALSA: timer: Don't take register_mutex with copy_from/to_user()

The infamous mmap_lock taken in copy_from/to_user() can be often
problematic when it's called inside another mutex, as they might lead
to deadlocks.

In the case of ALSA timer code, the bad pattern is with
guard(mutex)(&register_mutex) that covers copy_from/to_user() -- which
was mistakenly introduced at converting to guard(), and it had been
carefully worked around in the past.

This patch fixes those pieces simply by moving copy_from/to_user() out
of the register mutex lock again.

Fixes: 3923de04c817 ("ALSA: pcm: oss: Use guard() for setup")
Reported-by: syzbot+2b96f44164236dda0f3b@syzkaller.appspotmail.com
Closes: https://lore.kernel.org/67dd86c8.050a0220.25ae54.0059.GAE@google.com
Link: https://patch.msgid.link/20250321172653.14310-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/timer.c