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 AA730442397; Wed, 23 Sep 2026 14:34:23 +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=1790174064; cv=none; b=GCkimOw0M1zM6bwaPOSIuW2Ja67cIZe/GuV05YnQUg4IFFGhjbCS/m5TFuIGagUxqhsI9u6aCgdE6MkciL6gwc8Apajq62IAuQyBEpbLWXHO/1Lna6+GSzOa+6Br4FSGvp+OnkalWYc61GTpuDmzHVIAYh4cKiFY6oH9ZUacSIA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790174064; c=relaxed/simple; bh=GiDJ1PVXDGe73XCHOKpiC7jq70zICy5p2RvLzLDf7J0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=C29DHLaQV9kSyoCJLKXQi1KggTb/sBo7bIt8VMQnk+rtq7TfdMHdrJ1bWkLDxMZsFFR/0cFG07vfbTEcElsxppROP5prerNLXrOlMUFCM0cBdCoVuBrKzz8HumnoMytgqYOUhnnFDR3DDhoVW6jjD9c/SgdMY2Jdzjn+S2hLQCI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=B92IelWD; 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="B92IelWD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D55E01F000FF; Wed, 23 Sep 2026 14:34:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790174063; bh=890L7ASkFQGg28Hn9kaMXG4ib4OJESEJCGEDENOdg18=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=B92IelWDBSo/Pq6K1JA6/uQE9ZpVEbQjJGiwCIguXak/y/5oaaDOXmJuV/61ER62/ DrgHRYQfzyLBR1Gjn5qPN7A011rS/rBtg9yrqHMVIgQuNwfMCPSHWs4WxJj2pqPWh7 d7R4kfYnpu+uWco3H146XnavmJ7ObheD4P2Yfaw0= 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 7.2 423/438] smb: client: fix potential OOB read in smb3_enum_snapshots() Date: Wed, 23 Sep 2026 16:07:24 +0200 Message-ID: <20260923140655.881636435@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260923140644.756254324@linuxfoundation.org> References: <20260923140644.756254324@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 7.2-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 @@ -2460,8 +2460,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