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=1793826929; b=b7aWJezRwUiWDj3ClN5+KiqnOORVCwbZ8FhO7JikPP7oXALZ4dP7U4izuWP/wUe4VJxG oyfm+1PudBO3KeGQZSGVotEDCweiZm0jbbnVJmJx8JifonQ1QS7jLwNaH+UNVufuRt7Qs /+/XKSsy5E1B/yOhv+9Tt/wYsJoXD2rVQjoYtLkOt5QkRXu8IZQNMHRjSDvSg8nlBC3CN SoVxZZe1rTr17XYUj73w0/z79u3DDcZO07Gcm456Q1JTzfpfIMRApxlgehuDKJwS+ef3u RHYD8LnTnfpuqga1nlD9vNGUBZCITHBe/Huww4TYgNRZ5Ig8Nm8XKJJAJI5S7qSrOyw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793826929; 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=ZteNeQvOOP7aTgWn38NYMp6bHNYAJL6TgX+o6+BEYp4=; b=CCPwuRMPB8m5E2plN4mNLtkxRN3wNKCJCg4zM5DWKs9tx5mEACcDBtMSNh4IQNH3aglP l9AjnUTZrvwDJ8TCJ1+PuyYqasPR5Hx0HZ4Nppr+lSYxQarWKhaxLhzXdhUx+LmCvLMhB doJFg/F5hIDpeuFYc2cbxM8ipu/OMGjM8K3brC+Dy1w5y3CJ4XMnN1DE/M62c+/opO+J9 KeqRBR8GbuL8NMYIgoynZGuiSA3GXQRhAtdL0TlROPdVVZKlAeCSQ1z8VJN8eQSgewuKX YTONwP8SAk2DoiCznYanY1RQtdWzD0cHYc04prFInRoHyUyZDKABSdGSaKcoIt/6W+g== 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=VWFVfwSm; 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 098E46072FA3; Wed, 4 Nov 2026 21:15:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=VWFVfwSm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 861431F00A02; Wed, 4 Nov 2026 21:15:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793826928; bh=ZteNeQvOOP7aTgWn38NYMp6bHNYAJL6TgX+o6+BEYp4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VWFVfwSmuAuufhMD4jw+ebwUG3YuizhSYsLiRPq6iolLU0E7k5uBXs8mySm6LcMW3 5ungo/Eg+FdaLaubPN8A2po9Vbk/wctyrKZPK55x4nCP6OrQKett+frgZ2ibTYdw07 U0XQRLWj3loyyFFccbdQhxpYeyqt5jY38SfaZEZg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Fredric Cover , Paulo Alcantara Subject: [PATCH 7.3 090/547] smb: client: fix early procfs exposure race Date: Wed, 4 Nov 2026 16:04:34 -0500 Message-ID: <20261104211040.785045537@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261104211038.406938024@linuxfoundation.org> References: <20261104211038.406938024@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.3-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fredric Cover commit 7b1afb631395c958993cda4631002258ef4151ea upstream. Currently, init_cifs() calls cifs_proc_init() near the beginning of the function, before INIT_LIST_HEAD, leading to a momentarily uninitialized, but exposed, procfs. If a userspace process reads this empty procfs, iterating over a zeroed list_head leads to a NULL pointer dereference and a kernel oops/panic. For example, if a delay is added between cifs_proc_init() and INIT_LIST_HEAD, and a userspace process is polling /proc/fs/cifs/DebugData, the following oops occurs: BUG: kernel NULL pointer dereference, address: 0000000000000608 Oops: Oops: 0000 [#1] SMP PTI CPU: 0 UID: 0 PID: 3477 Comm: cat Not tainted 7.3.0-02212-g4df4d2a577db-dirty #6 PREEMPT(lazy) RIP: 0010:cifs_debug_data_proc_show+0x103/0xd80 [cifs] Call Trace: ? seq_read_iter+0x86/0x400 ? seq_read_iter+0x86/0x400 seq_read_iter+0x183/0x400 proc_reg_read_iter+0x62/0x90 copy_splice_read+0x215/0x310 splice_file_to_pipe+0xec/0x1c0 do_splice+0x4b8/0x780 __se_sys_splice+0x18f/0x250 do_syscall_64+0x109/0x330 entry_SYSCALL_64_after_hwframe+0x77/0x7f Fix this by moving cifs_proc_init() down in init_cifs(), ensuring it runs only after all internal lists, locks, counters, and workqueues are fully ready, but before registering the filesystem. Update the error cleanup ladder and exit_cifs() to maintain proper LIFO order. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Fredric Cover Cc: stable@vger.kernel.org Signed-off-by: Paulo Alcantara Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/cifsfs.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) --- a/fs/smb/client/cifsfs.c +++ b/fs/smb/client/cifsfs.c @@ -2021,7 +2021,6 @@ init_cifs(void) if (rc) return rc; - cifs_proc_init(); INIT_LIST_HEAD(&cifs_tcp_ses_list); /* * Initialize Global counters @@ -2070,10 +2069,8 @@ init_cifs(void) cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE | WQ_MEM_RECLAIM | WQ_PERCPU, 0); - if (!cifsiod_wq) { - rc = -ENOMEM; - goto out_clean_proc; - } + if (!cifsiod_wq) + return -ENOMEM; /* * Consider in future setting limit!=0 maybe to min(num_of_cores - 1, 3) @@ -2164,19 +2161,22 @@ init_cifs(void) if (rc) goto out_cifs_swn_init; + cifs_proc_init(); + rc = register_filesystem(&cifs_fs_type); if (rc) - goto out_init_cifs_idmap; + goto out_clean_proc; rc = register_filesystem(&smb3_fs_type); if (rc) { unregister_filesystem(&cifs_fs_type); - goto out_init_cifs_idmap; + goto out_clean_proc; } return 0; -out_init_cifs_idmap: +out_clean_proc: + cifs_proc_clean(); exit_cifs_idmap(); out_cifs_swn_init: #ifdef CONFIG_CIFS_SWN_UPCALL @@ -2212,8 +2212,6 @@ out_destroy_decrypt_wq: destroy_workqueue(decrypt_wq); out_destroy_cifsiod_wq: destroy_workqueue(cifsiod_wq); -out_clean_proc: - cifs_proc_clean(); return rc; } @@ -2223,6 +2221,7 @@ exit_cifs(void) cifs_dbg(NOISY, "exit_smb3\n"); unregister_filesystem(&cifs_fs_type); unregister_filesystem(&smb3_fs_type); + cifs_proc_clean(); cifs_release_automount_timer(); exit_cifs_idmap(); #ifdef CONFIG_CIFS_SWN_UPCALL @@ -2245,7 +2244,6 @@ exit_cifs(void) destroy_workqueue(serverclose_wq); destroy_workqueue(cfid_put_wq); destroy_workqueue(cifsiod_wq); - cifs_proc_clean(); } MODULE_AUTHOR("Steve French");