From: Takashi Iwai <tiwai@suse.de>
To: Takashi Iwai <tiwai@suse.de>
Cc: Hanxiang Xu <xuhx@hust.edu.cn>, Takashi Iwai <tiwai@suse.com>,
Jaroslav Kysela <perex@perex.cz>,
linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: emu8000: sync the PCM emulation timer before freeing snd_emu8k_pcm (uaf from the in-flight softirq callback)
Date: Wed, 02 Dec 2026 09:52:44 +0100 [thread overview]
Message-ID: <87ld68xdwj.wl-tiwai@suse.de> (raw)
In-Reply-To: <87mrqoxe3x.wl-tiwai@suse.de>
On Wed, 02 Dec 2026 09:48:18 +0100,
Takashi Iwai wrote:
>
> On Tue, 01 Dec 2026 19:20:39 +0100,
> Hanxiang Xu wrote:
> >
> > The emu8000 PCM emulation drives its period handling from a timer
> > that re-arms itself every jiffie (emu8k_pcm_timer_func() ->
> > mod_timer() inside the rec->timer_lock section). Stopping the stream
> > uses the non-synchronizing timer_delete() (stop_voice()), which
> > cannot affect a callback instance that is already executing in
> > softirq context, and emu8k_pcm_close() then kfree()s rec with no
> > timer_delete_sync() and nothing stops a running instance from
> > re-arming. An in-flight emu8k_pcm_timer_func() therefore continues
> > on freed memory: it dereferences rec->emu, locks the freed
> > rec->timer_lock, writes rec->period_pos, re-arms the freed timer (a
> > ghost timer firing every tick), and reads rec->substream for
> > snd_pcm_period_elapsed(). stop_voice() runs under the stream
> > spinlock, so the sync cannot be added there - but close() is process
> > context.
> >
> > Gate the re-arm on rec->timer_running (under the rec->timer_lock that
> > stop_voice() already clears) and wait for an in-flight callback with
> > timer_delete_sync() before kfree(rec) in emu8k_pcm_close().
> >
> > Cc: <stable@vger.kernel.org>
> > Signed-off-by: Hanxiang Xu <xuhx@hust.edu.cn>
>
> Applied to for-next branch. Thanks.
.... then I noticed that you've submitted another conflicting patch
for this driver. So I have to drop this one again.
*PLEASE* don't submit patches in this style. Group a patch series and
use a thread if you submit a bunch of patches.
Takashi
prev parent reply other threads:[~2026-12-02 8:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 18:20 [PATCH] ALSA: emu8000: sync the PCM emulation timer before freeing snd_emu8k_pcm (uaf from the in-flight softirq callback) Hanxiang Xu
2026-12-02 8:48 ` Takashi Iwai
2026-12-02 8:52 ` 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=87ld68xdwj.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
--cc=xuhx@hust.edu.cn \
/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