syzbot


KASAN: stack-out-of-bounds Read in refcount_sub_and_test_checked

Status: auto-closed as invalid on 2019/06/11 23:36
Subsystems: hardening mm
[Documentation on labels]
Reported-by: syzbot+d3ed975648421c381ca4@syzkaller.appspotmail.com
First crash: 1950d, last: 1932d
Discussions (1)
Title Replies (including bot) Last reply
KASAN: stack-out-of-bounds Read in refcount_sub_and_test_checked 0 (1) 2018/11/26 20:39

Sample crash report:
==================================================================
BUG: KASAN: stack-out-of-bounds in atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
BUG: KASAN: stack-out-of-bounds in refcount_sub_and_test_checked+0x9d/0x310 lib/refcount.c:179
kasan: CONFIG_KASAN_INLINE enabled
Read of size 4 at addr ffff8881da9c0bf0 by task syz-executor1/11883
kasan: GPF could be caused by NULL-ptr deref or user memory access

general protection fault: 0000 [#1] PREEMPT SMP KASAN
CPU: 1 PID: 11883 Comm: syz-executor1 Not tainted 4.20.0-rc6+ #342
CPU: 0 PID: 1049 Comm: syz-executor5 Not tainted 4.20.0-rc6+ #342
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
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+0x244/0x39d lib/dump_stack.c:113
RIP: 0010:lookup_object lib/debugobjects.c:156 [inline]
RIP: 0010:debug_object_deactivate+0x191/0x450 lib/debugobjects.c:542
------------[ cut here ]------------
Bad or missing usercopy whitelist? Kernel memory overwrite attempt detected to SLAB object '$' (offset 18446744071562083744, size 64)!
WARNING: CPU: 0 PID: 1049 at mm/usercopy.c:83 usercopy_warn+0xee/0x110 mm/usercopy.c:78
 print_address_description.cold.7+0x9/0x1ff mm/kasan/report.c:256
Kernel panic - not syncing: panic_on_warn set ...
 kasan_report_error mm/kasan/report.c:354 [inline]
 kasan_report.cold.8+0x242/0x309 mm/kasan/report.c:412
 check_memory_region_inline mm/kasan/kasan.c:260 [inline]
 check_memory_region+0x13e/0x1b0 mm/kasan/kasan.c:267
 kasan_check_read+0x11/0x20 mm/kasan/kasan.c:272
 atomic_read include/asm-generic/atomic-instrumented.h:21 [inline]
 refcount_sub_and_test_checked+0x9d/0x310 lib/refcount.c:179
 refcount_dec_and_test_checked+0x1a/0x20 lib/refcount.c:212
 kref_put include/linux/kref.h:69 [inline]
 aa_put_label security/apparmor/include/label.h:447 [inline]
 aa_free_file_ctx security/apparmor/include/file.h:75 [inline]
 apparmor_file_free_security+0x115/0x1a0 security/apparmor/lsm.c:450
 security_file_free+0x4a/0x80 security/security.c:900
 file_free fs/file_table.c:54 [inline]
 __fput+0x4e8/0xa30 fs/file_table.c:294
 ____fput+0x15/0x20 fs/file_table.c:309
 task_work_run+0x1e8/0x2a0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop+0x318/0x380 arch/x86/entry/common.c:166
 prepare_exit_to_usermode arch/x86/entry/common.c:197 [inline]
 syscall_return_slowpath arch/x86/entry/common.c:268 [inline]
 do_syscall_64+0x6be/0x820 arch/x86/entry/common.c:293
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x411110
Code: 01 f0 ff ff 0f 83 60 19 00 00 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 83 3d 9d 4e 63 00 00 75 14 b8 03 00 00 00 0f 05 <48> 3d 01 f0 ff ff 0f 83 34 19 00 00 c3 48 83 ec 08 e8 0a fc ff ff
RSP: 002b:00007ffc748753b8 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000411110
RDX: 0000000000000000 RSI: 0000000000004c01 RDI: 0000000000000003
RBP: 0000000000000003 R08: 0000000000000000 R09: 000000000000000a
R10: 0000000000000075 R11: 0000000000000246 R12: 0000000000000002
R13: 00000000000fb21e R14: 0000000000000737 R15: 0000000000000001

The buggy address belongs to the object at ffff8881da9c0040
 which belongs to the cache ĀŠ2™ˆ˙˙ of size -30591
The buggy address is located 33583 bytes to the right of
 -30591-byte region [ffff8881da9c0040, ffff8881da9b88c1)
The buggy address belongs to the page:
page:ffffea00076a7000 count:1 mapcount:0 mapping:ffff8881da800ac0 index:0x0 compound_mapcount: 0
flags: 0x2fffc0000010200(slab|head)
raw: 02fffc0000010200 ffffea00076a4108 ffffea0007650a08 ffff8881da800ac0
raw: 0000000000000000 ffff8881da9c0040 0000000100000007 0000000000000000
page dumped because: kasan: bad access detected

Memory state around the buggy address:
 ffff8881da9c0a80: 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1
 ffff8881da9c0b00: f1 00 f2 f2 f2 f2 f2 f2 f2 f8 f2 f2 f2 00 00 00
>ffff8881da9c0b80: 00 00 00 00 00 00 00 00 00 00 00 00 00 f1 f1 f1
                                                             ^
 ffff8881da9c0c00: f1 f8 f2 f2 f2 00 00 00 00 00 00 00 00 00 00 00
 ffff8881da9c0c80: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc 00
==================================================================
Kernel Offset: disabled

======================================================
WARNING: possible circular locking dependency detected
4.20.0-rc6+ #342 Not tainted
------------------------------------------------------
syz-executor5/1049 is trying to acquire lock:
00000000f30ae58a ((console_sem).lock){-.-.}, at: down_trylock+0x13/0x70 kernel/locking/semaphore.c:136

but task is already holding lock:
00000000b731d232 (&obj_hash[i].lock){-.-.}, at: debug_object_deactivate+0xf7/0x450 lib/debugobjects.c:540

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&obj_hash[i].lock){-.-.}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x99/0xd0 kernel/locking/spinlock.c:152
       __debug_object_init+0x127/0x1290 lib/debugobjects.c:383
       debug_object_init+0x16/0x20 lib/debugobjects.c:431
       debug_hrtimer_init kernel/time/hrtimer.c:410 [inline]
       debug_init kernel/time/hrtimer.c:458 [inline]
       hrtimer_init+0x97/0x490 kernel/time/hrtimer.c:1308
       init_dl_task_timer+0x1b/0x50 kernel/sched/deadline.c:1057
       __sched_fork+0x2ae/0x590 kernel/sched/core.c:2166
       init_idle+0x75/0x740 kernel/sched/core.c:5374
       sched_init+0xb33/0xc07 kernel/sched/core.c:6063
       start_kernel+0x4c1/0xa30 init/main.c:608
       x86_64_start_reservations+0x29/0x2b arch/x86/kernel/head64.c:470
       x86_64_start_kernel+0x76/0x79 arch/x86/kernel/head64.c:451
       secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243

