diff options
| author | Wahid Khan <wahidzk0091@gmail.com> | 2026-11-06 18:15:52 +0530 |
|---|---|---|
| committer | Namjae Jeon <linkinjeon@kernel.org> | 2026-11-08 12:43:07 +0900 |
| commit | bada7bbb11aaa6feba8904cf38ff833453f5b5d9 (patch) | |
| tree | d5226401ec3cab08333f02424f9c79abbc794d70 /scripts/Makefile.thinlto | |
| parent | 0ea30dd6eeabc09235d5c2cdb98ca4e0d593963f (diff) | |
| download | lwn-bada7bbb11aaa6feba8904cf38ff833453f5b5d9.tar.gz lwn-bada7bbb11aaa6feba8904cf38ff833453f5b5d9.zip | |
ntfs: open the index allocation before reading or writing an index block
ntfs_ib_write() and ntfs_ib_read() use icx->ia_ni without checking it.
ntfs_ir_reparent() only opens the index allocation through
ntfs_ia_add() when the root is a small index. For a root that is already
marked as a large index it calls ntfs_ib_write() directly.
The lookup does not open the index allocation either when it ends in the
root. If the last entry of the root has no child node, ia_ni is still
NULL when the root has to be moved into an index block, and the write
dereferences it:
Oops: general protection fault, KASAN: null-ptr-deref in range
[0x0000000000000128-0x000000000000012f]
RIP: 0010:ntfs_inode_attr_pwrite+0x52/0x1600
ntfs_ir_make_space
ntfs_ie_add
ntfs_index_add_filename
__ntfs_link
ntfs_link
vfs_link
A single byte of an image from mkntfs is enough. In a directory that has
one empty index block, clear INDEX_ENTRY_NODE (flags 3 -> 2) of the last
entry of the $INDEX_ROOT and link() a file into the directory.
Commit 9365c4a1357e ("ntfs: fix NULL dereference on index allocation open failure")
covers the case where ntfs_ia_open() fails in the lookup. Here it was
never tried. Open the index allocation on demand in both
helpers and fail with -EIO if that does not work.
ntfs_ia_open() also succeeds for a directory that has no
$INDEX_ALLOCATION attribute. The inode it returns is then an empty resident
stub that does not describe an index allocation, so reject that case too.
Fixes: 0a8ac0c1fa0b ("ntfs: update directory operations")
Cc: stable@vger.kernel.org # v7.1+
Signed-off-by: Wahid Khan <wahidzk0091@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
