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=1793831330; b=B8D+Fam+UJUtiNCqB+sovSyK1aSLJA+avEVRzMEyXSgm/uS107Cc5vY9s5Fw8eH8vvkY W7eQwghiV5u6nNXkUFvvG9BoHIo86nnNqkl6soDyZjnwEKViI5VDs3efqMgQoxjzjx5Vp UBPRh5AS2TsnkT7qq8Buru4HMaZLSPoNHEvEJweORtAARSRlC2kRxqS3ZVP2CJS+tFhtW wzBqW/ZJ6kUmIu2UgDx0bH/Yni33lo9QV02h3yAcwWu7UKreD11EbeF3Ku1bjU4SLvylx KFVLdK4+3RAIr5dazlafJfBsQtEsREeXQuRQmBOR3m7hB6HQWk+h7L7mqRx6EpLYwHg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793831330; 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=YuzRsIqz6lOrEK68DH/1Pbd2aEh2P6IbLcASqrJSgQo=; b=CAkagY5XGUl1v1lKYLpt8PiYrwNDrgL2AAtvQluz80CslrI4m38lTRqz7L7bnjSqjn92 IoTN38Wn+kUATrUsliOucR4Ds9Lxh7GJfggRUG7Kc7hWTHsJOqz6FBnRdqLZvGQ80qWvT 25iEYzsRPsgzPQPTmU1OR09DxLRfC1vhh6JPOowk1zQU2oNPrLkBWP8fxoEBhOn+JopF+ 9BQXJoWvlU4FsLY8fKW1zlEY9Q2YOZFJXrcz7FxaferE9JlXReAvUEp8qPonafFPWi9X7 42nTZH8Onl0bUGs5QoRiRbhQn//5V1+zM42feC9Rmbsis8eGEFEIaa/EyTIfQ4Vrt9Q== 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="kBXL/Qlb"; 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 9C2B1606D828; Wed, 4 Nov 2026 22:28:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=kBXL/Qlb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 373301F000C1; Wed, 4 Nov 2026 22:28:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793831330; bh=YuzRsIqz6lOrEK68DH/1Pbd2aEh2P6IbLcASqrJSgQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kBXL/QlbhTy1raOjo3lEANQr7aNCFnHV+z+hjQEe6NL93jlZWeHqraxkpy+QqMHOz amu19Oi73fIR5wSCddXgfCFig5GyaM5+U/wCVyw4qwI6n0T8R5FdVoFov+cbbvj4Gi iGB4gXwzbNiiU4NIl5sJNCBePrKE4ttDkAAeFGIg= 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.18 0640/1005] ksmbd: accept share config responses from ksmbd-tools before 3.5.3 Date: Wed, 4 Nov 2026 16:06:13 -0500 Message-ID: <20261104211101.686538611@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261104211043.516122098@linuxfoundation.org> References: <20261104211043.516122098@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 6.18-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 &&