-> #2 (&rq->lock){-.-.}:
       __raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
       _raw_spin_lock+0x2d/0x40 kernel/locking/spinlock.c:144
       rq_lock kernel/sched/sched.h:1124 [inline]
       task_fork_fair+0xb0/0x6d0 kernel/sched/fair.c:9802
       sched_fork+0x443/0xba0 kernel/sched/core.c:2359
       copy_process+0x25b8/0x87a0 kernel/fork.c:1887
       _do_fork+0x1cb/0x11d0 kernel/fork.c:2216
       kernel_thread+0x34/0x40 kernel/fork.c:2275
       rest_init+0x28/0x372 init/main.c:409
       arch_call_rest_init+0xe/0x1b
       start_kernel+0x9f5/0xa30 init/main.c:745
       x86_64_start_reservations+0x29/0x2b arch/x86/kernel/head64.c:470
       x86_64_start_kernel+0x76/0x79 arch/x86/kernel/head64.c:451
       secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243

-> #1 (&p->pi_lock){-.-.}:
       __raw_spin_lock_irqsave include/linux/spinlock_api_smp.h:110 [inline]
       _raw_spin_lock_irqsave+0x99/0xd0 kernel/locking/spinlock.c:152
       try_to_wake_up+0xdc/0x1440 kernel/sched/core.c:1965
       wake_up_process+0x10/0x20 kernel/sched/core.c:2129
       __up.isra.1+0x1c0/0x2a0 kernel/locking/semaphore.c:262
       up+0x13c/0x1c0 kernel/locking/semaphore.c:187
       __up_console_sem+0xbe/0x1b0 kernel/printk/printk.c:236
       console_unlock+0x811/0x1190 kernel/printk/printk.c:2432
       vprintk_emit+0x391/0x990 kernel/printk/printk.c:1922
       vprintk_default+0x28/0x30 kernel/printk/printk.c:1964
       vprintk_func+0x7e/0x181 kernel/printk/printk_safe.c:398
       printk+0xa7/0xcf kernel/printk/printk.c:1997
       check_stack_usage kernel/exit.c:755 [inline]
       do_exit.cold.18+0x57/0x16f kernel/exit.c:916
       do_group_exit+0x177/0x440 kernel/exit.c:970
       __do_sys_exit_group kernel/exit.c:981 [inline]
       __se_sys_exit_group kernel/exit.c:979 [inline]
       __x64_sys_exit_group+0x3e/0x50 kernel/exit.c:979
       do_syscall_64+0x1b9/0x820 arch/x86/entry/common.c:290
       entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 ((console_sem).lock){-.-.}:

