syzbot


KASAN: use-after-free Read in diFree

Status: fixed on 2023/10/30 11:46
Bug presence: origin:lts-only
[Documentation on labels]
Reported-by: syzbot+5d27913a927bee249e21@syzkaller.appspotmail.com
Fix commit: 4de3a603010e jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount
First crash: 581d, last: 420d
Fix bisection: fixed by (bisect log) :
commit 4de3a603010e0ca334487de24c6aab0777b7f808
Author: Liu Shixin via Jfs-discussion <jfs-discussion@lists.sourceforge.net>
Date: Thu Dec 1 12:46:28 2022 +0000

  jfs: fix invalid free of JFS_IP(ipimap)->i_imap in diUnmount

  
Bug presence (2)
Date Name Commit Repro Result
2023/09/01 linux-6.1.y (ToT) a2943d2d9a00 C [report] KASAN: use-after-free Read in diFree
2023/09/01 upstream (ToT) b84acc11b1c9 C Didn't crash
Similar bugs (11)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
linux-5.15 KASAN: use-after-free Read in diFree C error 5 521d 593d 0/3 auto-obsoleted due to no activity on 2023/10/07 20:25
linux-4.19 KASAN: use-after-free Read in diFree jfs C error 21 662d 1500d 0/1 upstream: reported C repro on 2020/10/13 01:51
upstream KASAN: use-after-free Read in diFree jfs C inconclusive unreliable 110 327d 975d 0/28 auto-obsoleted due to no activity on 2024/03/22 04:27
linux-4.14 KASAN: use-after-free Read in diFree jfs C error 3 640d 1513d 0/1 upstream: reported C repro on 2020/09/30 00:31
linux-4.19 BUG: unable to handle kernel paging request in diFree C done 18 1222d 1514d 1/1 fixed on 2021/08/17 00:59
linux-4.14 general protection fault in diFree 1 1392d 1392d 0/1 auto-closed as invalid on 2021/05/28 19:31
linux-4.14 general protection fault in diFree (2) C 2 632d 1037d 0/1 upstream: reported C repro on 2022/01/18 19:31
upstream BUG: unable to handle kernel paging request in diFree jfs C done 13 1244d 1515d 20/28 fixed on 2021/11/10 00:50
linux-5.15 UBSAN: array-index-out-of-bounds in diFree origin:upstream missing-backport C done 13 98d 144d 3/3 fixed on 2024/09/19 18:24
linux-4.14 BUG: unable to handle kernel paging request in diFree C 5 640d 1519d 0/1 upstream: reported C repro on 2020/09/23 16:53
upstream UBSAN: array-index-out-of-bounds in diFree jfs C inconclusive 226 101d 211d 27/28 fixed on 2024/08/14 03:44
Fix bisection attempts (2)
Created Duration User Patch Repo Result
2023/10/30 02:06 3h51m bisect fix linux-6.1.y OK (1) job log
2023/09/01 16:00 1h39m bisect fix linux-6.1.y OK (0) job log log

Sample crash report:
loop0: detected capacity change from 0 to 14901
read_mapping_page failed!
jfs_mount: diMount failed w/rc = -5
==================================================================
BUG: KASAN: use-after-free in diFree+0x17ac/0x2648 fs/jfs/jfs_imap.c:871
Read of size 4 at addr ffff0000d8130004 by task syz-executor453/4290

CPU: 0 PID: 4290 Comm: syz-executor453 Not tainted 6.1.29-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 04/28/2023
Call trace:
 dump_backtrace+0x1c8/0x1f4 arch/arm64/kernel/stacktrace.c:158
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:165
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x108/0x170 lib/dump_stack.c:106
 print_address_description mm/kasan/report.c:284 [inline]
 print_report+0x174/0x4c0 mm/kasan/report.c:395
 kasan_report+0xd4/0x130 mm/kasan/report.c:495
 __asan_report_load4_noabort+0x2c/0x38 mm/kasan/report_generic.c:350
 diFree+0x17ac/0x2648 fs/jfs/jfs_imap.c:871
 jfs_evict_inode+0x2d0/0x3f4 fs/jfs/inode.c:156
 evict+0x260/0x68c fs/inode.c:664
 iput_final fs/inode.c:1747 [inline]
 iput+0x7c0/0x8a4 fs/inode.c:1773
 diFreeSpecial+0x78/0x108 fs/jfs/jfs_imap.c:548
 jfs_mount+0x53c/0x7a4 fs/jfs/jfs_mount.c:203
 jfs_fill_super+0x464/0x9f0 fs/jfs/super.c:556
 mount_bdev+0x26c/0x368 fs/super.c:1423
 jfs_do_mount+0x44/0x58 fs/jfs/super.c:670
 legacy_get_tree+0xd4/0x16c fs/fs_context.c:610
 vfs_get_tree+0x90/0x274 fs/super.c:1553
 do_new_mount+0x25c/0x8c8 fs/namespace.c:3040
 path_mount+0x590/0xe58 fs/namespace.c:3370
 do_mount fs/namespace.c:3383 [inline]
 __do_sys_mount fs/namespace.c:3591 [inline]
 __se_sys_mount fs/namespace.c:3568 [inline]
 __arm64_sys_mount+0x45c/0x594 fs/namespace.c:3568
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

