]> git.baikalelectronics.ru Git - kernel.git/commit
ALSA: seq: Break too long mutex context in the write loop
authorTakashi Iwai <tiwai@suse.de>
Mon, 15 Jul 2019 20:50:27 +0000 (22:50 +0200)
committerTakashi Iwai <tiwai@suse.de>
Tue, 16 Jul 2019 07:41:41 +0000 (09:41 +0200)
commitaf67e9e5ec0e03e53b440e3092e1e44e0079030f
treec4512b7219236a6268838215384de608eb3c992e
parent7149dc6a578aa159c5ae86f2c93b3b02b020f6c3
ALSA: seq: Break too long mutex context in the write loop

The fix for the racy writes and ioctls to sequencer widened the
application of client->ioctl_mutex to the whole write loop.  Although
it does unlock/relock for the lengthy operation like the event dup,
the loop keeps the ioctl_mutex for the whole time in other
situations.  This may take quite long time if the user-space would
give a huge buffer, and this is a likely cause of some weird behavior
spotted by syzcaller fuzzer.

This patch puts a simple workaround, just adding a mutex break in the
loop when a large number of events have been processed.  This
shouldn't hit any performance drop because the threshold is set high
enough for usual operations.

Fixes: 01bcdf17bb92 ("ALSA: seq: More protection for concurrent write and ioctl races")
Reported-by: syzbot+97aae04ce27e39cbfca9@syzkaller.appspotmail.com
Reported-by: syzbot+4c595632b98bb8ffcc66@syzkaller.appspotmail.com
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/seq/seq_clientmgr.c