From: Takashi Iwai <tiwai@suse.de>
To: moonafterrain@outlook.com
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, Yuhao Jiang <danisjiang@gmail.com>
Subject: Re: [PATCH] ALSA: wavefront: Fix use-after-free in MIDI operations
Date: Wed, 05 Nov 2025 09:41:04 +0100 [thread overview]
Message-ID: <87qzuchnxb.wl-tiwai@suse.de> (raw)
In-Reply-To: <SYBPR01MB78812BAD18C71593392C2C31AFC4A@SYBPR01MB7881.ausprd01.prod.outlook.com>
On Tue, 04 Nov 2025 15:11:55 +0100,
moonafterrain@outlook.com wrote:
>
> From: Junrui Luo <moonafterrain@outlook.com>
>
> Clear substream pointers in close functions to prevent use-after-free
> when timer callbacks or interrupt handlers access them after close.
There can be no actual access done because MPU401_MODE_INPUT_TRIGGER
is guaranteed to be off before closing the stream. That is, the
variable stream is assigned to an old pointer, but it's not accessed.
So, this is not really a use-after-free bug, per se.
Other than that, the fix itself looks good. Please resubmit after
rephrasing the patch description.
thanks,
Takashi
> Reported-by: Yuhao Jiang <danisjiang@gmail.com>
> Reported-by: Junrui Luo <moonafterrain@outlook.com>
> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> Cc: stable@vger.kernel.org
> Signed-off-by: Junrui Luo <moonafterrain@outlook.com>
> ---
> sound/isa/wavefront/wavefront_midi.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/sound/isa/wavefront/wavefront_midi.c b/sound/isa/wavefront/wavefront_midi.c
> index 1250ecba659a..69d87c4cafae 100644
> --- a/sound/isa/wavefront/wavefront_midi.c
> +++ b/sound/isa/wavefront/wavefront_midi.c
> @@ -278,6 +278,7 @@ static int snd_wavefront_midi_input_close(struct snd_rawmidi_substream *substrea
> return -EIO;
>
> guard(spinlock_irqsave)(&midi->open);
> + midi->substream_input[mpu] = NULL;
> midi->mode[mpu] &= ~MPU401_MODE_INPUT;
>
> return 0;
> @@ -300,6 +301,7 @@ static int snd_wavefront_midi_output_close(struct snd_rawmidi_substream *substre
> return -EIO;
>
> guard(spinlock_irqsave)(&midi->open);
> + midi->substream_output[mpu] = NULL;
> midi->mode[mpu] &= ~MPU401_MODE_OUTPUT;
> return 0;
> }
> --
> 2.51.1.dirty
>
prev parent reply other threads:[~2025-11-05 8:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 14:11 [PATCH] ALSA: wavefront: Fix use-after-free in MIDI operations moonafterrain
2025-11-05 8:41 ` Takashi Iwai [this message]
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=87qzuchnxb.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=danisjiang@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=moonafterrain@outlook.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox