lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Date: Mon, 6 May 2024 18:45:07 +0800
From: Sam Sun <samsun1006219@...il.com>
To: linux-kernel@...r.kernel.org, mingo@...hat.com, peterz@...radead.org, 
	juri.lelli@...hat.com, vincent.guittot@...aro.org, dietmar.eggemann@....com, 
	rostedt@...dmis.org, bsegall@...gle.com, mgorman@...e.de, bristot@...hat.com, 
	vschneid@...hat.com
Subject: [Linux kernel bug] KASAN: out-of-bounds Read in irq_work_single

Dear developers and maintainers,

We encountered a slab-out-of-bounds bug while using our modified
syzkaller. It was tested against the upstream kernel (tag 6.9-rc5).
The kernel was compiled by clang 14.0.0, and kernel config and C repro
are attached to this email. Kernel crash log is listed below.

==================================================================
BUG: KASAN: out-of-bounds in __wake_up_common kernel/sched/wait.c:86 [inline]
BUG: KASAN: out-of-bounds in __wake_up_common_lock+0x171/0x1e0
kernel/sched/wait.c:106
Read of size 4 at addr ffffc9000fe57a60 by task syz-executor335/8119

CPU: 0 PID: 8119 Comm: syz-executor335 Not tainted 6.9.0-rc5 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.15.0-1 04/01/2014
Call Trace:
 <IRQ>
 __dump_stack lib/dump_stack.c:88 [inline]
 dump_stack_lvl+0x201/0x300 lib/dump_stack.c:114
 print_address_description+0x7b/0x360 mm/kasan/report.c:377
 print_report+0xfd/0x1e0 mm/kasan/report.c:488
 kasan_report+0xce/0x100 mm/kasan/report.c:601
 __wake_up_common kernel/sched/wait.c:86 [inline]
 __wake_up_common_lock+0x171/0x1e0 kernel/sched/wait.c:106
 irq_work_single+0xdf/0x240 kernel/irq_work.c:221
 irq_work_run_list kernel/irq_work.c:252 [inline]
 irq_work_tick+0x2db/0x390 kernel/irq_work.c:277
 update_process_times+0x1f6/0x230 kernel/time/timer.c:2489
 tick_sched_handle kernel/time/tick-sched.c:276 [inline]
 tick_nohz_handler+0x37a/0x4f0 kernel/time/tick-sched.c:297
 __run_hrtimer kernel/time/hrtimer.c:1692 [inline]
 __hrtimer_run_queues+0x4ab/0x8e0 kernel/time/hrtimer.c:1756
 hrtimer_interrupt+0x37f/0x970 kernel/time/hrtimer.c:1818
 local_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1032 [inline]
 __sysvec_apic_timer_interrupt+0xc1/0x180 arch/x86/kernel/apic/apic.c:1049
 instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1043 [inline]
 sysvec_apic_timer_interrupt+0xa1/0xc0 arch/x86/kernel/apic/apic.c:1043
 </IRQ>
 <TASK>
 asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702
