]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
4.9-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Apr 2022 11:01:12 +0000 (13:01 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Apr 2022 11:01:12 +0000 (13:01 +0200)
added patches:
alsa-usb-audio-clear-midi-port-active-flag-after-draining.patch

queue-4.9/alsa-usb-audio-clear-midi-port-active-flag-after-draining.patch [new file with mode: 0644]
queue-4.9/series

diff --git a/queue-4.9/alsa-usb-audio-clear-midi-port-active-flag-after-draining.patch b/queue-4.9/alsa-usb-audio-clear-midi-port-active-flag-after-draining.patch
new file mode 100644 (file)
index 0000000..9fe5ece
--- /dev/null
@@ -0,0 +1,41 @@
+From 0665886ad1392e6b5bae85d7a6ccbed48dca1522 Mon Sep 17 00:00:00 2001
+From: Takashi Iwai <tiwai@suse.de>
+Date: Wed, 20 Apr 2022 15:02:47 +0200
+Subject: ALSA: usb-audio: Clear MIDI port active flag after draining
+
+From: Takashi Iwai <tiwai@suse.de>
+
+commit 0665886ad1392e6b5bae85d7a6ccbed48dca1522 upstream.
+
+When a rawmidi output stream is closed, it calls the drain at first,
+then does trigger-off only when the drain returns -ERESTARTSYS as a
+fallback.  It implies that each driver should turn off the stream
+properly after the drain.  Meanwhile, USB-audio MIDI interface didn't
+change the port->active flag after the drain.  This may leave the
+output work picking up the port that is closed right now, which
+eventually leads to a use-after-free for the already released rawmidi
+object.
+
+This patch fixes the bug by properly clearing the port->active flag
+after the output drain.
+
+Reported-by: syzbot+70e777a39907d6d5fd0a@syzkaller.appspotmail.com
+Cc: <stable@vger.kernel.org>
+Link: https://lore.kernel.org/r/00000000000011555605dceaff03@google.com
+Link: https://lore.kernel.org/r/20220420130247.22062-1-tiwai@suse.de
+Signed-off-by: Takashi Iwai <tiwai@suse.de>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ sound/usb/midi.c |    1 +
+ 1 file changed, 1 insertion(+)
+
+--- a/sound/usb/midi.c
++++ b/sound/usb/midi.c
+@@ -1210,6 +1210,7 @@ static void snd_usbmidi_output_drain(str
+               } while (drain_urbs && timeout);
+               finish_wait(&ep->drain_wait, &wait);
+       }
++      port->active = 0;
+       spin_unlock_irq(&ep->buffer_lock);
+ }
index 5d66d16eb518f2172ac6524914e5da4ae0247fc4..999d1fecf5b90f678e37f8e0bc3c4a88aab50008 100644 (file)
@@ -1,3 +1,4 @@
 etherdevice-adjust-ether_addr-prototypes-to-silence-wstringop-overead.patch
 mm-page_alloc-fix-building-error-on-werror-array-compare.patch
 gfs2-assign-rgrp-glock-before-compute_bitstructs.patch
+alsa-usb-audio-clear-midi-port-active-flag-after-draining.patch