All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] KASAN: slab-use-after-free Read in ntfs_show_options
@ 2026-08-08 20:08 syzbot
  2026-08-09  2:56 ` Edward Adam Davis
  2026-08-09  6:07 ` [PATCH] ntfs3: Update only the member values without replacing the opts pointer Edward Adam Davis
  0 siblings, 2 replies; 4+ messages in thread
From: syzbot @ 2026-08-08 20:08 UTC (permalink / raw)
  To: linux-kernel, syzkaller-bugs

Hello,

syzbot found the following issue on:

HEAD commit:    0d8395707651 Merge tag 'soc-fixes-7.2-2' of git://git.kern..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1783bcc6580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=cb17729fb04b1e3a
dashboard link: https://syzkaller.appspot.com/bug?extid=4c22f022eb39c86b9d19
compiler:       Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15f877b9580000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+4c22f022eb39c86b9d19@syzkaller.appspotmail.com

==================================================================
==================================================================
BUG: KASAN: slab-use-after-free in ntfs_show_options+0x656/0x800 fs/ntfs3/super.c:762
Read of size 2 at addr ffff888030028d1c by task syz-executor377/6018

CPU: 0 UID: 0 PID: 6018 Comm: syz-executor377 Not tainted syzkaller #0 PREEMPT_{RT,(full)} 
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 07/16/2026
Call Trace:
 <TASK>
 dump_stack_lvl+0xe8/0x150 lib/dump_stack.c:120
 print_address_description+0x55/0x1e0 mm/kasan/report.c:378
 print_report+0x58/0x70 mm/kasan/report.c:482
 kasan_report+0x117/0x150 mm/kasan/report.c:595
 ntfs_show_options+0x656/0x800 fs/ntfs3/super.c:762
 show_vfsmnt+0x637/0x780 fs/proc_namespace.c:129
 seq_read_iter+0x8d6/0xcb0 fs/seq_file.c:273
 new_sync_read fs/read_write.c:493 [inline]
 vfs_read+0x59e/0xa90 fs/read_write.c:574
 ksys_read+0x156/0x270 fs/read_write.c:716
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x174/0x580 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f12f25c661e
Code: 08 0f 85 f5 e2 ff ff 49 89 fb 48 89 f0 48 89 d7 48 89 ce 4c 89 c2 4d 89 ca 4c 8b 44 24 08 4c 8b 4c 24 10 4c 89 5c 24 08 0f 05 <c3> 90 41 57 41 56 4d 89 c6 41 55 4d 89 cd 41 54 55 53 48 83 ec 08
RSP: 002b:00007f12ef560198 EFLAGS: 00000246 ORIG_RAX: 0000000000000000
RAX: ffffffffffffffda RBX: 00007f12ef5616c0 RCX: 00007f12f25c661e
RDX: 0000000000001000 RSI: 00007f12ef560200 RDI: 0000000000000005
RBP: 00007f12f260b03e R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f12ef560200
R13: 0000000000000000 R14: 00007fff2ed6d880 R15: 00007fff2ed6d968
 </TASK>

Allocated by task 6027:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 poison_kmalloc_redzone mm/kasan/common.c:398 [inline]
 __kasan_kmalloc+0x93/0xb0 mm/kasan/common.c:415
 kasan_kmalloc include/linux/kasan.h:263 [inline]
 __kmalloc_cache_noprof+0x3d2/0x6b0 mm/slub.c:5489
 _kmalloc_noprof include/linux/slab.h:988 [inline]
 _kzalloc_noprof include/linux/slab.h:1309 [inline]
 ntfs_init_fs_context+0x55/0x570 fs/ntfs3/super.c:1862
 alloc_fs_context+0x9a3/0xd00 fs/fs_context.c:295
 do_remount fs/namespace.c:3392 [inline]
 path_mount+0xc5e/0x1040 fs/namespace.c:4153
 do_mount fs/namespace.c:4174 [inline]
 __do_sys_mount fs/namespace.c:4390 [inline]
 __se_sys_mount+0x31d/0x420 fs/namespace.c:4367
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x174/0x580 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 6026:
 kasan_save_stack mm/kasan/common.c:57 [inline]
 kasan_save_track+0x3e/0x80 mm/kasan/common.c:78
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:584
 poison_slab_object mm/kasan/common.c:253 [inline]
 __kasan_slab_free+0x5c/0x80 mm/kasan/common.c:285
 kasan_slab_free include/linux/kasan.h:235 [inline]
 slab_free_hook mm/slub.c:2677 [inline]
 slab_free mm/slub.c:6377 [inline]
 kfree+0x1c5/0x6c0 mm/slub.c:6692
 put_fs_context+0x123/0xb00 fs/fs_context.c:498
 do_remount fs/namespace.c:3419 [inline]
 path_mount+0xef9/0x1040 fs/namespace.c:4153
 do_mount fs/namespace.c:4174 [inline]
 __do_sys_mount fs/namespace.c:4390 [inline]
 __se_sys_mount+0x31d/0x420 fs/namespace.c:4367
 do_syscall_x64 arch/x86/entry/syscall_64.c:63 [inline]
 do_syscall_64+0x174/0x580 arch/x86/entry/syscall_64.c:94
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff888030028d00
 which belongs to the cache kmalloc-32 of size 32
