Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 DD90B47124F; Tue, 21 Jul 2026 18:25:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784658307; cv=none; b=dtKmyFfqaHVMt44zUGgwh5Sp9aKoBkDm5DTsp/nwvl/3FWGXHmoOxVQrjDRzjRLrFeVYLNNoUkwpQzdrZQAEHAkxgsbEmc1vOFrd+fDRFJMdIayoaiZj+l644KneY1KSG2kOgO23MRGJk1/L00NJWjyk2eO5O/WQ5BnD/+IyfIQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784658307; c=relaxed/simple; bh=qQ7TzBA6B3RwctKalI4n3+GoQmR5IZlDXPeiMY83fNM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OvkhH4iGAmY+zFSJ+z4JTCjAQdimZ/Za8ncWDT0+MHM/po5JMoUz7DdUkp08eiXgLdouVPOv5WLqTudLWddN1VePmczxQ45Iy9R9tDzUSP+UQ5azWV/x5gbeAlyLcVS3qpP0JXGmT8XZxKQjFs7P2inPJJ8no0+0Q0tdgc/GqKk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IpdGeIxm; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IpdGeIxm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 18D581F00A3A; Tue, 21 Jul 2026 18:25:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784658306; bh=ELbTu1Za3whJJon7AM8yLaIV0Rq4SYN7keNOfIsrbxY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=IpdGeIxmrv9UaSpEsDGbL+YrTgyMvZAeImtOn43oKuSjUsRfIIuUKJcXSl0442Q8Z pB9G6PVCwqKS9S7d7GdYpWVsEysFoDbmR/Hwrx+9QSSGHRZGmAKgVMpJ9s2NDDS6J6 IVsVEkFS2O4F0+niN2UpMiUnaTZNWfN+HCADRArA= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guangshuo Li , Steve French , Sasha Levin Subject: [PATCH 6.18 1094/1611] smb: client: fix overflow in passthrough ioctl bounds check Date: Tue, 21 Jul 2026 17:20:10 +0200 Message-ID: <20260721152540.025045326@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152514.750365251@linuxfoundation.org> References: <20260721152514.750365251@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guangshuo Li [ Upstream commit a4f27ad055392fa164f5649e89a3637b033c5fcc ] smb2_ioctl_query_info() validates the PASSTHRU_FSCTL response payload before copying it to userspace. The payload offset and length both come from 32-bit fields. The bounds check currently adds OutputOffset and qi.input_buffer_length directly, so the addition can wrap in 32-bit arithmetic before the result is compared against the response buffer length. A malicious server can use a large OutputOffset and a small OutputCount to make the wrapped sum pass the bounds check. The later copy_to_user() then reads from io_rsp + OutputOffset, outside the response buffer. Use size_add() for the offset plus length check so overflow is treated as out of bounds. Fixes: 2b1116bbe898 ("CIFS: Use common error handling code in smb2_ioctl_query_info()") Signed-off-by: Guangshuo Li Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/smb/client/smb2ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/smb/client/smb2ops.c b/fs/smb/client/smb2ops.c index f714ded6b4ffc2..d4095710948e45 100644 --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -1764,8 +1764,8 @@ smb2_ioctl_query_info(const unsigned int xid, if (le32_to_cpu(io_rsp->OutputCount) < qi.input_buffer_length) qi.input_buffer_length = le32_to_cpu(io_rsp->OutputCount); if (qi.input_buffer_length > 0 && - le32_to_cpu(io_rsp->OutputOffset) + qi.input_buffer_length - > rsp_iov[1].iov_len) { + size_add(le32_to_cpu(io_rsp->OutputOffset), + qi.input_buffer_length) > rsp_iov[1].iov_len) { rc = -EFAULT; goto out; } -- 2.53.0