projects
/
GitHub
/
mt8127
/
android_kernel_alcatel_ttab.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
4df6314
)
ALSA: seq: Fix race at closing in virmidi driver
author
Takashi Iwai
<tiwai@suse.de>
Mon, 1 Feb 2016 11:06:42 +0000
(12:06 +0100)
committer
Greg Kroah-Hartman
<gregkh@linuxfoundation.org>
Fri, 19 Feb 2016 22:22:39 +0000
(14:22 -0800)
commit
2d1b5c08366acd46c35a2e9aba5d650cb5bf5c19
upstream.
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>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/core/seq/seq_virmidi.c
patch
|
blob
|
blame
|
history
diff --git
a/sound/core/seq/seq_virmidi.c
b/sound/core/seq/seq_virmidi.c
index 4b50e604276d8dec6adb47bee6b870a1fe52f8c0..0fa691e013849e308d66cbf59a54a5b71f190aa1 100644
(file)
--- a/
sound/core/seq/seq_virmidi.c
+++ b/
sound/core/seq/seq_virmidi.c
@@
-254,9
+254,13
@@
static int snd_virmidi_output_open(struct snd_rawmidi_substream *substream)
*/
static int snd_virmidi_input_close(struct snd_rawmidi_substream *substream)
{
+ struct snd_virmidi_dev *rdev = substream->rmidi->private_data;
struct snd_virmidi *vmidi = substream->runtime->private_data;
- snd_midi_event_free(vmidi->parser);
+
+ write_lock_irq(&rdev->filelist_lock);
list_del(&vmidi->list);
+ write_unlock_irq(&rdev->filelist_lock);
+ snd_midi_event_free(vmidi->parser);
substream->runtime->private_data = NULL;
kfree(vmidi);
return 0;