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=1796385153; b=DI5QY60FvZedKuYGftOVeXx6kwNyQP3f6LbRGrNzYB3IxiY1Xwwiw53LOAcXM3sz8OIq /I7QY1q7nFsm2pVq7M2n4NFNru+jq6g1wU8g+2WvhB+Io4Dh3Svv106nTVudJhphJ6oMT S1JhNx12Vm1Bgfasqc5gMKn4dpbtzp681Hm/uwtx9r7VHVtQ5sPJyS2EwzVC3b2PMX4d6 BjzL3CDdIjh7q2uyHPO/A3L1Zx7IDMsn8rIY2zWtUZTkf6pqvEG+jvlOkq4RkBa7bys8i TstAYvReQ3dNNoi7VTklhCThvDbDQYpbrMQN4/Ex7V9yx+qYyoLWfBSMBPAyQnzXUFw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385153; 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=1GeRYYf+2sjnwx4jIwOSoa30BMBwPxbQF26VCvFAhNk=; b=QkrdoPzrqBRyBcmT6sMahPg1px+HdGeBekKTB7/ghdTBh/xUCGuJN4KP5Sv/kTcOAnuV UrJ67xY+e9uFZAo9fi2yaj3OOX+PNis52McFbsQHuR7nGypkYveSUHT9B1JVXQ3ITC+x8 53/x6abz2180xoptLCUCEx/08V3MpEEicjaFQ/nOTBdxRzc/bqOZap0rU+1mn2XjiRBBn bmRH2ataf8tsI1I6vXd7ceiqxHiSZD1kEMVkmIZVpShpT1ksGhFIh9kIBCExe3/P27SnO mg9QyhgKAxrSUUQdR+2/qcKZIkVLvyl2nKFbN3LtwkNoX+nXc65UTAHFTRMLtkpEXMQ== 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=rSTX+VTV; 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 A6468606A322; Fri, 4 Dec 2026 11:52:33 +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=rSTX+VTV Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24BB11F000C2; Fri, 4 Dec 2026 11:52:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385153; bh=1GeRYYf+2sjnwx4jIwOSoa30BMBwPxbQF26VCvFAhNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=rSTX+VTVHkQ/Zt9c974qicFDTJ3sYI37Qf/GbAiKF4HAJ00rwCMFOlD//keTAszmy zhDuL1fGPTchemVbhOvQuGf+UeSSazx6uxqSHrNA6JhstS0cHnzQhSEWl6uTRhXDJf J9oG0SAkYR33cryqNXSd15n3+TNB7iW2cusfZvh4= 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.6 0440/1167] ALSA: jack: Pin the module while debugfs files are open Date: Fri, 4 Dec 2026 18:57:47 +0900 Message-ID: <20261204100713.476934728@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@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.6-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: Context lines use this branch's .open = simple_open, style instead of upstream's tab-aligned members, and the added .owner = THIS_MODULE, lines match it. ] 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