From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+f02665daa2abeef4a947@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [sound?] [usb?] general protection fault in snd_usbmidi_do_output
Date: Tue, 23 Sep 2025 15:39:34 +0800 [thread overview]
Message-ID: <20250923073935.7486-1-hdanton@sina.com> (raw)
In-Reply-To: <68d17f44.050a0220.13cd81.05b7.GAE@google.com>
> Date: Mon, 22 Sep 2025 09:54:28 -0700 [thread overview]
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 3b08f56fbbb9 Merge tag 'x86-urgent-2025-09-20' of git://gi..
> git tree: upstream
> console output: https://syzkaller.appspot.com/x/log.txt?x=176950e2580000
> kernel config: https://syzkaller.appspot.com/x/.config?x=927198eca77e75d9
> dashboard link: https://syzkaller.appspot.com/bug?extid=f02665daa2abeef4a947
> compiler: gcc (Debian 12.2.0-14+deb12u1) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=14006712580000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14e950e2580000
#syz test upstream master
--- x/sound/usb/midi.c
+++ y/sound/usb/midi.c
@@ -307,6 +307,8 @@ static void snd_usbmidi_do_output(struct
for (;;) {
if (!(ep->active_urbs & (1 << urb_index))) {
urb = ep->urbs[urb_index].urb;
+ if (!urb)
+ goto next;
urb->transfer_buffer_length = 0;
ep->umidi->usb_protocol_ops->output(ep, urb);
if (urb->transfer_buffer_length == 0)
@@ -319,6 +321,7 @@ static void snd_usbmidi_do_output(struct
break;
ep->active_urbs |= 1 << urb_index;
}
+ next:
if (++urb_index >= OUTPUT_URBS)
urb_index = 0;
if (urb_index == ep->next_urb)
@@ -1396,13 +1399,19 @@ static int snd_usbmidi_in_endpoint_creat
static void snd_usbmidi_out_endpoint_clear(struct snd_usb_midi_out_endpoint *ep)
{
unsigned int i;
+ unsigned long flags;
+ spin_lock_irqsave(&ep->buffer_lock, flags);
for (i = 0; i < OUTPUT_URBS; ++i)
if (ep->urbs[i].urb) {
- free_urb_and_buffer(ep->umidi, ep->urbs[i].urb,
- ep->max_transfer);
+ struct urb *urb = ep->urbs[i].urb;
+
ep->urbs[i].urb = NULL;
+ spin_unlock_irqrestore(&ep->buffer_lock, flags);
+ free_urb_and_buffer(ep->umidi, urb, ep->max_transfer);
+ spin_lock_irqsave(&ep->buffer_lock, flags);
}
+ spin_unlock_irqrestore(&ep->buffer_lock, flags);
}
static void snd_usbmidi_out_endpoint_delete(struct snd_usb_midi_out_endpoint *ep)
@@ -1522,15 +1531,23 @@ static void snd_usbmidi_free(struct snd_
{
int i;
+ timer_shutdown_sync(&umidi->error_timer);
for (i = 0; i < MIDI_MAX_ENDPOINTS; ++i) {
struct snd_usb_midi_endpoint *ep = &umidi->endpoints[i];
- if (ep->out)
+ int j;
+
+ if (ep->out) {
+ for (j = 0; j < OUTPUT_URBS; ++j)
+ usb_kill_urb(ep->out->urbs[j].urb);
snd_usbmidi_out_endpoint_delete(ep->out);
- if (ep->in)
+ }
+ if (ep->in) {
+ for (j = 0; j < INPUT_URBS; ++j)
+ usb_kill_urb(ep->in->urbs[j]);
snd_usbmidi_in_endpoint_delete(ep->in);
+ }
}
mutex_destroy(&umidi->mutex);
- timer_shutdown_sync(&umidi->error_timer);
kfree(umidi);
}
--
next prev parent reply other threads:[~2025-09-23 7:40 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-22 16:54 [syzbot] [sound?] [usb?] general protection fault in snd_usbmidi_do_output syzbot
2025-09-22 23:17 ` [PATCH 1/1] ALSA: usb-audio: Avoid NULL dereference in snd_usbmidi_do_output() Brahmajit Das
2025-09-23 2:40 ` Alan Stern
2025-09-23 6:16 ` Takashi Iwai
2025-09-23 0:48 ` [syzbot] [sound?] [usb?] general protection fault in snd_usbmidi_do_output Hillf Danton
2025-09-23 2:22 ` syzbot
2025-09-23 7:39 ` Hillf Danton [this message]
2025-09-23 9:48 ` syzbot
-- strict thread matches above, loose matches on Subject: below --
2025-09-27 9:19 [PATCH] ALSA: usb-audio: fix race condition to UAF in snd_usbmidi_free Hillf Danton
2025-09-27 10:03 ` [syzbot] [sound?] [usb?] general protection fault in snd_usbmidi_do_output syzbot
2025-09-27 10:29 ` Takashi Iwai
2025-09-27 10:55 ` syzbot
2025-09-27 11:53 ` Takashi Iwai
2025-09-27 14:30 ` syzbot
2025-09-27 15:50 ` Jeongjun Park
2025-09-27 16:17 ` syzbot
2025-09-27 10:36 ` Jeongjun Park
2025-09-27 11:52 ` Takashi Iwai
2025-09-27 12:15 ` Jeongjun Park
2025-09-27 15:41 ` Jeongjun Park
2025-09-27 16:07 ` Takashi Iwai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250923073935.7486-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+f02665daa2abeef4a947@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox