syzbot


KASAN: slab-use-after-free Read in load_firmware_cb

Status: moderation: reported on 2024/08/01 15:42
Subsystems: media
[Documentation on labels]
Reported-by: syzbot+c0d0bc2375f98b7d45e3@syzkaller.appspotmail.com
First crash: 45d, last: 45d
Similar bugs (2)
Kernel Title Repro Cause bisect Fix bisect Count Last Reported Patched Status
upstream KASAN: use-after-free Read in load_firmware_cb usb media C 12 743d 1658d 0/27 auto-obsoleted due to no activity on 2023/11/09 13:12
linux-6.1 KASAN: use-after-free Read in load_firmware_cb 2 41d 42d 0/3 upstream: reported on 2024/08/01 11:50

Sample crash report:
==================================================================
BUG: KASAN: slab-use-after-free in load_firmware_cb+0x9c/0x1618 drivers/media/tuners/xc2028.c:1364
Read of size 8 at addr ffff0000f810c318 by task kworker/0:7/6431

CPU: 0 PID: 6431 Comm: kworker/0:7 Not tainted 6.10.0-rc7-syzkaller-gc912bf709078 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Workqueue: events request_firmware_work_func
Call trace:
 dump_backtrace+0x1b8/0x1e4 arch/arm64/kernel/stacktrace.c:317
 show_stack+0x2c/0x3c arch/arm64/kernel/stacktrace.c:324
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0xe4/0x150 lib/dump_stack.c:114
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x198/0x538 mm/kasan/report.c:488
 kasan_report+0xd8/0x138 mm/kasan/report.c:601
 __asan_report_load8_noabort+0x20/0x2c mm/kasan/report_generic.c:381
 load_firmware_cb+0x9c/0x1618 drivers/media/tuners/xc2028.c:1364
 request_firmware_work_func+0x150/0x214 drivers/base/firmware_loader/main.c:1167
 process_one_work+0x79c/0x15b8 kernel/workqueue.c:3248
 process_scheduled_works kernel/workqueue.c:3329 [inline]
 worker_thread+0x938/0xecc kernel/workqueue.c:3409
 kthread+0x288/0x310 kernel/kthread.c:389
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860

Allocated by task 10537:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x40/0x78 mm/kasan/common.c:68
 kasan_save_alloc_info+0x40/0x50 mm/kasan/generic.c:565
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0xac/0xc4 mm/kasan/common.c:387
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slub.c:4123 [inline]
 __kmalloc_noprof+0x2a0/0x494 mm/slub.c:4136
 kmalloc_noprof include/linux/slab.h:664 [inline]
 tomoyo_realpath_from_path+0xc8/0x4cc security/tomoyo/realpath.c:251
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x218/0x588 security/tomoyo/file.c:822
 tomoyo_inode_getattr+0x28/0x38 security/tomoyo/tomoyo.c:123
 security_inode_getattr+0xd8/0x124 security/security.c:2269
 vfs_getattr fs/stat.c:173 [inline]
 vfs_statx+0x188/0x46c fs/stat.c:248
 vfs_fstatat+0xc4/0x1b8 fs/stat.c:304
 __do_sys_newfstatat fs/stat.c:468 [inline]
 __se_sys_newfstatat fs/stat.c:462 [inline]
 __arm64_sys_newfstatat+0x114/0x19c fs/stat.c:462
 __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline]
 invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48
 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:131
 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:150
 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712
 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730
 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598

Freed by task 10537:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x40/0x78 mm/kasan/common.c:68
 kasan_save_free_info+0x54/0x6c mm/kasan/generic.c:579
 poison_slab_object+0x128/0x180 mm/kasan/common.c:240
 __kasan_slab_free+0x3c/0x70 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2196 [inline]
 slab_free mm/slub.c:4438 [inline]
 kfree+0x154/0x3e0 mm/slub.c:4559
 tomoyo_realpath_from_path+0x484/0x4cc security/tomoyo/realpath.c:286
 tomoyo_get_realpath security/tomoyo/file.c:151 [inline]
 tomoyo_path_perm+0x218/0x588 security/tomoyo/file.c:822
 tomoyo_inode_getattr+0x28/0x38 security/tomoyo/tomoyo.c:123
 security_inode_getattr+0xd8/0x124 security/security.c:2269
 vfs_getattr fs/stat.c:173 [inline]
 vfs_statx+0x188/0x46c fs/stat.c:248
 vfs_fstatat+0xc4/0x1b8 fs/stat.c:304
 __do_sys_newfstatat fs/stat.c:468 [inline]
 __se_sys_newfstatat fs/stat.c:462 [inline]
 __arm64_sys_newfstatat+0x114/0x19c fs/stat.c:462
 __invoke_syscall arch/arm64/kernel/syscall.c:34 [inline]
 invoke_syscall+0x98/0x2b8 arch/arm64/kernel/syscall.c:48
 el0_svc_common+0x130/0x23c arch/arm64/kernel/syscall.c:131
 do_el0_svc+0x48/0x58 arch/arm64/kernel/syscall.c:150
 el0_svc+0x54/0x168 arch/arm64/kernel/entry-common.c:712
 el0t_64_sync_handler+0x84/0xfc arch/arm64/kernel/entry-common.c:730
 el0t_64_sync+0x190/0x194 arch/arm64/kernel/entry.S:598

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

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x138108
head: order:3 mapcount:0 entire_mapcount:0 nr_pages_mapped:0 pincount:0
flags: 0x5ffc00000000040(head|node=0|zone=2|lastcpupid=0x7ff)
page_type: 0xffffefff(slab)
raw: 05ffc00000000040 ffff0000c0002140 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000040004 00000001ffffefff 0000000000000000
head: 05ffc00000000040 ffff0000c0002140 dead000000000122 0000000000000000
head: 0000000000000000 0000000000040004 00000001ffffefff 0000000000000000
head: 05ffc00000000003 fffffdffc3e04201 ffffffffffffffff 0000000000000000
head: 0000000000000008 0000000000000000 00000000ffffffff 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff0000f810c200: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff0000f810c280: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff0000f810c300: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                            ^
 ffff0000f810c380: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 ffff0000f810c400: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