Allocated by task 3840:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
 kasan_save_alloc_info+0x24/0x30 mm/kasan/generic.c:505
 ____kasan_kmalloc mm/kasan/common.c:374 [inline]
 __kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:383
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slab_common.c:955 [inline]
 __kmalloc+0xd8/0x1c4 mm/slab_common.c:968
 kmalloc include/linux/slab.h:558 [inline]
 tomoyo_realpath_from_path+0xc8/0x4cc security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x208/0x568 security/tomoyo/file.c:822
 tomoyo_inode_getattr+0x28/0x38 security/tomoyo/tomoyo.c:122
 security_inode_getattr+0xd8/0x124 security/security.c:1347
 vfs_getattr fs/stat.c:158 [inline]
 vfs_statx+0x184/0x420 fs/stat.c:233
 vfs_fstatat fs/stat.c:267 [inline]
 __do_sys_newfstatat fs/stat.c:437 [inline]
 __se_sys_newfstatat fs/stat.c:431 [inline]
 __arm64_sys_newfstatat+0x134/0x1c0 fs/stat.c:431
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

Freed by task 3840:
 kasan_save_stack mm/kasan/common.c:45 [inline]
 kasan_set_track+0x4c/0x80 mm/kasan/common.c:52
 kasan_save_free_info+0x38/0x5c mm/kasan/generic.c:516
 ____kasan_slab_free+0x144/0x1c0 mm/kasan/common.c:236
 __kasan_slab_free+0x18/0x28 mm/kasan/common.c:244
 kasan_slab_free include/linux/kasan.h:177 [inline]
 slab_free_hook mm/slub.c:1724 [inline]
 slab_free_freelist_hook mm/slub.c:1750 [inline]
 slab_free mm/slub.c:3661 [inline]
 __kmem_cache_free+0x2c0/0x4b4 mm/slub.c:3674
 kfree+0xcc/0x1b8 mm/slab_common.c:1007
 tomoyo_realpath_from_path+0x484/0x4cc security/tomoyo/realpath.c:286
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x208/0x568 security/tomoyo/file.c:822
 tomoyo_inode_getattr+0x28/0x38 security/tomoyo/tomoyo.c:122
 security_inode_getattr+0xd8/0x124 security/security.c:1347
 vfs_getattr fs/stat.c:158 [inline]
 vfs_statx+0x184/0x420 fs/stat.c:233
 vfs_fstatat fs/stat.c:267 [inline]
 __do_sys_newfstatat fs/stat.c:437 [inline]
 __se_sys_newfstatat fs/stat.c:431 [inline]
 __arm64_sys_newfstatat+0x134/0x1c0 fs/stat.c:431
 __invoke_syscall arch/arm64/kernel/syscall.c:38 [inline]
 invoke_syscall+0x98/0x2c0 arch/arm64/kernel/syscall.c:52
 el0_svc_common+0x138/0x258 arch/arm64/kernel/syscall.c:142
 do_el0_svc+0x64/0x218 arch/arm64/kernel/syscall.c:206
 el0_svc+0x58/0x168 arch/arm64/kernel/entry-common.c:637
 el0t_64_sync_handler+0x84/0xf0 arch/arm64/kernel/entry-common.c:655
 el0t_64_sync+0x18c/0x190 arch/arm64/kernel/entry.S:581

The buggy address belongs to the object at ffff0000d8130000
 which belongs to the cache kmalloc-4k of size 4096
The buggy address is located 4 bytes inside of
 4096-byte region [ffff0000d8130000, ffff0000d8131000)

The buggy address belongs to the physical page:
page:00000000896df55b refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x118130
head:00000000896df55b order:3 compound_mapcount:0 compound_pincount:0
flags: 0x5ffc00000010200(slab|head|node=0|zone=2|lastcpupid=0x7ff)
raw: 05ffc00000010200 fffffc000354b800 dead000000000003 ffff0000c0002a80
raw: 0000000000000000 0000000000040004 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000d812ff00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
 ffff0000d812ff80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc
>ffff0000d8130000: fa fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                   ^
 ffff0000d8130080: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff0000d8130100: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
imap: 00000000d883ed5a: c7481500 ffff0000 00000f00 06600263
imap: 000000001ff316ea: 00000000 00000000 00000000 00000000
ERROR: (device loop0): diFree: inum = 2, iagno = 0, nextiag = -65536

Mount JFS Failure: -5
jfs_mount failed w/return code = -5

Crashes (7):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2023/05/24 00:45 linux-6.1.y fa74641fb6b9 4bce1a3e .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in diFree
2023/06/24 23:30 linux-6.1.y e84a4e368abe 79782afc .config console log report syz C [disk image] [vmlinux] [kernel image] [mounted in repro] ci2-linux-6-1-kasan KASAN: use-after-free Read in diFree
2023/06/18 08:19 linux-6.1.y ca87e77a2ef8 f3921d4d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in diFree
2023/05/24 00:26 linux-6.1.y fa74641fb6b9 4bce1a3e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in diFree
2023/04/20 07:00 linux-6.1.y 0102425ac76b a219f34e .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 KASAN: use-after-free Read in diFree
2023/09/27 17:58 linux-6.1.y d23900f974e0 2895a507 .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan general protection fault in diFree
2023/09/28 03:29 linux-6.1.y d23900f974e0 c2ab1e5d .config console log report info [disk image] [vmlinux] [kernel image] ci2-linux-6-1-kasan-arm64 BUG: unable to handle kernel paging request in diFree
* Struck through repros no longer work on HEAD.