From: Takashi Iwai <tiwai@suse.de>
To: Jeongjun Park <aha310510@gmail.com>
Cc: clemens@ladisch.de, perex@perex.cz, tiwai@suse.com,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] ALSA: usb-audio: fix race condition to UAF in snd_usbmidi_free
Date: Sat, 27 Sep 2025 10:01:37 +0200 [thread overview]
Message-ID: <87bjmwb9y6.wl-tiwai@suse.de> (raw)
In-Reply-To: <20250927044106.849247-1-aha310510@gmail.com>
On Sat, 27 Sep 2025 06:41:06 +0200,
Jeongjun Park wrote:
>
> The previous commit 0718a78f6a9f ("ALSA: usb-audio: Kill timer properly at
> removal") patched a UAF issue caused by the error timer.
>
> However, because the error timer kill added in this patch occurs after the
> endpoint delete, a race condition to UAF still occurs, albeit rarely.
>
> Therefore, to prevent this, the error timer must be killed before freeing
> the heap memory.
>
> Cc: <stable@vger.kernel.org>
> Fixes: 0718a78f6a9f ("ALSA: usb-audio: Kill timer properly at removal")
> Signed-off-by: Jeongjun Park <aha310510@gmail.com>
I suppose it's a fix for the recent syzbot reports?
https://lore.kernel.org/68d17f44.050a0220.13cd81.05b7.GAE@google.com
https://lore.kernel.org/68d38327.a70a0220.1b52b.02be.GAE@google.com
I had the very same fix in mind, as posted in
https://lore.kernel.org/87plbhn16a.wl-tiwai@suse.de
so I'll happily apply if that's the case (and it was verified to
work). I'm just back from vacation and trying to catch up things.
thanks,
Takashi
> ---
> sound/usb/midi.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/sound/usb/midi.c b/sound/usb/midi.c
> index acb3bf92857c..8d15f1caa92b 100644
> --- a/sound/usb/midi.c
> +++ b/sound/usb/midi.c
> @@ -1522,6 +1522,8 @@ static void snd_usbmidi_free(struct snd_usb_midi *umidi)
> {
> 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)
> @@ -1530,7 +1532,6 @@ static void snd_usbmidi_free(struct snd_usb_midi *umidi)
> 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-27 8:01 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-27 4:41 [PATCH] ALSA: usb-audio: fix race condition to UAF in snd_usbmidi_free Jeongjun Park
2025-09-27 8:01 ` Takashi Iwai [this message]
2025-09-27 8:48 ` Jeongjun Park
2025-09-27 9:39 ` Takashi Iwai
2025-09-27 9:19 ` 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=87bjmwb9y6.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=aha310510@gmail.com \
--cc=clemens@ladisch.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=stable@vger.kernel.org \
--cc=tiwai@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.