All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Hanxiang Xu <xuhx@hust.edu.cn>
Cc: 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: pin the module while an emu8k PCM runtime  exists
Date: Wed, 02 Dec 2026 09:48:05 +0100	[thread overview]
Message-ID: <87o6b4xe4a.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261202021939.1-1-xuhx@hust.edu.cn>

On Tue, 01 Dec 2026 19:19:39 +0100,
Hanxiang Xu wrote:
> 
> snd_emu8000_pcm_new() creates a PCM device on the host sound card
> from the snd_emu8000_synth seq driver, and snd_emu8000_remove() frees
> it again with snd_device_free(dev->card, hw->pcm) unconditionally.
> An fd on /dev/snd/pcmC*D1p only pins the host card module
> (try_module_get(pcm->card->module) in snd_pcm_open), so
> `rmmod snd_emu8000_synth` runs snd_emu8000_remove() while the fd is
> open: snd_pcm_dev_disconnect() stops the streams and unregisters the
> device, snd_pcm_free() kfrees every substream and the snd_pcm itself,
> and the fd's final close() then walks the freed pcm_file->substream,
> substream->pcm and pcm->open_mutex (and calls substream->ops->close,
> which points into the unloaded module).
> 
> Pin snd-emu8000-synth with try_module_get(THIS_MODULE) in
> emu8k_pcm_open() and drop it in emu8k_pcm_close(), so `rmmod` returns
> EBUSY instead of running snd_emu8000_remove() under an open fd.
> 
> Also reproduced on 7.4.0-rc5: 12 reports (slab-use-after-free in
> snd_pcm_release, slab-out-of-bounds in snd_power_ref_and_wait) with a
> KASAN kernel; orderly teardown without an open fd is clean.
> 
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Hanxiang Xu <xuhx@hust.edu.cn>

Although this doesn't cover fully, it's still a bit of improvement on
safety, so I applied to for-next branch now.


thanks,

Takashi

      parent reply	other threads:[~2026-12-02  8:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 18:19 [PATCH] ALSA: emu8000: pin the module while an emu8k PCM runtime exists Hanxiang Xu
2026-12-02  2:57 ` sashiko-bot
2026-12-02  8:48 ` 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=87o6b4xe4a.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 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.