ALSA: seq: Make ioctls race-free
authorTakashi Iwai <tiwai@suse.de>
Tue, 9 Jan 2018 22:11:03 +0000 (23:11 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 23 Jan 2018 18:57:04 +0000 (19:57 +0100)
commite4ff9f294629b65df3f7982cd4faf86b2856b9d7
tree6991c4a4b26b2bc1ed78f10aedebe90b3022a39f
parentd8a3170db0deca6bfee32ad77f492caba9f6791d
ALSA: seq: Make ioctls race-free

commit b3defb791b26ea0683a93a4f49c77ec45ec96f10 upstream.

The ALSA sequencer ioctls have no protection against racy calls while
the concurrent operations may lead to interfere with each other.  As
reported recently, for example, the concurrent calls of setting client
pool with a combination of write calls may lead to either the
unkillable dead-lock or UAF.

As a slightly big hammer solution, this patch introduces the mutex to
make each ioctl exclusive.  Although this may reduce performance via
parallel ioctl calls, usually it's not demanded for sequencer usages,
hence it should be negligible.

Reported-by: Luo Quan <a4651386@163.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/core/seq/seq_clientmgr.c
sound/core/seq/seq_clientmgr.h