mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Cen Zhang <zzzccc427@gmail.com>
Cc: perex@perex.cz, tiwai@suse.com, linux-sound@vger.kernel.org,
	linux-kernel@vger.kernel.org, baijiaju1990@gmail.com,
	jjzuming@gmail.com
Subject: Re: [PATCH] ALSA: jack: Pin the module while debugfs files are open
Date: Mon, 19 Oct 2026 16:27:11 +0200	[thread overview]
Message-ID: <8733u1ahq8.wl-tiwai@suse.de> (raw)
In-Reply-To: <pm-pmb-431ddb947e1a13b95d3a-v3-02d37dd7b4eb4774e100@gmail.com>

On Mon, 19 Oct 2026 12:30:54 +0200,
Cen Zhang wrote:
> 
> With CONFIG_SND=m and CONFIG_SND_JACK_INJECTION_DEBUG enabled, an in-tree
> HDA jack creates these debugfs files through snd_jack_new() and
> snd_jack_add_debugfs(). Their file_operations live in snd, but none sets
> .owner. full_proxy_open_regular() therefore takes no snd module reference
> when it calls fops_get(real_fops).
> 
> A debugfs descriptor can outlive removal of its HDA card. Once the card
> and dependent modules, including the OSS emulation modules, have been
> removed, snd can be unloaded while that descriptor is still open:
> 
>   Descriptor holder                   Card/module teardown
>   -----------------                   --------------------
>   open jack debugfs file
>     full_proxy_open_regular()
>       fops_get(real_fops)
>         owner == NULL: no snd pin
>   keep descriptor open
>                                       remove HDA card
>                                         snd_card_disconnect()
>                                           snd_jack_dev_disconnect()
>                                           remove debugfs nodes
>                                         snd_jack_dev_free()
>                                       unload dependent modules
>                                       rmmod snd
>                                         alsa_sound_exit()
>                                         free_module(): unmap snd
>   close descriptor
>     full_proxy_release()
>       read real_fops->release
>       fops_put(real_fops)
>         read real_fops->owner
> 
> debugfs_remove() drains active operations, but does not wait for idle
> open descriptors. Release deliberately bypasses removal protection and
> reads the real table even when no release callback is installed. The
> last close can therefore access unloaded snd storage.
> 
> Set .owner to THIS_MODULE in all six tables. The existing proxy
> fops_get()/fops_put() pair then keeps snd loaded through the final table
> access on close.
> 
> Fixes: 2d670ea2bd53 ("ALSA: jack: implement software jack injection via debugfs")
> Assisted-by: LLM
> Signed-off-by: Cen Zhang <zzzccc427@gmail.com>

Applied now.  Thanks.


Takashi

      reply	other threads:[~2026-10-19 14:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-19 10:30 Cen Zhang
2026-10-19 14:27 ` 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=8733u1ahq8.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=baijiaju1990@gmail.com \
    --cc=jjzuming@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.com \
    --cc=zzzccc427@gmail.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

all inboxes | Powered by JetHome®