Commit b5198fc
ntfs: fix NULL dereference in ntfs_index_walk_down()
ntfs_index_walk_down() allocates ictx->ib when descending from the root
into an index allocation block. If that allocation fails, the old code
still passes the NULL buffer to ntfs_ib_read(), which can write through
it via ntfs_inode_attr_pread().
Allocate the index block into a temporary pointer and return -ENOMEM
before changing the index context on allocation failure. Also propagate
ERR_PTR() through ntfs_index_next() and ntfs_readdir() so walk-down
allocation or index block read failures are not mistaken for normal
index iteration inside the filesystem.
ntfs_readdir() keeps the existing userspace-visible behavior of
suppressing readdir errors after marking end_in_iterate; this change only
prevents the walk-down failure path from dereferencing NULL internally.
The failure was reproduced with failslab fail-nth injection on getdents64;
the original module hits a NULL pointer dereference in memcpy_orig through
ntfs_ib_read(), while the patched module reaches the same
ntfs_index_walk_down() allocation failure without crashing.
Fixes: 0a8ac0c ("ntfs: update directory operations")
Signed-off-by: DaeMyung Kang <charsyam@gmail.com>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>1 parent 897d540 commit b5198fc
2 files changed
Lines changed: 23 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
911 | 911 | | |
912 | 912 | | |
913 | 913 | | |
914 | | - | |
915 | | - | |
| 914 | + | |
| 915 | + | |
916 | 916 | | |
917 | 917 | | |
918 | 918 | | |
919 | 919 | | |
920 | 920 | | |
921 | 921 | | |
922 | 922 | | |
923 | | - | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
924 | 931 | | |
925 | 932 | | |
926 | 933 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1969 | 1969 | | |
1970 | 1970 | | |
1971 | 1971 | | |
| 1972 | + | |
1972 | 1973 | | |
1973 | 1974 | | |
1974 | 1975 | | |
1975 | 1976 | | |
1976 | 1977 | | |
1977 | 1978 | | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
1978 | 1982 | | |
1979 | 1983 | | |
1980 | | - | |
| 1984 | + | |
1981 | 1985 | | |
1982 | 1986 | | |
1983 | 1987 | | |
| |||
1991 | 1995 | | |
1992 | 1996 | | |
1993 | 1997 | | |
1994 | | - | |
1995 | | - | |
| 1998 | + | |
| 1999 | + | |
1996 | 2000 | | |
1997 | 2001 | | |
1998 | 2002 | | |
| |||
2097 | 2101 | | |
2098 | 2102 | | |
2099 | 2103 | | |
2100 | | - | |
| 2104 | + | |
2101 | 2105 | | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
2102 | 2109 | | |
2103 | 2110 | | |
| 2111 | + | |
| 2112 | + | |
2104 | 2113 | | |
2105 | 2114 | | |
2106 | 2115 | | |
| |||
0 commit comments