ALSA: seq: Fix race at closing in virmidi driver
authorTakashi Iwai <tiwai@suse.de>
Mon, 1 Feb 2016 11:06:42 +0000 (12:06 +0100)
committerSasha Levin <sasha.levin@oracle.com>
Mon, 15 Feb 2016 20:45:30 +0000 (15:45 -0500)
commit81bce29eec26617db18ff21543c7a091b5c10c92
tree37c4a7c1a4f5fea3dc50bfda4cfadb79d073868d
parentbd92b10c95b37a4d6c043ad76d51d13dee45c477
ALSA: seq: Fix race at closing in virmidi driver

[ Upstream commit 2d1b5c08366acd46c35a2e9aba5d650cb5bf5c19 ]

The virmidi driver has an open race at closing its assigned rawmidi
device, and this may lead to use-after-free in
snd_seq_deliver_single_event().

Plug the hole by properly protecting the linked list deletion and
calling in the right order in snd_virmidi_input_close().

BugLink: http://lkml.kernel.org/r/CACT4Y+Zd66+w12fNN85-425cVQT=K23kWbhnCEcMB8s3us-Frw@mail.gmail.com
Reported-by: Dmitry Vyukov <dvyukov@google.com>
Tested-by: Dmitry Vyukov <dvyukov@google.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
sound/core/seq/seq_virmidi.c