The buggy address is located 28 bytes inside of
 freed 32-byte region [ffff888030028d00, ffff888030028d20)

The buggy address belongs to the physical page:
page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x30028
flags: 0x80000000000000(node=0|zone=1)
page_type: f5(slab)
raw: 0080000000000000 ffff88813ffb2780 dead000000000100 dead000000000122
raw: 0000000000000000 0000000800400040 00000000f5000000 0000000000000000
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask 0xd2800(GFP_NOWAIT|__GFP_NORETRY|__GFP_COMP|__GFP_NOMEMALLOC), pid 2774, tgid 2774 (kworker/u8:4), ts 16704250728, free_ts 0
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f9/0x250 mm/page_alloc.c:1859
 prep_new_page mm/page_alloc.c:1867 [inline]
 get_page_from_freelist+0x262a/0x26a0 mm/page_alloc.c:3946
 __alloc_frozen_pages_noprof+0x18d/0x380 mm/page_alloc.c:5304
 alloc_slab_page mm/slub.c:3266 [inline]
 allocate_slab+0x79/0x5e0 mm/slub.c:3380
 new_slab mm/slub.c:3426 [inline]
 refill_objects+0x2d8/0x350 mm/slub.c:7310
 refill_sheaf mm/slub.c:2804 [inline]
 __pcs_replace_empty_main+0x330/0x690 mm/slub.c:4675
 alloc_from_pcs mm/slub.c:4773 [inline]
 slab_alloc_node mm/slub.c:4905 [inline]
 __kmalloc_cache_noprof+0x468/0x6b0 mm/slub.c:5485
 _kmalloc_noprof include/linux/slab.h:988 [inline]
 slab_free_hook mm/slub.c:2629 [inline]
 slab_free mm/slub.c:6377 [inline]
 kmem_cache_free+0x156/0x6c0 mm/slub.c:6504
 __fput_deferred+0x2df/0x3e0 fs/file_table.c:567
 fput_close+0x11f/0x240 fs/file_table.c:629
 path_openat+0x30d5/0x3850 fs/namei.c:4872
 do_file_open+0x23e/0x4a0 fs/namei.c:4892
 do_open_execat+0x12b/0x590 fs/exec.c:785
 alloc_bprm+0x24/0x640 fs/exec.c:1431
 class_bprm_constructor fs/exec.c:1497 [inline]
 kernel_execve+0x85/0x9c0 fs/exec.c:1889
 call_usermodehelper_exec_async+0x212/0x360 kernel/umh.c:109
page_owner free stack trace missing

Memory state around the buggy address:
 ffff888030028c00: fa fb fb fb fc fc fc fc fa fb fb fb fc fc fc fc
 ffff888030028c80: 00 00 00 fc fc fc fc fc fa fb fb fb fc fc fc fc
>ffff888030028d00: fa fb fb fb fc fc fc fc 00 00 04 fc fc fc fc fc
                            ^
 ffff888030028d80: 00 00 07 fc fc fc fc fc 00 00 07 fc fc fc fc fc
 ffff888030028e00: 00 00 00 fc fc fc fc fc 00 00 00 fc fc fc fc fc
==================================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [syzbot] KASAN: slab-use-after-free Read in ntfs_show_options
  2026-08-08 20:08 [syzbot] KASAN: slab-use-after-free Read in ntfs_show_options syzbot
@ 2026-08-09  2:56 ` Edward Adam Davis
  2026-08-09  6:02   ` syzbot
  2026-08-09  6:07 ` [PATCH] ntfs3: Update only the member values without replacing the opts pointer Edward Adam Davis
  1 sibling, 1 reply; 4+ messages in thread
From: Edward Adam Davis @ 2026-08-09  2:56 UTC (permalink / raw)
  To: syzbot+4c22f022eb39c86b9d19; +Cc: linux-kernel, syzkaller-bugs

#syz test: upstream master

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 3305fe406cb2..58540491e68b 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -461,7 +461,7 @@ static int ntfs_fs_reconfigure(struct fs_context *fc)
 	}
 
 	sync_filesystem(sb);
-	swap(sbi->options, fc->fs_private);
+	memcpy(sbi->options, fc->fs_private, sizeof(*sbi->options));
 
 	return 0;
 }


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [syzbot] KASAN: slab-use-after-free Read in ntfs_show_options
  2026-08-09  2:56 ` Edward Adam Davis
