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 1B572149C6F for ; Fri, 24 Apr 2026 15:08:29 +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=1777043310; cv=none; b=GTy8W0G9ZS8M2A6OaKxgnxsGMY/TfCWpEbV+zUSsiAUJDgwDQyRRtYVP+wo4dml9p2pui3g3bIZjqh6HQtRl1zVLpC/GMaxiPloJhEDwu3+ywyL4Yhh4+rqwtDGZOP1PAhJCyAC2XH5GdNM5wbObGFlevS2VnnecykmLnKfz57Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777043310; c=relaxed/simple; bh=TzlYDStvyu7tW+Vj7fWn03GB/P130J4cNGbrSOS5Zso=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uv6CXcJxmbd4Mv0/aaYbfWS0S/TTIiS5XGZsLdnjnTVyQVf7Hk6ywyj2z+k9bD/GdOlFKU4ECDLnOJZgvbKaVbVMkgAM5lUlFgVAi4CAGzVgy3tGSlkRLT6XYMCFQOhtd4P/T3Eqs7izI4XU12jMhDbbBRup9+CqzsRSO5N7vvI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PqmYhDdJ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PqmYhDdJ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2EFBBC19425; Fri, 24 Apr 2026 15:08:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1777043309; bh=TzlYDStvyu7tW+Vj7fWn03GB/P130J4cNGbrSOS5Zso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PqmYhDdJjAZTSHezETZRLLTUXifIAE5XQbElVq7Gq0Zc6jA7i9Cg5BHy6NX39a1ae /w/MxUkPek8zLEaUjwpjZcHvX1ymmKXK6y/RUByQCgP4J9teee2EsPZqHJ7A60o59D mBiJ+Tda7DtQDBp6DAFuWXnW6s8IEa6JUC0D8UJKfJN1KkMRoVXdIgi59ExEkW7oEf ryto0MkU0oBd5Ay0qYFpLcpQByAnxqpxDJHU3gxl+hAV1FNm3dyJxHmtaqwZx7FPWF 55lgjqRUvG1u9aPY7243SN40kqZ85NjcXkmxkI9pE/4kEBoOm+7uqjPTjLHRMAWm0r 0m6UE36gTiq+Q== From: Sasha Levin To: stable@vger.kernel.org Cc: Michael Bommarito , Steve French , Sasha Levin Subject: [PATCH 5.15.y] smb: client: fix OOB read in smb2_ioctl_query_info QUERY_INFO path Date: Fri, 24 Apr 2026 11:08:27 -0400 Message-ID: <20260424150827.2204387-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026042458-crazily-gating-116d@gregkh> References: <2026042458-crazily-gating-116d@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Michael Bommarito [ Upstream commit a58c5af19ff0d6f44f6e9fe31e33a2c92223f77e ] smb2_ioctl_query_info() has two response-copy branches: PASSTHRU_FSCTL and the default QUERY_INFO path. The QUERY_INFO branch clamps qi.input_buffer_length to the server-reported OutputBufferLength and then copies qi.input_buffer_length bytes from qi_rsp->Buffer to userspace, but it never verifies that the flexible-array payload actually fits within rsp_iov[1].iov_len. A malicious server can return OutputBufferLength larger than the actual QUERY_INFO response, causing copy_to_user() to walk past the response buffer and expose adjacent kernel heap to userspace. Guard the QUERY_INFO copy with a bounds check on the actual Buffer payload. Use struct_size(qi_rsp, Buffer, qi.input_buffer_length) rather than an open-coded addition so the guard cannot overflow on 32-bit builds. Fixes: f5778c398713 ("SMB3: Allow SMB3 FSCTL queries to be sent to server from tools") Cc: stable@vger.kernel.org Signed-off-by: Michael Bommarito Assisted-by: Claude:claude-opus-4-6 Assisted-by: Codex:gpt-5-4 Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/smb2ops.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c index 0a62720590daf..2ad2ffd41a334 100644 --- a/fs/cifs/smb2ops.c +++ b/fs/cifs/smb2ops.c @@ -1826,6 +1826,12 @@ smb2_ioctl_query_info(const unsigned int xid, qi_rsp = (struct smb2_query_info_rsp *)rsp_iov[1].iov_base; if (le32_to_cpu(qi_rsp->OutputBufferLength) < qi.input_buffer_length) qi.input_buffer_length = le32_to_cpu(qi_rsp->OutputBufferLength); + if (qi.input_buffer_length > 0 && + struct_size(qi_rsp, Buffer, qi.input_buffer_length) > + rsp_iov[1].iov_len) { + rc = -EFAULT; + goto out; + } if (copy_to_user(&pqi->input_buffer_length, &qi.input_buffer_length, sizeof(qi.input_buffer_length))) { -- 2.53.0