From mboxrd@z Thu Jan 1 00:00:00 1970 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 2B31B4E0B66; Wed, 30 Sep 2026 16:36:46 +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=1790786207; cv=none; b=u9Ziji8SL3W1+/iIZ3hcmUwdSKPWg+tI/xfG4s4WkkUJyt0msXPW5vE3AE74nzZAVHT4yUR9+xlHQ4XmqbNP08W9T7IocheDZm2eNxt1g0LHJhYxNcihNshCYtg2u3eXFva57jHJla27gTFkpvg5xyroB92Zj12VwZ4BxRkBVXo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786207; c=relaxed/simple; bh=wJsSlMBRPQmRXaJQl0bsaT1ZBeOV9cH1xJ8VQCYrddc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d8B4EmjnoZ5CaX4UMMLca5ddKRSqBhuW8xE5Xmu5gR+tDHt6qPRas2TQZ56Ljt4bZRPIRFn0x+7ngQVGoPYqdExPOsi5yG32zu/yvamPWlVH3+HKNEcP/rKIpYDWPBhj5yhzjRSDN/yCsT17b0QFgBtqVDvZouVGxppg7/Lrtjg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=hUvH6F6A; 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="hUvH6F6A" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 848631F000FF; Wed, 30 Sep 2026 16:36:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790786206; bh=fWocjP+HbhqgJcv8bRyskzKc/qcKhky5WUcVuill/Kg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hUvH6F6AaY8KnEpMhKCCGVXBiXkMJ0KPzrUJx+qwBD27F3iGIypqdFO5WrjyjOYNl aCbbRwbuemImLo4tVKEQaSDwiXzB9mF8WLXij20OoJSPUEWKiQQ+vZlAuTzQyZ9UAu R8xIzMIi9ebbZM5Lv58g+ElefezYlEQIQ+HFUm2E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Frank Sorenson , David Howells , Paulo Alcantara Subject: [PATCH 6.1 778/982] smb: client: fix potential OOB read in smb3_enum_snapshots() Date: Wed, 30 Sep 2026 17:25:14 +0200 Message-ID: <20260930152433.465321139@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Frank Sorenson commit 4775c3b7a597907e0b97556c7986fda238a377ae upstream. If snapshot_array_size is smaller than GMT_TOKEN_SIZE, smb3_enum_snapshots() sets ret_data_len to sizeof(struct smb_snapshot_array) without verifying the actual length of the server's reply. Because SMB2_ioctl() places no lower bound on the server-supplied OutputCount and allocates retbuf to exactly that length, a short reply results in ret_data_len exceeding the size of retbuf. The subsequent copy_to_user() then reads past the end of retbuf, leaking adjacent slab memory to userspace. The subsequent clamp check is ineffective as it only reduces ret_data_len. Fix this by rejecting replies shorter than sizeof(struct smb_snapshot_array) with -EIO. Note that the bound is set to the 12-byte struct size rather than the 16-byte MIN_SNAPSHOT_ARRAY_SIZE defined in MS-SMB2 3.3.5.15.1, because 12 bytes is exactly what copy_to_user() attempts to read. Fixes: e02789a53d71 ("smb3: enumerating snapshots was leaving part of the data off end") Cc: stable@vger.kernel.org Signed-off-by: Frank Sorenson Reviewed-by: David Howells Signed-off-by: Paulo Alcantara Signed-off-by: Greg Kroah-Hartman --- fs/smb/client/smb2ops.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) --- a/fs/smb/client/smb2ops.c +++ b/fs/smb/client/smb2ops.c @@ -2148,8 +2148,14 @@ smb3_enum_snapshots(const unsigned int x * and retry the ioctl again with larger array size sufficient * to hold all of the snapshot GMT tokens on the second try. */ - if (snapshot_in.snapshot_array_size < GMT_TOKEN_SIZE) + if (snapshot_in.snapshot_array_size < GMT_TOKEN_SIZE) { + if (ret_data_len < sizeof(struct smb_snapshot_array)) { + rc = -EIO; + kfree(retbuf); + return rc; + } ret_data_len = sizeof(struct smb_snapshot_array); + } /* * We return struct SRV_SNAPSHOT_ARRAY, followed by