syzbot


KASAN: slab-out-of-bounds Read in exfat_clear_bitmap

Status: upstream: reported C repro on 2022/04/17 06:35
Reported-by: syzbot+a4087e40b9c13aad7892@syzkaller.appspotmail.com
Fix commit: 82f723b8a5ad exfat: check if cluster num is valid
Patched on: [ci2-android-5-10 ci2-android-5-10-perf], missing on: []
First crash: 711d, last: 711d
Cause bisection: failed (error log, bisect log)
  
Discussions (6)
Title Replies (including bot) Last reply
[PATCH 5.10 00/53] 5.10.120-rc1 review 60 (60) 2022/06/06 08:43
[PATCH 5.18 00/67] 5.18.2-rc1 review 75 (75) 2022/06/05 07:38
[PATCH 5.15 00/66] 5.15.45-rc1 review 73 (73) 2022/06/05 04:15
[PATCH 5.17 00/75] 5.17.13-rc1 review 82 (82) 2022/06/04 19:32
[PATCH v2 1/2] exfat: move is_valid_cluster to a common header 7 (7) 2022/05/16 23:38
[PATCH] exfat: check if cluster num is valid 5 (5) 2022/05/10 22:52
Last patch testing requests (5)
Created Duration User Patch Repo Result
2022/08/30 23:27 13m retest repro android12-5.10-lts OK log
2022/05/11 19:29 13m tadeusz.struk@linaro.org patch https://android.googlesource.com/kernel/common android12-5.10 OK
2022/05/11 19:08 0m tadeusz.struk@linaro.org patch https://android.googlesource.com/kernel/common android12-5.10 error OK
2022/04/18 17:55 8m tadeusz.struk@linaro.org patch https://android.googlesource.com/kernel/common android12-5.10 OK
2022/04/18 17:42 10m tadeusz.struk@linaro.org patch git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master OK

Sample crash report:
exFAT-fs (loop0): failed to load upcase table (idx : 0x00000c00, chksum : 0x00000000, utbl_chksum : 0xe619d30d)
==================================================================
BUG: KASAN: slab-out-of-bounds in exfat_clear_bitmap+0x147/0x490 fs/exfat/balloc.c:174
Read of size 8 at addr ffff888115aa9508 by task syz-executor251/365

CPU: 1 PID: 365 Comm: syz-executor251 Not tainted 5.10.109-syzkaller-00693-g414e6c8e941c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
 __dump_stack lib/dump_stack.c:77 [inline]
 dump_stack_lvl+0x1e2/0x24b lib/dump_stack.c:118
 print_address_description+0x81/0x3c0 mm/kasan/report.c:233
 __kasan_report mm/kasan/report.c:419 [inline]
 kasan_report+0x1a4/0x1f0 mm/kasan/report.c:436
 __asan_report_load8_noabort+0x14/0x20 mm/kasan/report_generic.c:309
 exfat_clear_bitmap+0x147/0x490 fs/exfat/balloc.c:174
 exfat_free_cluster+0x25a/0x4a0 fs/exfat/fatent.c:181
 __exfat_truncate+0x99e/0xe00 fs/exfat/file.c:217
 exfat_truncate+0x11b/0x4f0 fs/exfat/file.c:243
 exfat_setattr+0xa03/0xd40 fs/exfat/file.c:339
 notify_change+0xb76/0xe10 fs/attr.c:336
 do_truncate+0x1ea/0x2d0 fs/open.c:65
 handle_truncate fs/namei.c:2989 [inline]
 do_open fs/namei.c:3331 [inline]
 path_openat+0x294e/0x2fd0 fs/namei.c:3444
 do_filp_open+0x200/0x440 fs/namei.c:3471
 do_sys_openat2+0x13b/0x470 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_creat fs/open.c:1301 [inline]
 __se_sys_creat fs/open.c:1295 [inline]
 __x64_sys_creat+0x11f/0x160 fs/open.c:1295
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fd02eed02d9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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:00007ffcafe06f88 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 0030656c69662f2e RCX: 00007fd02eed02d9
RDX: 00007fd02eed02d9 RSI: 0000000000000000 RDI: 0000000020000080
RBP: 00007fd02ee8fb70 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fd02ee8fc00
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000

