]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: usb: Fix UAF at delayed release of MIDI2 EPs
authorTakashi Iwai <tiwai@suse.de>
Sat, 8 Aug 2026 15:20:06 +0000 (17:20 +0200)
committerTakashi Iwai <tiwai@suse.de>
Sat, 8 Aug 2026 15:51:43 +0000 (17:51 +0200)
The recent fix for UAF in ump_to_endpoint() caused another UAF because
it tries to dereference the UMP endpoint object, but this might be
executed at a delayed context where the endpoint has been already
released.

Add private_free to clear the associated data for avoiding the further
dereference for delayed releases.

Fixes: 4a05b2d1b464 ("ALSA: usb-audio: fix use-after-free in ump_to_endpoint()")
Reported-by: syzbot+565b1138cfbe549d4422@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=565b1138cfbe549d4422
Cc: <stable@vger.kernel.org>
Link: https://patch.msgid.link/20260808152009.1947835-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/usb/midi2.c

index 83980fb83ac84b86e4dcae8d1c634ed4ff1d12ae..1dc78f536ef937fe33776b8236b569da5769b16e 100644 (file)
@@ -677,6 +677,14 @@ static int parse_midi_2_0_endpoints(struct snd_usb_midi2_interface *umidi)
        return 0;
 }
 
+static void free_ump_private_data(struct snd_ump_endpoint *ump)
+{
+       struct snd_usb_midi2_ump *rmidi = ump->private_data;
+
+       if (rmidi)
+               rmidi->ump = NULL;
+}
+
 static void free_all_midi2_umps(struct snd_usb_midi2_interface *umidi)
 {
        struct snd_usb_midi2_ump *rmidi;
@@ -727,6 +735,7 @@ static int create_midi2_ump(struct snd_usb_midi2_interface *umidi,
 
        ump->private_data = rmidi;
        ump->ops = &snd_usb_midi_v2_ump_ops;
+       ump->private_free = free_ump_private_data;
 
        rmidi->eps[STR_IN] = ep_in;
        rmidi->eps[STR_OUT] = ep_out;