==================================================================
Unable to handle kernel paging request at virtual address dfff800000000005
KASAN: null-ptr-deref in range [0x0000000000000028-0x000000000000002f]
Mem abort info:
  ESR = 0x0000000096000005
  EC = 0x25: DABT (current EL), IL = 32 bits
  SET = 0, FnV = 0
  EA = 0, S1PTW = 0
  FSC = 0x05: level 1 translation fault
Data abort info:
  ISV = 0, ISS = 0x00000005, ISS2 = 0x00000000
  CM = 0, WnR = 0, TnD = 0, TagAccess = 0
  GCS = 0, Overlay = 0, DirtyBit = 0, Xs = 0
[dfff800000000005] address between user and kernel address ranges
Internal error: Oops: 0000000096000005 [#1] PREEMPT SMP
Modules linked in:
CPU: 0 PID: 6431 Comm: kworker/0:7 Tainted: G    B              6.10.0-rc7-syzkaller-gc912bf709078 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 06/07/2024
Workqueue: events request_firmware_work_func
pstate: 80400005 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : load_firmware_cb+0x188/0x1618 drivers/media/tuners/xc2028.c:1369
lr : load_firmware_cb+0xbc/0x1618 drivers/media/tuners/xc2028.c:1367
sp : ffff8000a2397880
x29: ffff8000a23979e0 x28: 0000000000000000 x27: ffff700014472f28
x26: 0000000000000000 x25: 1ffff00014472f4c x24: 1fffe0001f021863
x23: ffff8000a2397940 x22: dfff800000000000 x21: ffff0000d8ce8d60
x20: dfff800000000000 x19: ffff0000f810c318 x18: 1fffe000367a3dde
x17: ffff80008f2dd000 x16: ffff800082f95f34 x15: 0000000000000001
x14: 1ffff000124e489c x13: 0000000000000000 x12: 0000000000000000
x11: ffff7000124e489d x10: 0000000000ff0100 x9 : 0000000000000000
x8 : 0000000000000005 x7 : 1fffe000367a3ddf x6 : ffff8000802a3bb0
x5 : 0000000000000000 x4 : 0000000000000001 x3 : ffff8000801c9a1c
x2 : 0000000000000001 x1 : 0000000000000000 x0 : 0000000000000028
Call trace:
 load_firmware_cb+0x188/0x1618 drivers/media/tuners/xc2028.c:1369
 request_firmware_work_func+0x150/0x214 drivers/base/firmware_loader/main.c:1167
 process_one_work+0x79c/0x15b8 kernel/workqueue.c:3248
 process_scheduled_works kernel/workqueue.c:3329 [inline]
 worker_thread+0x938/0xecc kernel/workqueue.c:3409
 kthread+0x288/0x310 kernel/kthread.c:389
 ret_from_fork+0x10/0x20 arch/arm64/kernel/entry.S:860
Code: 9100a380 d2d00016 d343fc08 f2fbfff6 (38746908) 
---[ end trace 0000000000000000 ]---
----------------
Code disassembly (best guess):
   0:	9100a380 	add	x0, x28, #0x28
   4:	d2d00016 	mov	x22, #0x800000000000        	// #140737488355328
   8:	d343fc08 	lsr	x8, x0, #3
   c:	f2fbfff6 	movk	x22, #0xdfff, lsl #48
* 10:	38746908 	ldrb	w8, [x8, x20] <-- trapping instruction

Crashes (2):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/07/28 15:39 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c912bf709078 46eb10b7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 KASAN: slab-use-after-free Read in load_firmware_cb
2024/07/28 20:19 git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux.git for-kernelci c912bf709078 46eb10b7 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-gce-arm64 BUG: unable to handle kernel paging request in load_firmware_cb
* Struck through repros no longer work on HEAD.