linux/fs/ntfs3
Christian Brauner 56c3824de5
ntfs3: free replaced mount options after a grace period
ntfs_fs_reconfigure() replaces the old mount options with new mount
options in sbi->options. The old mount options land in fs_context and
are freed as soon as remount returns. With a pathwalk held up in
ntfs_nls_to_utf16() between loading sbi->options and dereferencing it
while a remount replaces them:

  BUG: KASAN: slab-use-after-free in ntfs_nls_to_utf16+0x7ae/0x7c0
  Read of size 8 at addr ff110001044fd448 by task walker/98
  Call Trace:
   <TASK>
   ntfs_nls_to_utf16+0x7ae/0x7c0
   ntfs_d_hash+0x22b/0x500
   link_path_walk+0x11ad/0x1d30
   path_lookupat+0x63/0xb00
   filename_lookup+0x1f1/0x5b0
   vfs_statx+0xd7/0x3b0
  [...]
  Allocated by task 95:
   __kmalloc_node_track_caller_noprof+0x2a2/0x730
   kmemdup_noprof+0x25/0x50
   ntfs_fill_super+0x1e5/0x4550
  [...]
  Freed by task 97:
   kfree+0x1db/0x5b0
   put_fs_context+0x13c/0x7d0
   path_mount+0x54a/0x2130
   __x64_sys_mount+0x20c/0x270

That info is needed in rcu lookup in the dentry hash and dentry compary
methods for ntfs3 and causes a UAF today. Delay freeing with an rcu
grace period.

ntfs_nls_to_utf16() reads ->nls and ->ads once under rcu_read_lock() so
the hooks pair with the release in ntfs_fs_reconfigure(). That also
covers callers outside of rcu pathwalk such as ntfs_lookup(). They don't
hold rcu_read_lock() themselves and wouldn't be protected by the grace
period otherwise. Remount refuses to change the iocharset so ->nls stays
valid after rcu_read_unlock().

Fixes: a3a956c78e ("fs/ntfs3: Add option "nocase"")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20261009-work-fixes-rcu-v1-8-7446d2d335e6@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
History 2026-10-14 22:08:04 +02:00
..
lib treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
attrib.c fs/ntfs3: Add basic support for alternative data streams 2026-07-30 10:50:00 +02:00
attrlist.c fs/ntfs3: Add basic support for alternative data streams 2026-07-30 10:50:00 +02:00
bitfunc.c fs/ntfs3: Add ntfs_bitmap_weight_le function and refactoring 2022-11-14 19:50:42 +03:00
bitmap.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
debug.h fs/ntfs3. Add forward declarations for structs to debug.h 2021-09-13 19:41:43 +03:00
dir.c ntfs3: free replaced mount options after a grace period 2026-10-14 22:08:04 +02:00
file.c fs/ntfs3: Add basic support for alternative data streams 2026-07-30 10:50:00 +02:00
frecord.c fs/ntfs3: Add basic support for alternative data streams 2026-07-30 10:50:00 +02:00
fslog.c fs/ntfs3: fix out-of-bounds read in read_log_rec_buf() 2026-08-18 10:35:38 +02:00
fsntfs.c fs/ntfs3: Add basic support for alternative data streams 2026-07-30 10:50:00 +02:00
index.c fs/ntfs3: Fix memory leak in indx_find_sort() 2026-07-30 10:49:41 +02:00
inode.c fs/ntfs3: use d_instantiate_new() in ntfs_create_inode() and murder syzbot's "WARNING in do_new_mount" saga 2026-09-10 09:22:06 +02:00
Kconfig ntfs: add Kconfig and Makefile 2026-02-19 21:51:00 +09:00
lznt.c fs/ntfs3: cosmetic fixes and improvements 2026-07-14 18:41:16 +02:00
Makefile fs/ntfs3: add a subset of W=1 warnings for stricter checks 2026-03-04 10:28:25 +01:00
namei.c Changes for 7.3-rc1 2026-08-20 12:27:02 -07:00
ntfs.h fs/ntfs3: Add basic support for alternative data streams 2026-07-30 10:50:00 +02:00
ntfs_fs.h ntfs3: free replaced mount options after a grace period 2026-10-14 22:08:04 +02:00
record.c fs/ntfs3: reject out-of-range evcn in mi_enum_attr() 2026-08-14 08:50:16 +02:00
run.c fs/ntfs3: cosmetic fixes and improvements 2026-07-14 18:41:16 +02:00
super.c ntfs3: free replaced mount options after a grace period 2026-10-14 22:08:04 +02:00
upcase.c fs/ntfs3: Add option "nocase" 2022-09-30 17:39:47 +03:00
xattr.c fs/ntfs3: validate ef->size covers the record's name and value 2026-08-18 10:35:39 +02:00