From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1755832BF21; Fri, 9 Jan 2026 11:50:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767959405; cv=none; b=m0WcCBa56o1U78RZUKkgMQXp9Yu2qrrcVM53w3yn0qejAGgNxNrmPMrCj9KMy1evvQbJ4e4iwy/DPDcBgfihbifvLXxvRTJ06zyvS2744U5Dpok86iH+d9QJFHIlRFgo5U47Jz8t39XBVxrtJNckR6LOKoVxjhYIGRZN6I7ACvk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767959405; c=relaxed/simple; bh=QS+6a4zrT5EbvF1PUubZlOnmw9fy2ViVr1uUW+9uDTg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rVsYnDFs3pAL0Hs8qrtJAQdGgKS2SQWokbfOQ1brY1wEUXAJ4PErs6/DqSA6sSXIP6cDvZ9Ogp19onis7cGFoGRS18JqcaOjXE1Mfm7Og9uzVSgRQMBbCgQ2va8zLd3XrVXYxMJZhbqEjo1LKNwB3VMCwUFGnK2B40wwTh+pe8w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=y0V7BdZB; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="y0V7BdZB" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 483B8C4CEF1; Fri, 9 Jan 2026 11:50:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767959404; bh=QS+6a4zrT5EbvF1PUubZlOnmw9fy2ViVr1uUW+9uDTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=y0V7BdZBX+pTpvlBs4KjkyFAfyqIMFBFb94YXDQRShqucTy8ulzlUArItAvpe+UHn 04XKL1Ukzu82/itSk0VnCHZnXKEeCe8F+/2PftdGBimGxjlJAJBHiwvbqPkdCCZ5wO xbNAby2/Z4FgvQamUvOLZjrb143BLZV2c1Q2pl+E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Qianchang Zhao , Zhitong Liu , Namjae Jeon , Steve French Subject: [PATCH 6.6 009/737] ksmbd: ipc: fix use-after-free in ipc_msg_send_request Date: Fri, 9 Jan 2026 12:32:28 +0100 Message-ID: <20260109112134.342981646@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260109112133.973195406@linuxfoundation.org> References: <20260109112133.973195406@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Qianchang Zhao commit 1fab1fa091f5aa97265648b53ea031deedd26235 upstream. ipc_msg_send_request() waits for a generic netlink reply using an ipc_msg_table_entry on the stack. The generic netlink handler (handle_generic_event()/handle_response()) fills entry->response under ipc_msg_table_lock, but ipc_msg_send_request() used to validate and free entry->response without holding the same lock. Under high concurrency this allows a race where handle_response() is copying data into entry->response while ipc_msg_send_request() has just freed it, leading to a slab-use-after-free reported by KASAN in handle_generic_event(): BUG: KASAN: slab-use-after-free in handle_generic_event+0x3c4/0x5f0 [ksmbd] Write of size 12 at addr ffff888198ee6e20 by task pool/109349 ... Freed by task: kvfree ipc_msg_send_request [ksmbd] ksmbd_rpc_open -> ksmbd_session_rpc_open [ksmbd] Fix by: - Taking ipc_msg_table_lock in ipc_msg_send_request() while validating entry->response, freeing it when invalid, and removing the entry from ipc_msg_table. - Returning the final entry->response pointer to the caller only after the hash entry is removed under the lock. - Returning NULL in the error path, preserving the original API semantics. This makes all accesses to entry->response consistent with handle_response(), which already updates and fills the response buffer under ipc_msg_table_lock, and closes the race that allowed the UAF. Cc: stable@vger.kernel.org Reported-by: Qianchang Zhao Reported-by: Zhitong Liu Signed-off-by: Qianchang Zhao Acked-by: Namjae Jeon Signed-off-by: Steve French Signed-off-by: Greg Kroah-Hartman --- fs/smb/server/transport_ipc.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/fs/smb/server/transport_ipc.c +++ b/fs/smb/server/transport_ipc.c @@ -520,12 +520,16 @@ static void *ipc_msg_send_request(struct up_write(&ipc_msg_table_lock); ret = ipc_msg_send(msg); - if (ret) + if (ret) { + down_write(&ipc_msg_table_lock); goto out; + } ret = wait_event_interruptible_timeout(entry.wait, entry.response != NULL, IPC_WAIT_TIMEOUT); + + down_write(&ipc_msg_table_lock); if (entry.response) { ret = ipc_validate_msg(&entry); if (ret) { @@ -534,7 +538,6 @@ static void *ipc_msg_send_request(struct } } out: - down_write(&ipc_msg_table_lock); hash_del(&entry.ipc_table_hlist); up_write(&ipc_msg_table_lock); return entry.response;