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 E7DC626B96C; Tue, 8 Apr 2025 12:19:27 +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=1744114768; cv=none; b=WHDEfH4Z09g8KBR95M7aUxNuUb9Q09gelcPBXCZBGQJwVjHTibp/3dg89Xm30zqlTQV27KbZl0N2hSbwUxRvdrFAimSt4Azun+LNCw9v9/zdKl20+/wbV8maMisZvebCnVcUaxmXsb+LDMwt51ARk16KeDz0SQNoib/eq+XaXkI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744114768; c=relaxed/simple; bh=ZLlLgi87CxXLjt6lIgkFA40s7D2kPhVCJF+4y6DFcUo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jjKgYm/l5kkeHtxLr4kN8HSU0la1xfRMCV1QJ800F76BixPWVNK0H28ponGApsJxlauA4FdBU4dY3ajnyajsJ2O2pwqEiTJLCVzRUzBHRL+TYE5CpSUngibcdWKc4Opw9RiAS+Sc40Ss4wLGRSg2fkJ7lG4CKzY7HUoHRlo0R4Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=NZ41bbUF; 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="NZ41bbUF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A838C4CEE5; Tue, 8 Apr 2025 12:19:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1744114767; bh=ZLlLgi87CxXLjt6lIgkFA40s7D2kPhVCJF+4y6DFcUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NZ41bbUF+CILIn4mQT9Gdvd5bG7HNCnf6htBE2XAnBHWLmGueKFuwisN5K0VuHuhG imsokKGrsWStQECHJgHgcsZJBo+Cv/DuSE45URMKYOvzMq/j/IKBhuHrBKuCXbqKFq LXGArLp5ftHND0xWJ9PTYlyO1OG7cJR3tK5krV2E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Konstantin Komarov , Sasha Levin Subject: [PATCH 6.13 228/499] fs/ntfs3: Prevent integer overflow in hdr_first_de() Date: Tue, 8 Apr 2025 12:47:20 +0200 Message-ID: <20250408104856.899189425@linuxfoundation.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250408104851.256868745@linuxfoundation.org> References: <20250408104851.256868745@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.13-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter [ Upstream commit 6bb81b94f7a9cba6bde9a905cef52a65317a8b04 ] The "de_off" and "used" variables come from the disk so they both need to check. The problem is that on 32bit systems if they're both greater than UINT_MAX - 16 then the check does work as intended because of an integer overflow. Fixes: 60ce8dfde035 ("fs/ntfs3: Fix wrong if in hdr_first_de") Signed-off-by: Dan Carpenter Signed-off-by: Konstantin Komarov Signed-off-by: Sasha Levin --- fs/ntfs3/ntfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/ntfs3/ntfs.h b/fs/ntfs3/ntfs.h index 241f2ffdd9201..1ff13b6f96132 100644 --- a/fs/ntfs3/ntfs.h +++ b/fs/ntfs3/ntfs.h @@ -717,7 +717,7 @@ static inline struct NTFS_DE *hdr_first_de(const struct INDEX_HDR *hdr) struct NTFS_DE *e; u16 esize; - if (de_off >= used || de_off + sizeof(struct NTFS_DE) > used ) + if (de_off >= used || size_add(de_off, sizeof(struct NTFS_DE)) > used) return NULL; e = Add2Ptr(hdr, de_off); -- 2.39.5