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 8297038AC75 for ; Fri, 24 Apr 2026 09:43:01 +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=1777023781; cv=none; b=HBN0UedMrRkXBqeIRFbyu3+MAhwQpPEL2LKsXJLQIm5TZ1WOog7g9Rsoc79JJhoWWAvasu6gbAwq5IvPqWNGcoPH6MaLvgQowvr7A9nnOx0rUOCACUlyFNBnwbRz/6bbQjOuB/PUa7LO3Svu/ZjyFFCVGDtQ4yvvyr4ZTO0cRU0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777023781; c=relaxed/simple; bh=Awj2TvDoBSf8McjBE1vUxdyIQiOI1e2rEHwUx3pnCGo=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=fggK52wC8DDBuAN9mb+Dqm8Qzk41b0W54Gn4H8YqWvKaSz2uZlGARsQHEIzRRzCkNfo8aUlpcRqWaiWinITdOSUn6+4v3uhPXxZSn8bPASVL8YCf1Ot3QhNPFM8ZLWDI4ruJZCnmWC2snmts1rC8gZncwaj863pTH/bJouzoMxQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=eQc226RK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="eQc226RK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB96FC19425; Fri, 24 Apr 2026 09:43:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1777023781; bh=Awj2TvDoBSf8McjBE1vUxdyIQiOI1e2rEHwUx3pnCGo=; h=Subject:To:Cc:From:Date:From; b=eQc226RKIImAur4Z2jdYJDj+CNg7FQccD322qo2p3sNVly3tsg/Jmw+O+aL785Lvp ZrAemk8/qkkgC8jXiZLmea0NjQeKx+NnJyaDAerMg4boJHJkEaz9U2+3kZHjzthC8M Deg15vKmEyxi9tdEU2nEJZr3xG8e3fWlz3/uwiok= Subject: FAILED: patch "[PATCH] smb: client: fix OOB read in smb2_ioctl_query_info QUERY_INFO" failed to apply to 5.15-stable tree To: michael.bommarito@gmail.com,stfrench@microsoft.com Cc: From: Date: Fri, 24 Apr 2026 11:42:58 +0200 Message-ID: <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-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x a58c5af19ff0d6f44f6e9fe31e33a2c92223f77e # git commit -s git send-email --to '' --in-reply-to '2026042458-crazily-gating-116d@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From a58c5af19ff0d6f44f6e9fe31e33a2c92223f77e Mon Sep 17 00:00:00 2001 From: Michael Bommarito Date: Sun, 19 Apr 2026 19:35:19 -0400 Subject: [PATCH] smb: client: fix OOB read in smb2_ioctl_query_info QUERY_INFO path 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 diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index a2105f4b54db..7f346ee50289 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -1783,6 +1783,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))) {