From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387942; b=G9J16T63L7p4eg8a7FuxQs9CtMcTdOeX9Blv+y/y/9tY4jV4BryHeNPBChU/ouSVKSAR kkEdoK2tVe7DPlt50xDwMiyxXm+2CEMnAbmNWD8HDeTfMCl/z629PzSHzQJgdhHGueph6 RVd/h26bHIYMOQ+6jL1bMSCzOyTn6cbw4BhnubyzK4ke2JxoWBbHfaATNLnnAZbfg3vX+ lpb7E5k5YO25ls0uXFsZRwufqmgRWeM8wiJfrdPXc+YDb5Mot+6BaSqDgX41NDFpnQv8P F4yveklCL/Cd28wJOIBtIyo4uekz3eE8X5n8zm38Gc663KuMPTvr9Tq1Rb6EV89jZ7A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387942; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=nB4Htrz1eeztg4oAS9MHoxNtzkfQ/KN0kO+fYPiQH+g=; b=qLCfZFec3C8uehu5+jFdwbUqy6xhD6URpK8dlPFPAGjwDckoOQnSCq6gDRaySTaaHHwe yNrK756dkwjFxs3zvFNAxJiHpHbl1X55Wwu/0EfMZUktZYetKUie0nQ4AV+dE0YDN2jVA juEKehxo+2x0sLaCZX9V5KBuBheX4eRxWeMi3KiALKlxZSncyaWmmu7MH4XsInUvrvvFD m6ga32HI31DS5sepb63FKEKS0HWSlFAhka74JO8kwJhCKl04r8NmxURJqKGoZmxQG6Duf RHxaxdmqK1S08Uh11qTtMQgOlVhQwczRkFgjWQbzijMRtyMlqGj0sLfLqCCXZveXgfw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b3NxIuF4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FE3B606A683; Fri, 4 Dec 2026 12:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=b3NxIuF4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 89D171F00933; Fri, 4 Dec 2026 12:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387941; bh=nB4Htrz1eeztg4oAS9MHoxNtzkfQ/KN0kO+fYPiQH+g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=b3NxIuF4YW+RLs7NxQdYOEKWttAvhw7lA+nmdhLt4MpYrxT+OYWd8shLphhgWv2PR hb9f+dCSIQH5WojM8WgWgGYveo5f5viyxZfxVMuoDlnPqmHhkKTL+4fSIX1aH2Rk/A zQ+E8E4b2pmHoXMwms1DCfeqTe4eO8EKKYLlKhUg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Cen Zhang , Takashi Iwai , Sasha Levin Subject: [PATCH 6.1 0422/1059] ALSA: jack: Pin the module while debugfs files are open Date: Fri, 4 Dec 2026 18:59:13 +0900 Message-ID: <20261204100655.262894726@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cen Zhang [ Upstream commit 8b479b265301e97bfbec0ef25de1c1f7eb4d2f74 ] 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 Link: https://patch.msgid.link/pm-pmb-431ddb947e1a13b95d3a-v3-02d37dd7b4eb4774e100@gmail.com Signed-off-by: Takashi Iwai [ sashal: adjusted context to match this tree's single-space style (.open = simple_open,) instead of tab-aligned, and added .owner = THIS_MODULE, to the six file_operations tables. ] Signed-off-by: Sasha Levin --- sound/core/jack.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/core/jack.c b/sound/core/jack.c index d5b4330747f22..5147ab8cf9263 100644 --- a/sound/core/jack.c +++ b/sound/core/jack.c @@ -307,6 +307,7 @@ static ssize_t jack_type_read(struct file *file, } static const struct file_operations jack_type_fops = { + .owner = THIS_MODULE, .open = simple_open, .read = jack_type_read, .llseek = default_llseek, @@ -314,6 +315,7 @@ static const struct file_operations jack_type_fops = { #endif static const struct file_operations sw_inject_enable_fops = { + .owner = THIS_MODULE, .open = simple_open, .read = sw_inject_enable_read, .write = sw_inject_enable_write, @@ -321,24 +323,28 @@ static const struct file_operations sw_inject_enable_fops = { }; static const struct file_operations jackin_inject_fops = { + .owner = THIS_MODULE, .open = simple_open, .write = jackin_inject_write, .llseek = default_llseek, }; static const struct file_operations jack_kctl_id_fops = { + .owner = THIS_MODULE, .open = simple_open, .read = jack_kctl_id_read, .llseek = default_llseek, }; static const struct file_operations jack_kctl_mask_bits_fops = { + .owner = THIS_MODULE, .open = simple_open, .read = jack_kctl_mask_bits_read, .llseek = default_llseek, }; static const struct file_operations jack_kctl_status_fops = { + .owner = THIS_MODULE, .open = simple_open, .read = jack_kctl_status_read, .llseek = default_llseek, -- 2.53.0