linux/fs/ntfs3
Ziqi Zhao 1f9b94af92
fs/ntfs3: Fix possible null-pointer dereference in hdr_find_e()
Upon investigation of the C reproducer provided by Syzbot, it seemed
the reproducer was trying to mount a corrupted NTFS filesystem, then
issue a rename syscall to some nodes in the filesystem. This can be
shown by modifying the reproducer to only include the mount syscall,
and investigating the filesystem by e.g. `ls` and `rm` commands. As a
result, during the problematic call to `hdr_fine_e`, the `inode` being
supplied did not go through `indx_init`, hence the `cmp` function
pointer was never set.

The fix is simply to check whether `cmp` is not set, and return NULL
if that's the case, in order to be consistent with other error
scenarios of the `hdr_find_e` method. The rationale behind this patch
is that:

- We should prevent crashing the kernel even if the mounted filesystem
  is corrupted. Any syscalls made on the filesystem could return
  invalid, but the kernel should be able to sustain these calls.

- Only very specific corruption would lead to this bug, so it would be
  a pretty rare case in actual usage anyways. Therefore, introducing a
  check to specifically protect against this bug seems appropriate.
  Because of its rarity, an `unlikely` clause is used to wrap around
  this nullity check.

Reported-by: syzbot+60cf892fc31d1f4358fc@syzkaller.appspotmail.com
Signed-off-by: Ziqi Zhao <astrajoan@yahoo.com>
Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
2023-09-28 15:04:05 +03:00
..
lib fs/ntfs3: Add missing header and guards to lib/ headers 2021-09-13 19:41:44 +03:00
attrib.c fs/ntfs3: Fix NULL pointer dereference on error in attr_allocate_frame() 2023-09-28 15:04:03 +03:00
attrlist.c fs/ntfs3: Use kvmalloc instead of kmalloc(... __GFP_NOWARN) 2023-09-28 15:03:56 +03:00
bitfunc.c fs/ntfs3: Add ntfs_bitmap_weight_le function and refactoring 2022-11-14 19:50:42 +03:00
bitmap.c fs/ntfs3: Allow repeated call to ntfs3_put_sbi 2023-09-28 15:03:59 +03:00
debug.h fs/ntfs3. Add forward declarations for structs to debug.h 2021-09-13 19:41:43 +03:00
dir.c fs/ntfs3: Fix sparse problems 2022-11-14 19:50:42 +03:00
file.c fs/ntfs3: Refactoring and comments 2023-09-28 15:04:01 +03:00
frecord.c fs/ntfs3: Fix possible NULL-ptr-deref in ni_readpage_cmpr() 2023-09-28 15:04:03 +03:00
fslog.c fs/ntfs3: Code formatting 2023-07-03 00:21:27 +04:00
fsntfs.c fs/ntfs3: fix deadlock in mark_as_free_ex 2023-09-28 15:03:58 +03:00
index.c fs/ntfs3: Fix possible null-pointer dereference in hdr_find_e() 2023-09-28 15:04:05 +03:00
inode.c fs/ntfs3: Refactoring and comments 2023-09-28 15:04:01 +03:00
Kconfig fs: add CONFIG_BUFFER_HEAD 2023-08-02 09:13:09 -06:00
lznt.c fs/ntfs3: Code formatting 2023-07-03 00:21:27 +04:00
Makefile
namei.c fs/ntfs3: Refactoring and comments 2023-09-28 15:04:01 +03:00
ntfs_fs.h fs/ntfs3: Refactoring and comments 2023-09-28 15:04:01 +03:00
ntfs.h fs/ntfs3: Refactoring and comments 2023-09-28 15:04:01 +03:00
record.c fs/ntfs3: Refactoring and comments 2023-09-28 15:04:01 +03:00
run.c fs/ntfs3: Code formatting 2023-07-03 00:21:27 +04:00
super.c fs/ntfs3: Fix OOB read in ntfs_init_from_boot 2023-09-28 15:04:05 +03:00
upcase.c fs/ntfs3: Add option "nocase" 2022-09-30 17:39:47 +03:00
xattr.c fs/ntfs3: fix panic about slab-out-of-bounds caused by ntfs_list_ea() 2023-09-28 15:04:04 +03:00