syzbot


KASAN: out-of-bounds Read in ntfs_set_ea

Status: fixed on 2023/02/24 13:50
Subsystems: ntfs3
[Documentation on labels]
Reported-by: syzbot+8778f030156c6cd16d72@syzkaller.appspotmail.com
Fix commit: 0e8235d28f3a fs/ntfs3: Check fields while reading
First crash: 447d, last: 441d
Cause bisection: failed (error log, bisect log)
  
Fix bisection: fixed by (bisect log) :
commit 0e8235d28f3a0e9eda9f02ff67ee566d5f42b66b
Author: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
Date: Mon Oct 10 10:15:33 2022 +0000

  fs/ntfs3: Check fields while reading

  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] KASAN: out-of-bounds Read in ntfs_set_ea 1 (3) 2023/02/01 07:54

Sample crash report:
loop0: detected capacity change from 0 to 4096
ntfs3: loop0: Different NTFS' sector size (2048) and media sector size (512)
==================================================================
BUG: KASAN: out-of-bounds in ntfs_set_ea+0xcb5/0x1760 fs/ntfs3/xattr.c:336
Read of size 18446744069414584420 at addr ffff88824a6c8610 by task syz-executor228/3632

CPU: 0 PID: 3632 Comm: syz-executor228 Not tainted 6.1.0-syzkaller-03295-g02bf43c7b7f7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x1b1/0x28e lib/dump_stack.c:106
 print_address_description+0x74/0x340 mm/kasan/report.c:284
 print_report+0x107/0x1f0 mm/kasan/report.c:395
 kasan_report+0xcd/0x100 mm/kasan/report.c:495
 kasan_check_range+0x2a7/0x2e0 mm/kasan/generic.c:189
 memmove+0x25/0x60 mm/kasan/shadow.c:54
 ntfs_set_ea+0xcb5/0x1760 fs/ntfs3/xattr.c:336
 ntfs_save_wsl_perm+0x1f4/0x490 fs/ntfs3/xattr.c:936
 ntfs3_setattr+0x959/0xb40 fs/ntfs3/file.c:817
 notify_change+0xe50/0x1100 fs/attr.c:482
 chown_common+0x5b6/0x910 fs/open.c:736
 do_fchownat+0x165/0x240 fs/open.c:767
 __do_sys_chown fs/open.c:787 [inline]
 __se_sys_chown fs/open.c:785 [inline]
 __x64_sys_chown+0x7e/0x90 fs/open.c:785
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f474c3a07c9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdedf21528 EFLAGS: 00000246 ORIG_RAX: 000000000000005c
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f474c3a07c9
RDX: 0000000039323420 RSI: 0000000000000000 RDI: 0000000020001d80
RBP: 00007f474c360060 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f474c3600f0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>

Memory state around the buggy address:
BUG: unable to handle page fault for address: ffffed10494d90a0
#PF: supervisor read access in kernel mode
#PF: error_code(0x0000) - not-present page
PGD 23ffee067 P4D 23ffee067 PUD 13fff4067 PMD 0 
Oops: 0000 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 3632 Comm: syz-executor228 Not tainted 6.1.0-syzkaller-03295-g02bf43c7b7f7 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 10/26/2022
RIP: 0010:memcpy_erms+0x6/0x10 arch/x86/lib/memcpy_64.S:56
Code: fe ff ff cc eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1 <f3> a4 c3 0f 1f 80 00 00 00 00 48 89 f8 48 83 fa 20 72 7e 40 38 fe
RSP: 0018:ffffc90003b2f688 EFLAGS: 00010086
RAX: ffffc90003b2f6a0 RBX: ffff88824a6c8500 RCX: 0000000000000010
RDX: 0000000000000010 RSI: ffffed10494d90a0 RDI: ffffc90003b2f6a0
RBP: ffffc90003b2f700 R08: ffffffff8a8ea68e R09: fffff52000765ed9
R10: fffff52000765ed9 R11: 1ffff92000765ed8 R12: ffffc90003b2f6a0
R13: ffff88824a6c8580 R14: 0000000000000100 R15: ffffc90003b2f6b0
FS:  00005555559cf300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffed10494d90a0 CR3: 00000000460de000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 print_memory_metadata mm/kasan/report.c:371 [inline]
 print_report+0x191/0x1f0 mm/kasan/report.c:396
 kasan_report+0xcd/0x100 mm/kasan/report.c:495
 kasan_check_range+0x2a7/0x2e0 mm/kasan/generic.c:189
 memmove+0x25/0x60 mm/kasan/shadow.c:54
 ntfs_set_ea+0xcb5/0x1760 fs/ntfs3/xattr.c:336
 ntfs_save_wsl_perm+0x1f4/0x490 fs/ntfs3/xattr.c:936
 ntfs3_setattr+0x959/0xb40 fs/ntfs3/file.c:817
 notify_change+0xe50/0x1100 fs/attr.c:482
 chown_common+0x5b6/0x910 fs/open.c:736
 do_fchownat+0x165/0x240 fs/open.c:767
 __do_sys_chown fs/open.c:787 [inline]
 __se_sys_chown fs/open.c:785 [inline]
 __x64_sys_chown+0x7e/0x90 fs/open.c:785
 do_syscall_x64 arch/x86/entry/common.c:50 [inline]
 do_syscall_64+0x3d/0xb0 arch/x86/entry/common.c:80
 entry_SYSCALL_64_after_hwframe+0x63/0xcd
