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=1796387968; b=aMIenr5k9524TUhYLVRcO4oM17Pl8VLcvxiTPkTL7PkI/Uug5FyLLshvtAv+zL6ATqBw q5vsRNPk0wbjdzAlrjYbSOIsKemIkWK+bXxc1M/O0SuyEQUa561nGqEDzcdf6xvp3+QOi rhWxAmsd13JFbv2dmST9wGvLyU/fIHTuOzC07mC0ym/kW1Vwhiw9Ko0vqTSeT+qa2havo nIKPuz4x4bliubHVl91JQl8UYLGICT+jIWMYKvOZTFpUCj5LmNr3s27KM7OOYMGIviGjz cTVAQFCR0PP5obg4CA3n77QdSki4ufEmNWorMy0a63cpSN5bxWYVTOqyGExBfzhs6bg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387968; 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=FRkYWfPg5iG/GwSbqZqG8hGTmX1OoQ4LQsj0t3+7TP8=; b=pQC8Cqg9SC0xSh4IQn3lnQSbQtp2x5TgA2ik1QVyJA75sj3+lDF3uR24/bUiVkwMwPNl gcLQSQuhZ541UqDV8khzD7+7CpICoa8v5mRQCY70osgbxuzFbNRyQ0t6qcSKa+8Q43Yhf Zozh1c3+ddeIDJfd0LAoiVsrb2smGpOmmQHIdwHqe4e5i6KwbKBBqttFlmC83Yhl8Vphx lyOrbljVaH2XtXeRDYo2zVWqwnIIruSky2CheMFTE0uiiXeIN56+qgrgsaJAipmJbJpOu BzhbffHSwhA7l+gB4WlScOc5gICuRZ79//F7OYusdzcvhqS98iLM/sKiyalbgQOt6VA== 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="F/ph2PpS"; 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 36625606A32F; Fri, 4 Dec 2026 12:39:28 +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=F/ph2PpS Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1D501F000C2; Fri, 4 Dec 2026 12:39:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387968; bh=FRkYWfPg5iG/GwSbqZqG8hGTmX1OoQ4LQsj0t3+7TP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=F/ph2PpSMoe7zoq3S9vGENESM8cbxqVaxQib9b0SKTlXaYtGZiJ0XuDFa/fiy1SCa nq67uzRSh0ZPLYvoAjTRH4DDrEOhmMbgSvbmAWdw3nytDdmXy2Xk06vaqFXZkPmX41 fOyxgHv1YFnI/ejbEKM6aOg5vnUTl85/Y2ljzJcg= 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.1 0432/1059] ksmbd: fix iface_list use-after-free during server reset Date: Fri, 4 Dec 2026 18:59:23 +0900 Message-ID: <20261204100655.513320224@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: 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() call from the free loop, since the older tree's loop never had that call or function. ] 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 7b06fff60d6b7..0d31a26da9642 100644 --- a/fs/smb/server/transport_tcp.c +++ b/fs/smb/server/transport_tcp.c @@ -652,10 +652,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