RIP: 0010:memmove+0x28/0x1b0 arch/x86/lib/memmove_64.S:44
Code: c3 90 f3 0f 1e fa 48 89 f8 48 39 fe 7d 0f 49 89 f0 49 01 d0 49
39 f8 0f 8f b5 00 00 00 48 83 fa 20 0f 82 01 01 00 00 48 89 d1 <f3> a4
c3 48 81 fa a8 02 00 00 72 05 40 38 fe 74 47 48 83 ea 20 48
RSP: 0018:ffffc900084be7f8 EFLAGS: 00010286
RAX: ffff8880273b8fb4 RBX: 0000000000000010 RCX: ffffffffff82672b
RDX: ffffffffffffffe0 RSI: ffff888027b92859 RDI: ffff888027b92869
RBP: ffff8880273b8fa4 R08: ffff8880273b8f84 R09: 0000766972705f73
R10: 667265736965722e R11: 0000766972705f73 R12: 0000000000000f84
R13: ffff8880273b8f84 R14: 0000000000000020 R15: ffffffffffffffe0
 leaf_paste_entries+0x96f/0x1380 fs/reiserfs/lbalance.c:1377
 balance_leaf_finish_node_paste_dirent fs/reiserfs/do_balan.c:1295 [inline]
 balance_leaf_finish_node_paste fs/reiserfs/do_balan.c:1321 [inline]
 balance_leaf_finish_node fs/reiserfs/do_balan.c:1364 [inline]
 balance_leaf+0xa9b7/0x12070 fs/reiserfs/do_balan.c:1452
 do_balance+0x2da/0x8c0 fs/reiserfs/do_balan.c:1888
 reiserfs_paste_into_item+0x73e/0x880 fs/reiserfs/stree.c:2158
 reiserfs_add_entry+0x9c5/0xef0 fs/reiserfs/namei.c:558
 reiserfs_mkdir+0x694/0x8d0 fs/reiserfs/namei.c:853
 xattr_mkdir fs/reiserfs/xattr.c:77 [inline]
 create_privroot fs/reiserfs/xattr.c:891 [inline]
 reiserfs_xattr_init+0x359/0x6c0 fs/reiserfs/xattr.c:1007
 reiserfs_fill_super+0x2090/0x2480 fs/reiserfs/super.c:2174
 mount_bdev+0x212/0x2d0 fs/super.c:1658
 legacy_get_tree+0xed/0x190 fs/fs_context.c:662
 vfs_get_tree+0x90/0x2a0 fs/super.c:1779
 do_new_mount+0x2bb/0xb40 fs/namespace.c:3352
 do_mount fs/namespace.c:3692 [inline]
 __do_sys_mount fs/namespace.c:3898 [inline]
 __se_sys_mount+0x2c9/0x3b0 fs/namespace.c:3875
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xe4/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x67/0x6f
RIP: 0033:0x7f890811aa7e
Code: 48 c7 c0 ff ff ff ff eb aa e8 ee 08 00 00 66 2e 0f 1f 84 00 00
00 00 00 0f 1f 40 00 f3 0f 1e fa 49 89 ca b8 a5 00 00 00 0f 05 <48> 3d
01 f0 ff ff 73 01 c3 48 c7 c1 b0 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007f89080b5ff8 EFLAGS: 00000286 ORIG_RAX: 00000000000000a5
RAX: ffffffffffffffda RBX: 00007f89080b65f0 RCX: 00007f890811aa7e
RDX: 0000000020001100 RSI: 00000000200000c0 RDI: 00007f89080b6010
RBP: 00007f89080b6010 R08: 00007f89080b6050 R09: 00000000000010ec
R10: 0000000000018050 R11: 0000000000000286 R12: 00007f89080b6050
R13: 0000000000018050 R14: 0000000000000003 R15: 0000000000000004
 </TASK>

The buggy address belongs to the virtual mapping at
 [ffffc9000fe50000, ffffc9000fe59000) created by:
 dup_task_struct+0x8b/0x5a0 kernel/fork.c:1115