other info that might help us debug this:

Chain exists of:
  (console_sem).lock --> &rq->lock --> &obj_hash[i].lock

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&obj_hash[i].lock);
                               lock(&rq->lock);
                               lock(&obj_hash[i].lock);
  lock((console_sem).lock);

 *** DEADLOCK ***

5 locks held by syz-executor5/1049:
 #0: 00000000b6b409e1 (rcu_read_lock){....}, at: __skb_unlink include/linux/skbuff.h:1922 [inline]
 #0: 00000000b6b409e1 (rcu_read_lock){....}, at: __skb_dequeue include/linux/skbuff.h:1938 [inline]
 #0: 00000000b6b409e1 (rcu_read_lock){....}, at: process_backlog+0x1dd/0x7a0 net/core/dev.c:5909
 #1: 00000000b6b409e1 (rcu_read_lock){....}, at: __skb_pull include/linux/skbuff.h:2155 [inline]
 #1: 00000000b6b409e1 (rcu_read_lock){....}, at: ip_local_deliver_finish+0x13d/0x390 net/ipv4/ip_input.c:231
 #2: 000000000f63df30 (hrtimer_bases.lock){-.-.}, at: hrtimer_interrupt+0xfc/0x780 kernel/time/hrtimer.c:1499
 #3: 00000000b731d232 (&obj_hash[i].lock){-.-.}, at: debug_object_deactivate+0xf7/0x450 lib/debugobjects.c:540
 #4: 00000000b6b409e1 (rcu_read_lock){....}, at: atomic_notifier_call_chain+0x0/0x190 kernel/notifier.c:329

stack backtrace:
CPU: 0 PID: 1049 Comm: syz-executor5 Not tainted 4.20.0-rc6+ #342
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
Rebooting in 86400 seconds..

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2018/12/13 23:35 net-next-old 95302c394c3d fe7127be .config console log report ci-upstream-net-kasan-gce
2018/12/09 12:04 net-next-old a60956ed72f7 979179d6 .config console log report ci-upstream-net-kasan-gce
2018/12/07 10:07 net-next-old fdb8b298676a dcf836b1 .config console log report ci-upstream-net-kasan-gce
2018/11/26 04:04 net-next-old 358be656406d 3d3ec907 .config console log report ci-upstream-net-kasan-gce
* Struck through repros no longer work on HEAD.