Allocated by task 365:
 kasan_save_stack mm/kasan/common.c:38 [inline]
 kasan_set_track mm/kasan/common.c:46 [inline]
 set_alloc_info mm/kasan/common.c:428 [inline]
 ____kasan_kmalloc+0xdc/0x110 mm/kasan/common.c:507
 __kasan_kmalloc+0x9/0x10 mm/kasan/common.c:516
 kasan_kmalloc include/linux/kasan.h:269 [inline]
 __kmalloc+0x1f7/0x360 mm/slub.c:4042
 kmalloc_array include/linux/slab.h:592 [inline]
 exfat_allocate_bitmap fs/exfat/balloc.c:72 [inline]
 exfat_load_bitmap+0x511/0xae0 fs/exfat/balloc.c:120
 __exfat_fill_super fs/exfat/super.c:595 [inline]
 exfat_fill_super+0x1101/0x2ab0 fs/exfat/super.c:645
 get_tree_bdev+0x417/0x640 fs/super.c:1344
 exfat_get_tree+0x1c/0x20 fs/exfat/super.c:717
 vfs_get_tree+0x88/0x290 fs/super.c:1549
 do_new_mount+0x289/0xad0 fs/namespace.c:2899
 path_mount+0x58d/0xce0 fs/namespace.c:3229
 do_mount fs/namespace.c:3242 [inline]
 __do_sys_mount fs/namespace.c:3450 [inline]
 __se_sys_mount+0x2d2/0x3c0 fs/namespace.c:3427
 __x64_sys_mount+0xbf/0xd0 fs/namespace.c:3427
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The buggy address belongs to the object at ffff888115aa9500
 which belongs to the cache kmalloc-8 of size 8
The buggy address is located 0 bytes to the right of
 8-byte region [ffff888115aa9500, ffff888115aa9508)
The buggy address belongs to the page:
page:ffffea000456aa40 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x115aa9
flags: 0x8000000000000200(slab)
raw: 8000000000000200 dead000000000100 dead000000000122 ffff888100043c80
raw: 0000000000000000 0000000080660066 00000001ffffffff 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 0x12cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY), pid 198, ts 4174522057, free_ts 4174389097
 set_page_owner include/linux/page_owner.h:35 [inline]
 post_alloc_hook mm/page_alloc.c:2385 [inline]
 prep_new_page mm/page_alloc.c:2391 [inline]
 get_page_from_freelist+0x745/0x760 mm/page_alloc.c:4063
 __alloc_pages_nodemask+0x3b6/0x890 mm/page_alloc.c:5113
 alloc_slab_page mm/slub.c:1815 [inline]
 allocate_slab+0x78/0x540 mm/slub.c:1817
 new_slab mm/slub.c:1878 [inline]
 new_slab_objects mm/slub.c:2637 [inline]
 ___slab_alloc+0x131/0x2e0 mm/slub.c:2800
 __slab_alloc+0x63/0xa0 mm/slub.c:2840
 slab_alloc_node mm/slub.c:2922 [inline]
 slab_alloc mm/slub.c:2964 [inline]
 __kmalloc+0x24f/0x360 mm/slub.c:4038
 __kmalloc_node include/linux/slab.h:418 [inline]
 kmalloc_node include/linux/slab.h:575 [inline]
 kvmalloc_node+0x82/0x130 mm/util.c:580
 kvmalloc include/linux/mm.h:822 [inline]
 kvzalloc include/linux/mm.h:830 [inline]
 proc_sys_call_handler+0x3d5/0x870 fs/proc/proc_sysctl.c:574
 proc_sys_write+0x22/0x30 fs/proc/proc_sysctl.c:617
 call_write_iter include/linux/fs.h:1947 [inline]
 new_sync_write fs/read_write.c:518 [inline]
 vfs_write+0xc1c/0xf40 fs/read_write.c:605
 ksys_write+0x198/0x2c0 fs/read_write.c:658
 __do_sys_write fs/read_write.c:670 [inline]
 __se_sys_write fs/read_write.c:667 [inline]
 __x64_sys_write+0x7b/0x90 fs/read_write.c:667
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
page last free stack trace:
 reset_page_owner include/linux/page_owner.h:28 [inline]
 free_pages_prepare mm/page_alloc.c:1331 [inline]
 free_pcp_prepare+0x18c/0x1c0 mm/page_alloc.c:1405
 free_unref_page_prepare mm/page_alloc.c:3291 [inline]
 free_unref_page mm/page_alloc.c:3341 [inline]
 free_the_page mm/page_alloc.c:5172 [inline]
 __free_pages+0x2e0/0x4a0 mm/page_alloc.c:5180
 free_pages+0x7c/0x90 mm/page_alloc.c:5191
 selinux_genfs_get_sid+0x209/0x250 security/selinux/hooks.c:1326
 inode_doinit_with_dentry+0x858/0x1030 security/selinux/hooks.c:1523
 selinux_d_instantiate+0x27/0x40 security/selinux/hooks.c:6351
 security_d_instantiate+0xa5/0x100 security/security.c:1948
 d_splice_alias+0x71/0x3b0 fs/dcache.c:3029
 proc_sys_lookup+0x6d5/0x7e0 fs/proc/proc_sysctl.c:535
 lookup_open fs/namei.c:3162 [inline]
 open_last_lookups fs/namei.c:3253 [inline]
 path_openat+0x119a/0x2fd0 fs/namei.c:3441
 do_filp_open+0x200/0x440 fs/namei.c:3471
 do_sys_openat2+0x13b/0x470 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_openat fs/open.c:1243 [inline]
 __se_sys_openat fs/open.c:1238 [inline]
 __x64_sys_openat+0x243/0x290 fs/open.c:1238
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

