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=1795034996; b=YlbMHN0plntaEnS1D4MzLls0PvPiZWarhUMcVbhlj/WgfvQ5hjdf2cLLvmG2nIoQeTAu EWygGyzqvaZeDZPtRDhtA0QVyuTkxtS5wyLapnIg/rNa5Pi+Tt5bk5EdIbXf40YB3/HAs cQWYDFGzFmqDcthFg4y4v5o5s8o4L+Rhw7MO2m4+flQfsJcuNLrRfBoBr1GBLV8bM7pKR kESbWa1+zdlUV9BdKt8yAaUnANYiJxruEHSWwB0dnEkXSlt3y/DwR+pYT73cb0W8mHn6b hNf3D3/Hp5T0Hv4RjWBH6eFKnAPESvUK3ofE3J7gL95cFYGm0AFYKyieeFNU8LAWhlA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795034996; 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=T/JZDR9FbTv1Yrg0Z6p4rCsKhgrmeDXYr+FsPqyka24=; b=A+nnX81ih91m8S3a1eQIpeHdSlilaXkvI94FYTmaieOCCz7MfPd9+Uqkv00peU2fosqO /RCR9TFeMYgP9wl56wHFDsbiO26y0xI/gbRuD/ioIeYk/SxyBhZUQAdQLx+JnVhW4AooQ +4IFbmSY6gienN/YrI/SgFkrnkntIQB9EGLfZuKM2iTz7JBK6u4IUDR6M8UeHgS07RcDv qNSdiYWGGQlon5YqLuuj7lrqM5TInk7CsGyOWhagGGJIVD0Og9nLpFeDJt6gLnaZVhPVO hktxEjJ0ER3g40efJP4dIVbXJ0MF1Y9PZocCBRKd8Zy29f0YYoBJ9Gy39Qn29j8dgxg== 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=uc3I5oYk; 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 BB593606A31C; Wed, 18 Nov 2026 20:49:56 +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=uc3I5oYk Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B3471F000C4; Wed, 18 Nov 2026 20:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795034996; bh=T/JZDR9FbTv1Yrg0Z6p4rCsKhgrmeDXYr+FsPqyka24=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=uc3I5oYkNpE+BSMcu+MRQAm6/JED5R84gX4O8G4Ch4AZiO4wlZ2tYRvqUgmiZQfrP Ep44b7+tRVC/NfgqVFhri3wORf5aRN80cna+dbjvVNYXGiJpqxiZEr7dp8KErn/rYY um216K/j6Qpuglfben2uo3JbRuA93p65vhysOwWU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michail Andreas Michalopoulos , Namjae Jeon Subject: [PATCH 6.6 0567/3318] ksmbd: accept share config responses from ksmbd-tools before 3.5.3 Date: Wed, 18 Nov 2026 15:19:49 +0100 Message-ID: <20261118150334.414562995@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@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: Michail Andreas Michalopoulos commit 4f1ce9ffb996a524acf864316479a7806ae500c6 upstream. 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: Greg Kroah-Hartman --- fs/smb/server/transport_ipc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) --- a/fs/smb/server/transport_ipc.c +++ b/fs/smb/server/transport_ipc.c @@ -524,11 +524,25 @@ static int ipc_validate_msg(struct ipc_m 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 &&