@ 2026-08-09  6:02   ` syzbot
  0 siblings, 0 replies; 4+ messages in thread
From: syzbot @ 2026-08-09  6:02 UTC (permalink / raw)
  To: eadavis, linux-kernel, syzkaller-bugs

Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-by: syzbot+4c22f022eb39c86b9d19@syzkaller.appspotmail.com
Tested-by: syzbot+4c22f022eb39c86b9d19@syzkaller.appspotmail.com

Tested on:

commit:         06cf6189 Merge tag 'x86-urgent-2026-08-08' of git://gi..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=1735e132580000
kernel config:  https://syzkaller.appspot.com/x/.config?x=6ddb3079499f48cb
dashboard link: https://syzkaller.appspot.com/bug?extid=4c22f022eb39c86b9d19
compiler:       Debian clang version 22.1.8 (++20260613092233+e80beda6e255-1~exp1~20260613092250.77), Debian LLD 22.1.8
patch:          https://syzkaller.appspot.com/x/patch.diff?x=143fbfb9580000

Note: testing is done by a robot and is best-effort only.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ntfs3: Update only the member values without replacing the opts pointer
  2026-08-08 20:08 [syzbot] KASAN: slab-use-after-free Read in ntfs_show_options syzbot
  2026-08-09  2:56 ` Edward Adam Davis
@ 2026-08-09  6:07 ` Edward Adam Davis
  1 sibling, 0 replies; 4+ messages in thread
From: Edward Adam Davis @ 2026-08-09  6:07 UTC (permalink / raw)
  To: syzbot+4c22f022eb39c86b9d19
  Cc: almaz.alexandrovich, ntfs3, linux-kernel, syzkaller-bugs

There is a potential race condition when accessing options during remount
and read operations. This would trigger a uaf [1].

CPU0: remount				CPU1: read options
==================================	==================
do_remount()
reconfigure_super()
 ntfs_fs_reconfigure()
  sbi->options = fc->fs_private
put_fs_context()
 ntfs_fs_free()
  put_mount_options()			ntfs_show_options()
   kfree(sbi->options)			 opts = sbi->options
				         opts->dmask //trigger uaf

The fix involves not updating the sbi->options pointer during
reconfiguration, but instead using fc->fs_private to update the
corresponding member values.

[1]
BUG: KASAN: slab-use-after-free in ntfs_show_options+0x656/0x800 fs/ntfs3/super.c:762
Call Trace:
 ntfs_show_options+0x656/0x800 fs/ntfs3/super.c:762
 show_vfsmnt+0x637/0x780 fs/proc_namespace.c:129
 seq_read_iter+0x8d6/0xcb0 fs/seq_file.c:273
 new_sync_read fs/read_write.c:493 [inline]
 vfs_read+0x59e/0xa90 fs/read_write.c:574

Allocated by task 6027:
 ntfs_init_fs_context+0x55/0x570 fs/ntfs3/super.c:1862
 alloc_fs_context+0x9a3/0xd00 fs/fs_context.c:295
 do_remount fs/namespace.c:3392 [inline]
 path_mount+0xc5e/0x1040 fs/namespace.c:4153
 do_mount fs/namespace.c:4174 [inline]

Freed by task 6026:
 kfree+0x1c5/0x6c0 mm/slub.c:6692
 put_fs_context+0x123/0xb00 fs/fs_context.c:498
 do_remount fs/namespace.c:3419 [inline]
 path_mount+0xef9/0x1040 fs/namespace.c:4153
 do_mount fs/namespace.c:4174 [inline]

Fixes: cd39981fb92a ("fs/ntfs3: Fix double free on remount")
Reported-by: syzbot+4c22f022eb39c86b9d19@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=4c22f022eb39c86b9d19
Tested-by: syzbot+4c22f022eb39c86b9d19@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 fs/ntfs3/super.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index 3305fe406cb2..58540491e68b 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -461,7 +461,7 @@ static int ntfs_fs_reconfigure(struct fs_context *fc)
 	}
 
 	sync_filesystem(sb);
-	swap(sbi->options, fc->fs_private);
+	memcpy(sbi->options, fc->fs_private, sizeof(*sbi->options));
 
 	return 0;
 }
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-09  6:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-08 20:08 [syzbot] KASAN: slab-use-after-free Read in ntfs_show_options syzbot
2026-08-09  2:56 ` Edward Adam Davis
2026-08-09  6:02   ` syzbot
2026-08-09  6:07 ` [PATCH] ntfs3: Update only the member values without replacing the opts pointer Edward Adam Davis

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.