The buggy address belongs to the physical page:
page: refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x22a56
memcg:ffff888016378682
flags: 0xfff80000000000(node=0|zone=1|lastcpupid=0xfff)
page_type: 0xffffffff()
raw: 00fff80000000000 0000000000000000 dead000000000122 0000000000000000
raw: 0000000000000000 0000000000000000 00000001ffffffff ffff888016378682
page dumped because: kasan: bad access detected
page_owner tracks the page as allocated
page last allocated via order 0, migratetype Unmovable, gfp_mask
0x2dc2(GFP_KERNEL|__GFP_HIGHMEM|__GFP_NOWARN|__GFP_ZERO), pid 6401,
tgid 828911888 (systemd-udevd), ts 6401, free_ts 55598516357
 set_page_owner include/linux/page_owner.h:32 [inline]
 post_alloc_hook+0x1e6/0x210 mm/page_alloc.c:1534
 prep_new_page mm/page_alloc.c:1541 [inline]
 get_page_from_freelist+0x7d2/0x850 mm/page_alloc.c:3317
 __alloc_pages+0x25e/0x580 mm/page_alloc.c:4575
 alloc_pages_mpol+0x392/0x610 mm/mempolicy.c:2264
 vm_area_alloc_pages mm/vmalloc.c:3561 [inline]
 __vmalloc_area_node mm/vmalloc.c:3637 [inline]
 __vmalloc_node_range+0x9bb/0x14a0 mm/vmalloc.c:3818
 alloc_thread_stack_node+0x32d/0x580 kernel/fork.c:309
 dup_task_struct+0x8b/0x5a0 kernel/fork.c:1115
 copy_process+0x5cc/0x3d70 kernel/fork.c:2220
 kernel_clone+0x228/0x6b0 kernel/fork.c:2797
 __do_sys_clone kernel/fork.c:2940 [inline]
 __se_sys_clone kernel/fork.c:2924 [inline]
 __x64_sys_clone+0x26b/0x2e0 kernel/fork.c:2924
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xe4/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x67/0x6f
page last free pid 6318 tgid 6318 stack trace:
 reset_page_owner include/linux/page_owner.h:25 [inline]
 free_pages_prepare mm/page_alloc.c:1141 [inline]
 free_unref_page_prepare+0x72f/0x7c0 mm/page_alloc.c:2347
 free_unref_page+0x37/0x3f0 mm/page_alloc.c:2487
 __slab_free+0x336/0x3d0 mm/slub.c:4192
 qlink_free mm/kasan/quarantine.c:163 [inline]
 qlist_free_all+0x60/0xd0 mm/kasan/quarantine.c:179
 kasan_quarantine_reduce+0x15a/0x170 mm/kasan/quarantine.c:286
 __kasan_slab_alloc+0x23/0x70 mm/kasan/common.c:322
 kasan_slab_alloc include/linux/kasan.h:201 [inline]
 slab_post_alloc_hook mm/slub.c:3798 [inline]
 slab_alloc_node mm/slub.c:3845 [inline]
 kmem_cache_alloc+0x172/0x350 mm/slub.c:3852
 vm_area_dup+0x27/0x280 kernel/fork.c:482
 dup_mmap+0xb67/0x1a40 kernel/fork.c:697
 dup_mm kernel/fork.c:1688 [inline]
 copy_mm+0x143/0x430 kernel/fork.c:1737
 copy_process+0x1810/0x3d70 kernel/fork.c:2390
 kernel_clone+0x228/0x6b0 kernel/fork.c:2797
 __do_sys_clone kernel/fork.c:2940 [inline]
 __se_sys_clone kernel/fork.c:2924 [inline]
 __x64_sys_clone+0x26b/0x2e0 kernel/fork.c:2924
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xe4/0x240 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x67/0x6f

Memory state around the buggy address:
 ffffc9000fe57900: 48 00 04 00 01 00 00 00 01 00 00 00 02 00 00 00
 ffffc9000fe57980: 48 00 04 00 01 00 00 00 01 00 00 00 02 00 00 00
>ffffc9000fe57a00: 48 00 04 00 01 00 00 00 01 00 00 00 02 00 00 00
                                                       ^
 ffffc9000fe57a80: 48 00 04 00 01 00 00 00 01 00 00 00 02 00 00 00
 ffffc9000fe57b00: 48 00 04 00 01 00 00 00 01 00 00 00 02 00 00 00
==================================================================
----------------
Code disassembly (best guess):
   0: c3                   ret
   1: 90                   nop
   2: f3 0f 1e fa           endbr64
   6: 48 89 f8             mov    %rdi,%rax
   9: 48 39 fe             cmp    %rdi,%rsi
   c: 7d 0f                 jge    0x1d
   e: 49 89 f0             mov    %rsi,%r8
  11: 49 01 d0             add    %rdx,%r8
  14: 49 39 f8             cmp    %rdi,%r8
  17: 0f 8f b5 00 00 00     jg     0xd2
  1d: 48 83 fa 20           cmp    $0x20,%rdx
  21: 0f 82 01 01 00 00     jb     0x128
  27: 48 89 d1             mov    %rdx,%rcx
* 2a: f3 a4                 rep movsb %ds:(%rsi),%es:(%rdi) <--
trapping instruction
  2c: c3                   ret
  2d: 48 81 fa a8 02 00 00 cmp    $0x2a8,%rdx
  34: 72 05                 jb     0x3b
  36: 40 38 fe             cmp    %dil,%sil
  39: 74 47                 je     0x82
  3b: 48 83 ea 20           sub    $0x20,%rdx
  3f: 48                   rex.W

If you have any questions, please contact us.

Reported by Yue Sun <samsun1006219@...il.com>
Reported by xingwei lee <xrivendell7@...il.com>

Best Regards,
Yue

View attachment "irq_work_single.c" of type "text/x-csrc" (41765 bytes)

Download attachment "config" of type "application/octet-stream" (247888 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