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=1795051663; b=CUMwGjIaJwNZaJR6lnHKECxCNnIcxtXms873NcJ/TeN8JvmIA5RgeOSDduoDbs90zjyn VNdnbi5jIpYknpkBJGuepDL/qPefa//F5goYoj9KH2vrTiBh7mDmvKJxz8V9NADVtUaNx 2LH14Di8y1slyvFPZhWoDVabVI5xr9IFZM6S0uPFlv5nGJSo4jqCl36TuBTeljztETSMj eU9jajNqqiU07VkduPGMaSmHm7pRyLbsiS77beBhTDrSQfFHUdX2QEgTef17vTRID9l9N 8ySKvT0+JVmGkBCIZ2Spz34XlVGvK+hN78u3yQqU9SN9u6Ja1maS7F6Hn7SfDSPAY+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795051663; 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=yfVxcU+dwhxJJDrB4JmRMRJPk0cpunTeP3kl9/sxOV4=; b=xeyBBD4aJj+RJs/V9rSXxZL+EyoBPM9uCtxaZy4oc/yRmxURDIHLUaim7rtB+HR+201n 8vgu+CHy+1aUCjNdgwb2JA/IpvN8/XDkJj3T4XjIQuANdR1NUdGjPObxhczlhhUmyDBZ1 WKnasUSJ5UWXFNAfc8U35HLgNySrFonHBMyTMQhYtdnN4mbSQMYyFZlPSLQnrmRmOQ9pY Xoe4MOwg8coi5czDT/jkXnreMiZpF0ivVfbs3uDH5UDfgjZzcfAzyCxrwualnFXyAsd/X Lr14J+vq9qrNqgaSFYrPcGGCM0308qHaIJexWmVBlHKDbZXLx1/lbb0dBk+Y5qe+y+w== 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=ivDNeKzA; 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 40106606A31C; Thu, 19 Nov 2026 01:27:43 +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=ivDNeKzA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 922581F000C5; Thu, 19 Nov 2026 01:27:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795051663; bh=yfVxcU+dwhxJJDrB4JmRMRJPk0cpunTeP3kl9/sxOV4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ivDNeKzAsupchHswn1KLClSWnFy3xY4SYv/WQ0mBmrpsUA/rXcb7AYkOdOGPXRuDD zQUXT/5nALyW6wbSxn36+C2wZF5AeJnFYCir+nrJ83uceteQZVrVZ6BtsYdhDW/zMG kasbgvvuQxkjg8eHVZVsNMAs+3KtdZnacTVOQPno= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michail Andreas Michalopoulos , Namjae Jeon , Sasha Levin Subject: [PATCH 5.15 0287/2214] ksmbd: accept share config responses from ksmbd-tools before 3.5.3 Date: Wed, 18 Nov 2026 15:32:43 +0100 Message-ID: <20261118150021.531818268@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150009.797899913@linuxfoundation.org> References: <20261118150009.797899913@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 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michail Andreas Michalopoulos [ Upstream commit 4f1ce9ffb996a524acf864316479a7806ae500c6 ] ksmbd-tools releases before 3.5.2 do not have the payload_sz field in struct ksmbd_share_config_response; the field occupies the last word of their reserved[] area, so the kernel always sees payload_sz == 0 from them. ipc_validate_msg() and share_config_request() used to treat payload_sz == 0 as "legacy userspace" and skip the payload size checks. That case was removed by commit f25e93768fcc ("ksmbd: prevent out-of-bounds reads in share config responses"). With payload_sz == 0: - the IPC$ (pipe) response fails the final message size comparison: these tools always send a one-byte payload, so msg_sz is sizeof(*resp) + 1, but the expected size is now computed as sizeof(*resp) + 0; - every other share fails "payload_sz <= veto_list_sz". In addition, ksmbd-tools before 3.5.3 copy a global "veto files" setting into the IPC$ response, so with such a configuration IPC$ also fails the now unconditional "veto_list_sz > payload_sz" check, even though pipe shares never use a veto list. ksmbd_ipc_share_config_request() then returns NULL and every tree connect fails with STATUS_BAD_NETWORK_NAME, so ksmbd cannot serve any share when used with these ksmbd-tools releases, for example the 3.5.1 package shipped by Ubuntu 24.04. Login still works, which makes the failure look like a configuration problem: CIFS: VFS: BAD_NETWORK_NAME: \\127.0.0.1\IPC$ CIFS: VFS: \\127.0.0.1 failed to connect to IPC (rc=-2) When payload_sz is zero, derive it from the size of the message actually received and store it back in the response, so that the checks in ipc_validate_msg() and the path and veto list parsing in share_config_request() all use the same bound. The response is the kernel's own copy made by handle_response(), and msg_sz has already been checked to be at least sizeof(*resp), so this cannot underflow. All checks added by that commit then apply unchanged, bounded by the bytes that really arrived, and newer ksmbd-tools that fill in payload_sz are unaffected. Also skip the veto list size check for pipe shares: share_config_request() reads neither the path nor the veto list for them. Tested in QEMU with ksmbd-tools 3.5.1 and 3.5.7 and the in-kernel SMB client over loopback, with and without a global "veto files" setting. Fixes: f25e93768fcc ("ksmbd: prevent out-of-bounds reads in share config responses") Cc: stable@vger.kernel.org Assisted-by: LLM Signed-off-by: Michail Andreas Michalopoulos Signed-off-by: Namjae Jeon Signed-off-by: Michail Andreas Michalopoulos Signed-off-by: Sasha Levin --- fs/ksmbd/transport_ipc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/fs/ksmbd/transport_ipc.c b/fs/ksmbd/transport_ipc.c index 9d7b21257bcad..500735ddaa2d5 100644 --- a/fs/ksmbd/transport_ipc.c +++ b/fs/ksmbd/transport_ipc.c @@ -478,11 +478,25 @@ static int ipc_validate_msg(struct ipc_msg_table_entry *entry) if (entry->msg_sz < sizeof(struct ksmbd_share_config_response)) return -EINVAL; + /* + * ksmbd-tools releases before 3.5.2 leave payload_sz zero. + * Derive it from the size of the message actually received so + * the checks below bound the payload for those releases too. + */ + if (!resp->payload_sz) + resp->payload_sz = entry->msg_sz - + sizeof(struct ksmbd_share_config_response); + if (strnlen(resp->share_name, sizeof(resp->share_name)) == sizeof(resp->share_name)) return -EINVAL; - if (resp->veto_list_sz > resp->payload_sz) + /* + * Pipe shares carry no veto list, but ksmbd-tools before 3.5.3 + * copy a global "veto files" setting into the IPC$ response. + */ + if (!(resp->flags & KSMBD_SHARE_FLAG_PIPE) && + resp->veto_list_sz > resp->payload_sz) return -EINVAL; if (resp->flags != KSMBD_SHARE_FLAG_INVALID && -- 2.53.0