]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
fs/ntfs3: Prevent integer overflow in hdr_first_de()
authorDan Carpenter <dan.carpenter@linaro.org>
Sun, 16 Feb 2025 20:52:10 +0000 (23:52 +0300)
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>
Thu, 6 Mar 2025 16:53:26 +0000 (19:53 +0300)
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 <dan.carpenter@linaro.org>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
fs/ntfs3/ntfs.h

index 241f2ffdd9201a7520bad25de395372f11a5f0e9..1ff13b6f96132628a4177c10015fa87368cb0fb3 100644 (file)
@@ -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);