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=1793826965; b=uI7nyorWazLzHGcA5cJWi3yt948pMJvcpLogYF+AWPe6ArTYus16tTDhQWFd/nAMtmaD QbXg6I0hNddDKIQo++Vc/k9Tp3zQ+dB4h0FN1XC0fvxmXfJ03jec+taH6hHl37vv1ifJ5 F/96DZ/kJxsVjtnz2CpsgZftY2Q3n+8asWvC76fItj+/ivm08ePEI92VD9xbqo2QCFX/u Mi7U4HuV75xpxtHBCFoW+9c+U9SU+2d/ONXjjsMdC/eNeR3QjsL1aMWoHrVZREY05dB0Z 9XPm2ED+jF1pnjyV6p3Tnvy2VW1/D4Br6XdAazXvMgMdNamWjkW8n1xaL4z5bnbslAg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793826965; 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=U8LlfDrP7sJd8cqypmMLOOJLBMyrZDax24GtpXTEwkQ=; b=DJ21myr9QBwnaXIpJ1E2q2H/6okEgAdqWLOyX6eFGWwbR2oqQypSVu+U2ejdyUfxpfac oOGIlzwK9dQj1RNZ/vcsRRJiEV6KbOvql+s/y3bUbXQA1VBtEzofMJseW9iiBA17SmWGH Mgj0v9jySjh+e4UApD5dMBtYPnDjNYm+zPJOJpcvYCxZaf3JlQwtgFc3ASXhC07q0s3Tg QblXAVQmBaFRgiRbugnE1kExjRXPJ6tFb4LXAL3uVpQeUsnnxdADjpH2j6nDJyXYgiuqS WZX0o5cWNwbhGa3hf6zuQRql5ebRTrIRwGBp+fjyNFXS+OfsDhkBMlOh1EypFACwsHw== 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=nNhlxkpO; 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 93CE16070323; Wed, 4 Nov 2026 21:16:05 +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=nNhlxkpO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1C2201F00A1D; Wed, 4 Nov 2026 21:16:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1793826965; bh=U8LlfDrP7sJd8cqypmMLOOJLBMyrZDax24GtpXTEwkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=nNhlxkpOr4UyehibgGN7Kp3qC75/ACqaVEyhmno+DCHE536uokOr11j5IbcnCEetZ 7c9ivUSwTnBbLFujLDg94TfCE9WjaJiSH4v4BF1HWrrbVCrr3NubPWe7NIG6gdb2rn UPVun1xyIKlcW7rW7/lbdmAyolP+oCUAEDyRvvps= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Michail Andreas Michalopoulos , Namjae Jeon Subject: [PATCH 7.3 113/547] ksmbd: accept share config responses from ksmbd-tools before 3.5.3 Date: Wed, 4 Nov 2026 16:04:57 -0500 Message-ID: <20261104211041.414978988@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261104211038.406938024@linuxfoundation.org> References: <20261104211038.406938024@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 7.3-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 @@ -532,11 +532,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 &&