RIP: 0033:0x7f474c3a07c9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 51 14 00 00 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 c0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffdedf21528 EFLAGS: 00000246 ORIG_RAX: 000000000000005c
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f474c3a07c9
RDX: 0000000039323420 RSI: 0000000000000000 RDI: 0000000020001d80
RBP: 00007f474c360060 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007f474c3600f0
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
 </TASK>
Modules linked in:
CR2: ffffed10494d90a0
---[ end trace 0000000000000000 ]---
RIP: 0010:memcpy_erms+0x6/0x10 arch/x86/lib/memcpy_64.S:56
Code: fe ff ff cc eb 1e 0f 1f 00 48 89 f8 48 89 d1 48 c1 e9 03 83 e2 07 f3 48 a5 89 d1 f3 a4 c3 66 0f 1f 44 00 00 48 89 f8 48 89 d1 <f3> a4 c3 0f 1f 80 00 00 00 00 48 89 f8 48 83 fa 20 72 7e 40 38 fe
RSP: 0018:ffffc90003b2f688 EFLAGS: 00010086
RAX: ffffc90003b2f6a0 RBX: ffff88824a6c8500 RCX: 0000000000000010
RDX: 0000000000000010 RSI: ffffed10494d90a0 RDI: ffffc90003b2f6a0
RBP: ffffc90003b2f700 R08: ffffffff8a8ea68e R09: fffff52000765ed9
R10: fffff52000765ed9 R11: 1ffff92000765ed8 R12: ffffc90003b2f6a0
R13: ffff88824a6c8580 R14: 0000000000000100 R15: ffffc90003b2f6b0
FS:  00005555559cf300(0000) GS:ffff8880b9800000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffed10494d90a0 CR3: 00000000460de000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess), 2 bytes skipped:
   0:	ff cc                	dec    %esp
   2:	eb 1e                	jmp    0x22
   4:	0f 1f 00             	nopl   (%rax)
   7:	48 89 f8             	mov    %rdi,%rax
   a:	48 89 d1             	mov    %rdx,%rcx
   d:	48 c1 e9 03          	shr    $0x3,%rcx
  11:	83 e2 07             	and    $0x7,%edx
  14:	f3 48 a5             	rep movsq %ds:(%rsi),%es:(%rdi)
  17:	89 d1                	mov    %edx,%ecx
  19:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi)
  1b:	c3                   	retq
  1c:	66 0f 1f 44 00 00    	nopw   0x0(%rax,%rax,1)
  22:	48 89 f8             	mov    %rdi,%rax
  25:	48 89 d1             	mov    %rdx,%rcx
* 28:	f3 a4                	rep movsb %ds:(%rsi),%es:(%rdi) <-- trapping instruction
  2a:	c3                   	retq
  2b:	0f 1f 80 00 00 00 00 	nopl   0x0(%rax)
  32:	48 89 f8             	mov    %rdi,%rax
  35:	48 83 fa 20          	cmp    $0x20,%rdx
  39:	72 7e                	jb     0xb9
  3b:	40 38 fe             	cmp    %dil,%sil

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/12/14 03:04 upstream 02bf43c7b7f7 f6511626 .config strace log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-upstream-fs KASAN: out-of-bounds Read in ntfs_set_ea
2022/12/20 09:22 upstream aeba12b26c79 c52b2efb .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: out-of-bounds Read in ntfs_set_ea
2022/12/16 00:41 upstream 041fae9c105a 6f9c033e .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: out-of-bounds Read in ntfs_set_ea
2022/12/14 02:47 upstream 02bf43c7b7f7 f6511626 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-fs KASAN: out-of-bounds Read in ntfs_set_ea
* Struck through repros no longer work on HEAD.