]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
ALSA: usb-audio: Clear MIDI port active flag after draining
authorTakashi Iwai <tiwai@suse.de>
Wed, 20 Apr 2022 13:02:47 +0000 (15:02 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 22 Jun 2022 12:22:05 +0000 (14:22 +0200)
commita7415b0fc6c0a81a07481bab8dea6dc1a10cf13e
tree25c4fbb1f6460ef90c9d481aa9591f48ba685eee
parent99567dad57b8c0dce9d641a73117961aeb064105
ALSA: usb-audio: Clear MIDI port active flag after draining

BugLink: https://bugs.launchpad.net/bugs/1972905
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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
sound/usb/midi.c