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: hwdep: do not free a still-open hwdep on single-device teardown
Date: Wed, 02 Dec 2026 09:58:05 +0100 [thread overview]
Message-ID: <87h5gwxdnm.wl-tiwai@suse.de> (raw)
In-Reply-To: <20261202100703.1-1-xuhx@hust.edu.cn>
On Wed, 02 Dec 2026 03:07:03 +0100,
Hanxiang Xu wrote:
>
> An independent teardown path calls snd_device_free(card, hwdep),
> which runs snd_hwdep_free(): it kfrees the struct snd_hwdep without
> waiting for hwdep->used to drop. Open descriptors keep
> file->private_data pointing at the freed object with the real hwdep
> f_ops, and their in-flight or later operations (ioctl/read/poll and
> the final close) are use-after-frees. The card-wide path swaps
> file->f_op for stub operations, but a single-device teardown never
> runs it.
>
> Refuse the free while hwdep->used is non-zero: __snd_device_free()
> still unlinks the snd_device wrapper, so the card never revisits the
> device, and the object stays valid for the open descriptors.
>
> Cc: <stable@vger.kernel.org>
> Signed-off-by: Hanxiang Xu <xuhx@hust.edu.cn>
This is no-no. You need a synchronization before release, instead.
Takashi
prev parent reply other threads:[~2026-12-02 8:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 2:07 Hanxiang Xu
2026-12-02 8:58 ` 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=87h5gwxdnm.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
all inboxes | Powered by JetHome®