Memory state around the buggy address:
 ffff888115aa9400: fc fc fa fc fc fc fc fa fc fc fc fc fa fc fc fc
 ffff888115aa9480: fc fa fc fc fc fc 00 fc fc fc fc 00 fc fc fc fc
>ffff888115aa9500: 00 fc fc fc fc 00 fc fc fc fc fa fc fc fc fc 00
                      ^
 ffff888115aa9580: fc fc fc fc fa fc fc fc fc fa fc fc fc fc fa fc
 ffff888115aa9600: fc fc fc fa fc fc fc fc fc fc fc fc fc fa fc fc
==================================================================
general protection fault, probably for non-canonical address 0xf9bffc1cc0000032: 0000 [#1] PREEMPT SMP KASAN
KASAN: maybe wild-memory-access in range [0xce0000e600000190-0xce0000e600000197]
CPU: 1 PID: 365 Comm: syz-executor251 Tainted: G    B             5.10.109-syzkaller-00693-g414e6c8e941c #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:exfat_clear_bitmap+0x163/0x490 fs/exfat/balloc.c:174
Code: 80 3c 08 00 74 08 48 89 df e8 39 26 af ff 44 23 75 b0 4c 8b 23 49 83 c4 28 4c 89 e0 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 4c 89 e7 e8 0f 26 af ff 41 8d 46 3f 45 85 f6 41
RSP: 0018:ffffc90000bf7420 EFLAGS: 00010a03
RAX: 19c0001cc0000032 RBX: ffff888115aa9508 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000286 RDI: 0000000000000001
RBP: ffffc90000bf7490 R08: ffffffff813efad3 R09: fffffbfff0d85cf9
R10: fffffbfff0d85cf9 R11: 1ffffffff0d85cf8 R12: ce0000e600000195
R13: 1ffff11020eb500c R14: 0000000000000000 R15: 0000000000000008
FS:  0000555557200300(0000) GS:ffff8881f7100000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 000055f229b3b0d8 CR3: 00000001077ad000 CR4: 00000000003506a0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 exfat_free_cluster+0x25a/0x4a0 fs/exfat/fatent.c:181
 __exfat_truncate+0x99e/0xe00 fs/exfat/file.c:217
 exfat_truncate+0x11b/0x4f0 fs/exfat/file.c:243
 exfat_setattr+0xa03/0xd40 fs/exfat/file.c:339
 notify_change+0xb76/0xe10 fs/attr.c:336
 do_truncate+0x1ea/0x2d0 fs/open.c:65
 handle_truncate fs/namei.c:2989 [inline]
 do_open fs/namei.c:3331 [inline]
 path_openat+0x294e/0x2fd0 fs/namei.c:3444
 do_filp_open+0x200/0x440 fs/namei.c:3471
 do_sys_openat2+0x13b/0x470 fs/open.c:1211
 do_sys_open fs/open.c:1227 [inline]
 __do_sys_creat fs/open.c:1301 [inline]
 __se_sys_creat fs/open.c:1295 [inline]
 __x64_sys_creat+0x11f/0x160 fs/open.c:1295
 do_syscall_64+0x34/0x70 arch/x86/entry/common.c:46
 entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x7fd02eed02d9
Code: ff ff c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 40 00 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:00007ffcafe06f88 EFLAGS: 00000246 ORIG_RAX: 0000000000000055
RAX: ffffffffffffffda RBX: 0030656c69662f2e RCX: 00007fd02eed02d9
RDX: 00007fd02eed02d9 RSI: 0000000000000000 RDI: 0000000020000080
RBP: 00007fd02ee8fb70 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fd02ee8fc00
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
Modules linked in:
---[ end trace dd7d39fc867eb4c8 ]---
RIP: 0010:exfat_clear_bitmap+0x163/0x490 fs/exfat/balloc.c:174
Code: 80 3c 08 00 74 08 48 89 df e8 39 26 af ff 44 23 75 b0 4c 8b 23 49 83 c4 28 4c 89 e0 48 c1 e8 03 48 b9 00 00 00 00 00 fc ff df <80> 3c 08 00 74 08 4c 89 e7 e8 0f 26 af ff 41 8d 46 3f 45 85 f6 41
RSP: 0018:ffffc90000bf7420 EFLAGS: 00010a03
RAX: 19c0001cc0000032 RBX: ffff888115aa9508 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000286 RDI: 0000000000000001
RBP: ffffc90000bf7490 R08: ffffffff813efad3 R09: fffffbfff0d85cf9
R10: fffffbfff0d85cf9 R11: 1ffffffff0d85cf8 R12: ce0000e600000195
R13: 1ffff11020eb500c R14: 0000000000000000 R15: 0000000000000008
FS:  0000555557200300(0000) GS:ffff8881f7000000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007ffe84dd3e08 CR3: 00000001077ad000 CR4: 00000000003506b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
----------------
Code disassembly (best guess):
   0:	80 3c 08 00          	cmpb   $0x0,(%rax,%rcx,1)
   4:	74 08                	je     0xe
   6:	48 89 df             	mov    %rbx,%rdi
   9:	e8 39 26 af ff       	callq  0xffaf2647
   e:	44 23 75 b0          	and    -0x50(%rbp),%r14d
  12:	4c 8b 23             	mov    (%rbx),%r12
  15:	49 83 c4 28          	add    $0x28,%r12
  19:	4c 89 e0             	mov    %r12,%rax
  1c:	48 c1 e8 03          	shr    $0x3,%rax
  20:	48 b9 00 00 00 00 00 	movabs $0xdffffc0000000000,%rcx
  27:	fc ff df
* 2a:	80 3c 08 00          	cmpb   $0x0,(%rax,%rcx,1) <-- trapping instruction
  2e:	74 08                	je     0x38
  30:	4c 89 e7             	mov    %r12,%rdi
  33:	e8 0f 26 af ff       	callq  0xffaf2647
  38:	41 8d 46 3f          	lea    0x3f(%r14),%eax
  3c:	45 85 f6             	test   %r14d,%r14d
  3f:	41                   	rex.B

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2022/04/17 06:23 android12-5.10-lts 414e6c8e941c 8bcc32a6 .config console log report syz C ci2-android-5-10 KASAN: slab-out-of-bounds Read in exfat_clear_bitmap
2022/04/17 05:54 android12-5.10-lts 414e6c8e941c 8bcc32a6 .config console log report info ci2-android-5-10 KASAN: slab-out-of-bounds Read in exfat_clear_bitmap
* Struck through repros no longer work on HEAD.