Skip to content

Commit b2bc7c4

Browse files
Jiasheng Jiangaalexandrovich
authored andcommitted
fs/ntfs3: Fix slab-out-of-bounds read in DeleteIndexEntryRoot
In the 'DeleteIndexEntryRoot' case of the 'do_action' function, the entry size ('esize') is retrieved from the log record without adequate bounds checking. Specifically, the code calculates the end of the entry ('e2') using: e2 = Add2Ptr(e1, esize); It then calculates the size for memmove using 'PtrOffset(e2, ...)', which subtracts the end pointer from the buffer limit. If 'esize' is maliciously large, 'e2' exceeds the used buffer size. This results in a negative offset which, when cast to size_t for memmove, interprets as a massive unsigned integer, leading to a heap buffer overflow. This commit adds a check to ensure that the entry size ('esize') strictly fits within the remaining used space of the index header before performing memory operations. Fixes: b46acd6 ("fs/ntfs3: Add NTFS journal") Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com> Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent ca1cedd commit b2bc7c4

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

fs/ntfs3/fslog.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3431,6 +3431,9 @@ static int do_action(struct ntfs_log *log, struct OPEN_ATTR_ENRTY *oe,
34313431

34323432
e1 = Add2Ptr(attr, le16_to_cpu(lrh->attr_off));
34333433
esize = le16_to_cpu(e1->size);
3434+
if (PtrOffset(e1, Add2Ptr(hdr, used)) < esize)
3435+
goto dirty_vol;
3436+
34343437
e2 = Add2Ptr(e1, esize);
34353438

34363439
memmove(e1, e2, PtrOffset(e2, Add2Ptr(hdr, used)));

0 commit comments

Comments
 (0)