All of lore.kernel.org
 help / color / mirror / Atom feed
* ntfs_inode_attr_pread(pos<0) can dereference bad pointer
@ 2026-08-16 20:24 rtm
  0 siblings, 0 replies; only message in thread
From: rtm @ 2026-08-16 20:24 UTC (permalink / raw)
  To: Namjae Jeon, Hyunchul Lee; +Cc: linux-fsdevel

ntfs_inode_attr_pread()'s check on its pos argument is

        if (pos > isize) {
                mutex_unlock(&ni->mrec_lock);
                return -EINVAL;
        }

which allows pos to be negative, allowing this to potentially read from
a wild pointer:

                memcpy(buf, (u8 *)attr + pos, count);

A demo using a corrupt NTFS image:

# uname -a
Linux xxx 7.2.0-rc7-00016-g3d6d817622b0 #40 SMP PREEMPT_DYNAMIC Wed Aug 12 13:01:40 EDT 2026 x86_64 x86_64 x86_64 GNU/Linux
# wget http://www.rtmrtm.org/rtm/ntfs23d.img.gz
# gunzip ntfs23d.img.gz
# mount -t ntfs -o loop,rw junk /mnt
# ls /mnt
ntfs: (device loop0): ntfs_lookup_inode_by_name(): Corrupt directory.  Aborting lookup.
Oops: general protection fault, probably for non-canonical address 0x7fff88c0c159a850: 0000 [#1] SMP DEBUG_PAGEALLOC PTI
CPU: 3 UID: 0 PID: 1273 Comm: ls Not tainted 7.2.0-rc7-00016-g3d6d817622b0 #40 PREEMPT(full)
Hardware name: FreeBSD BHYVE/BHYVE, BIOS 14.0 10/17/2021
Call Trace:
 <TASK>
 ? ntfs_inode_attr_pread+0x26d/0x2f0
 ? __kvmalloc_node_noprof+0x1f0/0x5b0
 ntfs_ib_read+0x3d/0xd0
 ntfs_index_walk_down+0x76/0x120
 ntfs_readdir+0x7e5/0xa60
 ? selinux_file_permission+0x127/0x190
 iterate_dir+0x91/0x150
 __x64_sys_getdents64+0x77/0x110
 ? __pfx_filldir64+0x10/0x10
 x64_sys_call+0xfd0/0x2130

Robert Morris
rtm@mit.edu


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-16 20:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-16 20:24 ntfs_inode_attr_pread(pos<0) can dereference bad pointer rtm

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.