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=1796385179; b=xgAVb6QtK7Uz4xXzshSjGQdbZSSipai6BsmHyo550FJ69v/ybs2Cr09hh1Cn+KSKuMWp aZ1gtt5xRLbwRHRNTUUqBizoNx9qp3yGJXYPs/0IOEffRRKrvSRoyIaP9joseYc5HRs7x U9axHUNaopgRG0EdfIihkyW3h7yBUjma+mGJ+YoHdIw0+XfjNRkrGyGUflsW44Z7fcyMb NIXluMFWwslpAfHEiLN3JormO+By535cLgOt7LPI3dCieNxfjuSmjYj/4kOND4ttksH33 6eqT3tYw7rcP+hm59XbsifNxFg2jItZ2+x16okeMY39dLiA21I/vtuQiLAas0ZzJibw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385179; 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=9LFQOJW4jn8VoGYFmUpc8yyqaLK7nPfMngO/OFs62BA=; b=XGG0/ghcpKb8qR1eRmRgNPwsvuYU1bb3S1UFLFaWj+OJK9ei5HlYvFwyvokGrYC/If6r iw5CdIQ/DbCT8/QgzwJyoWMJ2X9mQqTeHaMBRmkCfgMU9ej9dCHGZtrvvnsb4XpIadj9P PaFz9hHIG4bZL9ntABZuhn7FQyH21yTCZ2Zb77izIfNxX0dvGAr2YoriGQMDZTudYi5Dh ooD6XbD1negddDf4UKxWTS7Ta9S3pIAY1ARs6/p1fAVYsfWFObl5aimaZMtQoUgK875+I 6AXRe5e66PkYpKnxS8GZyUQm2Z6NVc+G5tFXAYKQTVFO++NU/yhVzFEH/1AwLh/P5hA== 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=Dt8WH7tn; 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 E570A606A322; Fri, 4 Dec 2026 11:52:58 +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=Dt8WH7tn Received: by smtp.kernel.org (Postfix) with ESMTPSA id 287FC1F000CE; Fri, 4 Dec 2026 11:52:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385178; bh=9LFQOJW4jn8VoGYFmUpc8yyqaLK7nPfMngO/OFs62BA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Dt8WH7tnX54dMoikwA0HbrYypo0Bzt3oyctL8FhS4ETWuY/pNUnTrhabwhNPMFAwc eFcsRAMaT7uaFcD8DmwFkonIEJh3K+3URdgXynfbDFEeQQiwuSMewSAhO4yv3MV+6R d4mtzcmIb4ehSX4nEgVKLmX92udUitqhb9o8L6Hg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Sashiko , Henry Hu , Namjae Jeon , Sasha Levin Subject: [PATCH 6.6 0450/1167] ksmbd: fix iface_list use-after-free during server reset Date: Fri, 4 Dec 2026 18:57:57 +0900 Message-ID: <20261204100713.735263272@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: Henry Hu [ Upstream commit d34d38ab0c62fe4eb9e746420c554e6d0e6f54db ] ksmbd_find_netdev_name_iface_list() walks iface_list for fsctl_query_iface_info_ioctl(), which holds RTNL. But during server reset, ksmbd_tcp_destroy() unlinks and frees the entries without RTNL, and queued SMB requests can still be running at that point. So an FSCTL_QUERY_NETWORK_INTERFACE_INFO request can therefore race with interface destruction and dereference a freed entry. With debug-only instrumentation to make the race deterministic, KASAN reports: BUG: KASAN: slab-use-after-free in ksmbd_find_netdev_name_iface_list ksmbd_find_netdev_name_iface_list fsctl_query_iface_info_ioctl smb2_ioctl handle_ksmbd_work Freed by: kfree ksmbd_tcp_destroy ksmbd_conn_transport_destroy kill_server_store The fix is to detach iface_list to a temporary list under RTNL, then drop RTNL before cleanup because the following cleanup may block and hold RTNL for a long time. Fixes: b2d99376c5d6 ("ksmbd: browse interfaces list on FSCTL_QUERY_INTERFACE_INFO IOCTL") Reported-by: Sashiko Link: https://sashiko.dev/#/patchset/20260911163516.6403-1-15815827059%40163.com Assisted-by: LLM Signed-off-by: Henry Hu Signed-off-by: Namjae Jeon [ sashal: Dropped the ksmbd_tcp_stop_listener() context line from the ksmbd_tcp_destroy() hunk, since that helper doesn't exist here; the rest of the fix is unchanged. ] Signed-off-by: Sasha Levin --- fs/smb/server/transport_tcp.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/smb/server/transport_tcp.c b/fs/smb/server/transport_tcp.c index 31a241043fb46..8d12b26c94b33 100644 --- a/fs/smb/server/transport_tcp.c +++ b/fs/smb/server/transport_tcp.c @@ -681,10 +681,15 @@ static void tcp_stop_kthread(struct task_struct *kthread) void ksmbd_tcp_destroy(void) { struct interface *iface, *tmp; + LIST_HEAD(iface_list_to_free); unregister_netdevice_notifier(&ksmbd_netdev_notifier); - list_for_each_entry_safe(iface, tmp, &iface_list, entry) { + rtnl_lock(); + list_splice_init(&iface_list, &iface_list_to_free); + rtnl_unlock(); + + list_for_each_entry_safe(iface, tmp, &iface_list_to_free, entry) { list_del(&iface->entry); kfree(iface->name); kfree(iface); -- 2.53.0