syzbot


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

Status: closed as dup on 2024/09/20 16:58
Subsystems: lsm
[Documentation on labels]
Reported-by: syzbot+a95cf48b5daf4bb16c29@syzkaller.appspotmail.com
First crash: 3d23h, last: 5h05m
Cause bisection: introduced by (bisect log) :
commit 5f8d28f6d7d568dbbc8c5bce94894474c07afd4f
Author: Casey Schaufler <casey@schaufler-ca.com>
Date: Wed Jul 10 21:32:26 2024 +0000

  lsm: infrastructure management of the key security blob

Crash: KASAN: slab-use-after-free Read in smk_access (log)
Repro: C syz .config
  
Duplicate of
Title Repro Cause bisect Fix bisect Count Last Reported
general protection fault in smack_log_callback audit C done 2 2d03h 1d13h
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [lsm?] KASAN: slab-use-after-free Read in smk_access 1 (2) 2024/09/20 16:58

Sample crash report:
capability: warning: `syz-executor210' uses 32-bit capabilities (legacy support in use)
==================================================================
BUG: KASAN: slab-use-after-free in smk_access+0xae/0x4e0 security/smack/smack_access.c:147
Read of size 8 at addr ffff8880265cab00 by task syz-executor210/5220

CPU: 0 UID: 0 PID: 5220 Comm: syz-executor210 Not tainted 6.11.0-syzkaller-02574-ga430d95c5efa #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 08/06/2024
Call Trace:
 <TASK>
 __dump_stack lib/dump_stack.c:93 [inline]
 dump_stack_lvl+0x241/0x360 lib/dump_stack.c:119
 print_address_description mm/kasan/report.c:377 [inline]
 print_report+0x169/0x550 mm/kasan/report.c:488
 kasan_report+0x143/0x180 mm/kasan/report.c:601
 smk_access+0xae/0x4e0 security/smack/smack_access.c:147
 smack_watch_key+0x2f4/0x3a0 security/smack/smack_lsm.c:4656
 security_watch_key+0x86/0x250 security/security.c:4448
 keyctl_watch_key+0x2b7/0x480 security/keys/keyctl.c:1813
 __do_sys_keyctl security/keys/keyctl.c:2021 [inline]
 __se_sys_keyctl+0x106/0xa50 security/keys/keyctl.c:1874
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f
RIP: 0033:0x7f0451b6cbf9
Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 c1 17 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 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fff281262e8 EFLAGS: 00000246 ORIG_RAX: 00000000000000fa
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f0451b6cbf9
RDX: 0000000000000007 RSI: 0000000032bb21f7 RDI: 0000000000000020
RBP: 00007f0451bdf5f0 R08: 0000000000000000 R09: 0000000000000006
R10: 00000000000000b1 R11: 0000000000000246 R12: 0000000000000001
R13: 431bde82d7b634db R14: 0000000000000001 R15: 0000000000000001
 </TASK>

Allocated by task 4676:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 poison_kmalloc_redzone mm/kasan/common.c:370 [inline]
 __kasan_kmalloc+0x98/0xb0 mm/kasan/common.c:387
 kasan_kmalloc include/linux/kasan.h:211 [inline]
 __do_kmalloc_node mm/slub.c:4159 [inline]
 __kmalloc_node_track_caller_noprof+0x225/0x440 mm/slub.c:4178
 kstrdup+0x3a/0x80 mm/util.c:64
 smack_inode_init_security+0x5d7/0x740 security/smack/smack_lsm.c:1053
 security_inode_init_security+0x202/0x480 security/security.c:1830
 shmem_mknod+0xc5/0x1e0 mm/shmem.c:3432
 lookup_open fs/namei.c:3595 [inline]
 open_last_lookups fs/namei.c:3694 [inline]
 path_openat+0x1c03/0x3590 fs/namei.c:3930
 do_filp_open+0x235/0x490 fs/namei.c:3960
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_openat fs/open.c:1446 [inline]
 __se_sys_openat fs/open.c:1441 [inline]
 __x64_sys_openat+0x247/0x2a0 fs/open.c:1441
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Freed by task 4676:
 kasan_save_stack mm/kasan/common.c:47 [inline]
 kasan_save_track+0x3f/0x80 mm/kasan/common.c:68
 kasan_save_free_info+0x40/0x50 mm/kasan/generic.c:579
 poison_slab_object+0xe0/0x150 mm/kasan/common.c:240
 __kasan_slab_free+0x37/0x60 mm/kasan/common.c:256
 kasan_slab_free include/linux/kasan.h:184 [inline]
 slab_free_hook mm/slub.c:2250 [inline]
 slab_free mm/slub.c:4474 [inline]
 kfree+0x149/0x360 mm/slub.c:4595
 security_inode_init_security+0x316/0x480 security/security.c:1849
 shmem_mknod+0xc5/0x1e0 mm/shmem.c:3432
 lookup_open fs/namei.c:3595 [inline]
 open_last_lookups fs/namei.c:3694 [inline]
 path_openat+0x1c03/0x3590 fs/namei.c:3930
 do_filp_open+0x235/0x490 fs/namei.c:3960
 do_sys_openat2+0x13e/0x1d0 fs/open.c:1415
 do_sys_open fs/open.c:1430 [inline]
 __do_sys_openat fs/open.c:1446 [inline]
 __se_sys_openat fs/open.c:1441 [inline]
 __x64_sys_openat+0x247/0x2a0 fs/open.c:1441
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xf3/0x230 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

The buggy address belongs to the object at ffff8880265cab00
 which belongs to the cache kmalloc-8 of size 8
The buggy address is located 0 bytes inside of
 freed 8-byte region [ffff8880265cab00, ffff8880265cab08)

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff8880265caf00 pfn:0x265ca
flags: 0xfff00000000000(node=0|zone=1|lastcpupid=0x7ff)
page_type: 0xfdffffff(slab)
raw: 00fff00000000000 ffff88801a841500 ffffea00009df180 dead000000000002
raw: ffff8880265caf00 000000008080007d 00000001fdffffff 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 0x52cc0(GFP_KERNEL|__GFP_NOWARN|__GFP_NORETRY|__GFP_COMP), pid 1, tgid 1 (swapper/0), ts 9248500129, free_ts 9235291326
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1f3/0x230 mm/page_alloc.c:1500
 prep_new_page mm/page_alloc.c:1508 [inline]
 get_page_from_freelist+0x2e4c/0x2f10 mm/page_alloc.c:3446
 __alloc_pages_noprof+0x256/0x6c0 mm/page_alloc.c:4702
 __alloc_pages_node_noprof include/linux/gfp.h:269 [inline]
 alloc_pages_node_noprof include/linux/gfp.h:296 [inline]
 alloc_slab_page+0x5f/0x120 mm/slub.c:2319
 allocate_slab+0x5a/0x2f0 mm/slub.c:2482
 new_slab mm/slub.c:2535 [inline]
 ___slab_alloc+0xcd1/0x14b0 mm/slub.c:3721
 __slab_alloc+0x58/0xa0 mm/slub.c:3811
 __slab_alloc_node mm/slub.c:3864 [inline]
 slab_alloc_node mm/slub.c:4026 [inline]
 __do_kmalloc_node mm/slub.c:4158 [inline]
 __kmalloc_node_track_caller_noprof+0x281/0x440 mm/slub.c:4178
 kvasprintf+0xdf/0x190 lib/kasprintf.c:25
 kobject_set_name_vargs+0x61/0x120 lib/kobject.c:274
 kobject_add_varg lib/kobject.c:368 [inline]
 kobject_add+0x113/0x220 lib/kobject.c:426
 irq_sysfs_add kernel/irq/irqdesc.c:374 [inline]
 alloc_descs kernel/irq/irqdesc.c:543 [inline]
 __irq_alloc_descs+0x544/0x960 kernel/irq/irqdesc.c:863
 irq_domain_alloc_irqs_locked+0x83/0xbb0 kernel/irq/irqdomain.c:1575
 __irq_domain_alloc_irqs+0xaa/0x110 kernel/irq/irqdomain.c:1647
 __msi_domain_alloc_irqs+0x723/0x1380 kernel/irq/msi.c:1266
 __msi_domain_alloc_locked kernel/irq/msi.c:1323 [inline]
 msi_domain_alloc_locked+0x52d/0xbf0 kernel/irq/msi.c:1328
page last free pid 940 tgid 940 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1101 [inline]
 free_unref_page+0xd19/0xea0 mm/page_alloc.c:2619
 vfree+0x186/0x2e0 mm/vmalloc.c:3367
 delayed_vfree_work+0x56/0x80 mm/vmalloc.c:3288
 process_one_work kernel/workqueue.c:3231 [inline]
 process_scheduled_works+0xa2c/0x1830 kernel/workqueue.c:3312
 worker_thread+0x870/0xd30 kernel/workqueue.c:3393
 kthread+0x2f0/0x390 kernel/kthread.c:389
 ret_from_fork+0x4b/0x80 arch/x86/kernel/process.c:147
 ret_from_fork_asm+0x1a/0x30 arch/x86/entry/entry_64.S:244

Memory state around the buggy address:
 ffff8880265caa00: fa fc fc fc fa fc fc fc 00 fc fc fc fa fc fc fc
 ffff8880265caa80: 05 fc fc fc 05 fc fc fc 00 fc fc fc 00 fc fc fc
>ffff8880265cab00: fa fc fc fc fa fc fc fc fa fc fc fc 06 fc fc fc
                   ^
 ffff8880265cab80: fa fc fc fc fa fc fc fc 06 fc fc fc 00 fc fc fc
 ffff8880265cac00: 00 fc fc fc 00 fc fc fc 05 fc fc fc fa fc fc fc
==================================================================

Crashes (26):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/09/17 13:05 upstream a430d95c5efa c673ca06 .config strace log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/17 12:00 upstream a430d95c5efa c673ca06 .config console log report syz / log C [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Read in smk_access
2024/09/17 11:41 upstream a430d95c5efa c673ca06 .config console log report syz / log [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/19 22:59 upstream 839c4f596f89 6f888b75 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/18 22:33 upstream bdf56c7580d2 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/18 06:34 upstream 2f27fce67173 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/17 10:49 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/17 07:09 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/17 05:43 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/17 05:40 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/17 03:43 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-use-after-free Read in smk_access
2024/09/19 03:27 upstream 4a39ac5b7d62 c673ca06 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-arm64-mte KASAN: slab-use-after-free Read in smk_access
2024/09/17 10:45 upstream a430d95c5efa c673ca06 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-arm64-mte KASAN: slab-use-after-free Read in smk_access
2024/09/17 10:36 upstream a430d95c5efa c673ca06 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-arm64-mte KASAN: slab-use-after-free Read in smk_access
2024/09/20 01:34 upstream 839c4f596f89 6f888b75 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Read in smk_access
2024/09/18 22:34 upstream bdf56c7580d2 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Read in smk_access
2024/09/17 23:59 upstream 2f27fce67173 c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Read in smk_access
2024/09/17 07:31 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Read in smk_access
2024/09/17 05:43 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Read in smk_access
2024/09/17 03:43 upstream a430d95c5efa c673ca06 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-kasan-gce-smack-root KASAN: slab-out-of-bounds Read in smk_access
2024/09/20 21:58 upstream baeb9a7d8b60 6f888b75 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-arm64-mte KASAN: invalid-access Read in smk_access
2024/09/20 20:49 upstream baeb9a7d8b60 6f888b75 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-arm64-mte KASAN: invalid-access Read in smk_access
2024/09/19 03:10 upstream 4a39ac5b7d62 c673ca06 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-arm64-mte KASAN: invalid-access Read in smk_access
2024/09/18 15:34 upstream 2f27fce67173 c673ca06 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-arm64-mte KASAN: invalid-access Read in smk_access
2024/09/18 14:25 upstream 2f27fce67173 c673ca06 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-arm64-mte KASAN: invalid-access Read in smk_access
2024/09/18 14:24 upstream 2f27fce67173 c673ca06 .config console log report info [disk image (non-bootable)] [vmlinux] [kernel image] ci-qemu2-arm64-mte KASAN: invalid-access Read in smk_access
* Struck through repros no longer work on HEAD.