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: emux: drain open hwdep users before freeing the emux structures
Date: Wed, 02 Dec 2026 10:04:04 +0100 [thread overview]
Message-ID: <87ecc0xddn.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261202101231.1-1-xuhx@hust.edu.cn>
On Wed, 02 Dec 2026 03:12:31 +0100,
Hanxiang Xu wrote:
>
> Opening a hwdep device of the emux wavetable pins only the base-card
> module; the emux hwdep registers no open/release hooks, so an open fd
> keeps file->private_data pointing at the struct snd_hwdep and in-flight
> ioctls keep running against the emux structures while the sub-driver
> removal (rmmod snd_emu10k1_synth, or unbind which bypasses module
> refcounts) kfrees the hwdep, the soundfont list and the struct snd_emux
> itself -- snd_hwdep_ioctl() holds no open_mutex and
> snd_hwdep_dev_disconnect() neither checks hwdep->used nor revokes f_op
> (dynamically confirmed on v7.4-rc5, 113 UAF reports).
>
> Register hwdep open/release hooks that account for the fd with
> snd_emux_inc_count()/snd_emux_dec_count() -- which also pins the
> sub-driver module like the sequencer and OSS-sequencer paths -- and
> make snd_emux_free() wait until all hwdep users are gone before
> tearing anything down, mirroring the drain snd_card_disconnect()
> performs for whole-card removal.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Hanxiang Xu <xuhx@hust.edu.cn>
This could be replaced simply with a call of snd_card_file_sync(card,
hwdep), instead? Also it can be covered similarly for vmidi rawmidi
in emux code, too. Just add those before snd_device_free() calls.
Takashi
prev parent reply other threads:[~2026-12-02 9:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 2:12 [PATCH] ALSA: emux: drain open hwdep users before freeing the emux structures Hanxiang Xu
2026-12-02 9:04 ` 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=87ecc0xddn.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