Skip to content

Commit 0dc7117

Browse files
moonheeleeaalexandrovich
authored andcommitted
fs/ntfs3: reject index allocation if $BITMAP is empty but blocks exist
Index allocation requires at least one bit in the $BITMAP attribute to track usage of index entries. If the bitmap is empty while index blocks are already present, this reflects on-disk corruption. syzbot triggered this condition using a malformed NTFS image. During a rename() operation involving a long filename (which spans multiple index entries), the empty bitmap allowed the name to be added without valid tracking. Subsequent deletion of the original entry failed with -ENOENT, due to unexpected index state. Reject such cases by verifying that the bitmap is not empty when index blocks exist. Reported-by: [email protected] Closes: https://syzkaller.appspot.com/bug?extid=b0373017f711c06ada64 Fixes: d99208b ("fs/ntfs3: cancle set bad inode after removing name fails") Tested-by: [email protected] Signed-off-by: Moon Hee Lee <[email protected]> Signed-off-by: Konstantin Komarov <[email protected]>
1 parent d683184 commit 0dc7117

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

fs/ntfs3/index.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,6 +1508,16 @@ static int indx_add_allocate(struct ntfs_index *indx, struct ntfs_inode *ni,
15081508
bmp_size = bmp_size_v = le32_to_cpu(bmp->res.data_size);
15091509
}
15101510

1511+
/*
1512+
* Index blocks exist, but $BITMAP has zero valid bits.
1513+
* This implies an on-disk corruption and must be rejected.
1514+
*/
1515+
if (in->name == I30_NAME &&
1516+
unlikely(bmp_size_v == 0 && indx->alloc_run.count)) {
1517+
err = -EINVAL;
1518+
goto out1;
1519+
}
1520+
15111521
bit = bmp_size << 3;
15121522
}
15131523

0 commit comments

Comments
 (0)