possible deadlock in pie_timer

5 views
Skip to first unread message

syzbot

unread,
Oct 6, 2019, 12:17:07 PM10/6/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: db189223 Linux 4.14.147
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=118dbe67600000
kernel config: https://syzkaller.appspot.com/x/.config?x=14d726467704dd7
dashboard link: https://syzkaller.appspot.com/bug?extid=49121b310d1c242c9cb8
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=15f31e67600000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=14d4230b600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+49121b...@syzkaller.appspotmail.com

======================================================
WARNING: possible circular locking dependency detected
4.14.147 #0 Not tainted
------------------------------------------------------
syz-executor166/7192 is trying to acquire lock:
(&qdisc_rx_lock){+.-.}, at: [<ffffffff84efec90>] spin_lock
include/linux/spinlock.h:317 [inline]
(&qdisc_rx_lock){+.-.}, at: [<ffffffff84efec90>] pie_timer+0x70/0x680
net/sched/sch_pie.c:431

but task is already holding lock:
(((&q->adapt_timer))){+.-.}, at: [<ffffffff814f9c28>] lockdep_copy_map
include/linux/lockdep.h:174 [inline]
(((&q->adapt_timer))){+.-.}, at: [<ffffffff814f9c28>]
call_timer_fn+0xc8/0x670 kernel/time/timer.c:1269

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #1 (((&q->adapt_timer))){+.-.}:
lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3994
del_timer_sync+0xb4/0x250 kernel/time/timer.c:1235
pie_destroy+0x47/0x60 net/sched/sch_pie.c:534
qdisc_destroy+0x157/0x320 net/sched/sch_generic.c:725
sfb_change+0x28e/0xaa0 net/sched/sch_sfb.c:524
qdisc_change net/sched/sch_api.c:1144 [inline]
tc_modify_qdisc+0xc5a/0x1270 net/sched/sch_api.c:1410
rtnetlink_rcv_msg+0x3eb/0xb70 net/core/rtnetlink.c:4285
netlink_rcv_skb+0x14f/0x3c0 net/netlink/af_netlink.c:2432
rtnetlink_rcv+0x1d/0x30 net/core/rtnetlink.c:4297
netlink_unicast_kernel net/netlink/af_netlink.c:1286 [inline]
netlink_unicast+0x45d/0x640 net/netlink/af_netlink.c:1312
netlink_sendmsg+0x7c4/0xc60 net/netlink/af_netlink.c:1877
sock_sendmsg_nosec net/socket.c:646 [inline]
sock_sendmsg+0xce/0x110 net/socket.c:656
___sys_sendmsg+0x70a/0x840 net/socket.c:2062
__sys_sendmsg+0xb9/0x140 net/socket.c:2096
SYSC_sendmsg net/socket.c:2107 [inline]
SyS_sendmsg+0x2d/0x50 net/socket.c:2103
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7

-> #0 (&qdisc_rx_lock){+.-.}:
check_prev_add kernel/locking/lockdep.c:1901 [inline]
check_prevs_add kernel/locking/lockdep.c:2018 [inline]
validate_chain kernel/locking/lockdep.c:2460 [inline]
__lock_acquire+0x2cb3/0x4620 kernel/locking/lockdep.c:3487
lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3994
__raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
_raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:152
spin_lock include/linux/spinlock.h:317 [inline]
pie_timer+0x70/0x680 net/sched/sch_pie.c:431
call_timer_fn+0x161/0x670 kernel/time/timer.c:1279
expire_timers kernel/time/timer.c:1318 [inline]
__run_timers kernel/time/timer.c:1634 [inline]
__run_timers kernel/time/timer.c:1602 [inline]
run_timer_softirq+0x5b4/0x1570 kernel/time/timer.c:1647
__do_softirq+0x244/0x9a0 kernel/softirq.c:288
invoke_softirq kernel/softirq.c:368 [inline]
irq_exit+0x160/0x1b0 kernel/softirq.c:409
exiting_irq arch/x86/include/asm/apic.h:648 [inline]
smp_apic_timer_interrupt+0x146/0x5e0 arch/x86/kernel/apic/apic.c:1102
apic_timer_interrupt+0x96/0xa0 arch/x86/entry/entry_64.S:792
memcmp+0x4c/0xc0 lib/string.c:861
find_stack lib/stackdepot.c:176 [inline]
depot_save_stack+0x11c/0x410 lib/stackdepot.c:225
save_stack+0xa9/0xd0 mm/kasan/kasan.c:453
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc mm/kasan/kasan.c:551 [inline]
kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:489
kmem_cache_alloc+0x12e/0x780 mm/slab.c:3552
kmem_cache_zalloc include/linux/slab.h:651 [inline]
ebitmap_cpy+0xcd/0x270 security/selinux/ss/ebitmap.c:60
mls_context_cpy security/selinux/ss/context.h:51 [inline]
mls_compute_sid+0x22f/0xd60 security/selinux/ss/mls.c:556
security_compute_sid.part.0+0xa8f/0x10f0
security/selinux/ss/services.c:1725
security_compute_sid security/selinux/ss/services.c:1764 [inline]
security_transition_sid+0xd6/0x130
security/selinux/ss/services.c:1764
socket_sockcreate_sid security/selinux/hooks.c:4356 [inline]
socket_sockcreate_sid security/selinux/hooks.c:4348 [inline]
selinux_socket_create+0x36d/0x4d0 security/selinux/hooks.c:4389
security_socket_create+0x83/0xc0 security/security.c:1346
__sock_create+0x67/0x620 net/socket.c:1230
sock_create net/socket.c:1315 [inline]
SYSC_socket net/socket.c:1345 [inline]
SyS_socket+0xd3/0x170 net/socket.c:1325
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7

other info that might help us debug this:

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(((&q->adapt_timer)));
lock(&qdisc_rx_lock);
lock(((&q->adapt_timer)));
lock(&qdisc_rx_lock);

*** DEADLOCK ***

2 locks held by syz-executor166/7192:
#0: (policy_rwlock){.+.?}, at: [<ffffffff82a15620>]
security_compute_sid.part.0+0xe0/0x10f0 security/selinux/ss/services.c:1608
#1: (((&q->adapt_timer))){+.-.}, at: [<ffffffff814f9c28>]
lockdep_copy_map include/linux/lockdep.h:174 [inline]
#1: (((&q->adapt_timer))){+.-.}, at: [<ffffffff814f9c28>]
call_timer_fn+0xc8/0x670 kernel/time/timer.c:1269

stack backtrace:
CPU: 1 PID: 7192 Comm: syz-executor166 Not tainted 4.14.147 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x138/0x197 lib/dump_stack.c:53
print_circular_bug.isra.0.cold+0x1cc/0x28f kernel/locking/lockdep.c:1258
check_prev_add kernel/locking/lockdep.c:1901 [inline]
check_prevs_add kernel/locking/lockdep.c:2018 [inline]
validate_chain kernel/locking/lockdep.c:2460 [inline]
__lock_acquire+0x2cb3/0x4620 kernel/locking/lockdep.c:3487
lock_acquire+0x16f/0x430 kernel/locking/lockdep.c:3994
__raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
_raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:152
spin_lock include/linux/spinlock.h:317 [inline]
pie_timer+0x70/0x680 net/sched/sch_pie.c:431
call_timer_fn+0x161/0x670 kernel/time/timer.c:1279
expire_timers kernel/time/timer.c:1318 [inline]
__run_timers kernel/time/timer.c:1634 [inline]
__run_timers kernel/time/timer.c:1602 [inline]
run_timer_softirq+0x5b4/0x1570 kernel/time/timer.c:1647
__do_softirq+0x244/0x9a0 kernel/softirq.c:288
invoke_softirq kernel/softirq.c:368 [inline]
irq_exit+0x160/0x1b0 kernel/softirq.c:409
exiting_irq arch/x86/include/asm/apic.h:648 [inline]
smp_apic_timer_interrupt+0x146/0x5e0 arch/x86/kernel/apic/apic.c:1102
apic_timer_interrupt+0x96/0xa0 arch/x86/entry/entry_64.S:792
</IRQ>
RIP: 0010:memcmp+0x4c/0xc0 lib/string.c:861
RSP: 0018:ffff88808990f708 EFLAGS: 00000293 ORIG_RAX: ffffffffffffff10
RAX: 0000000000000000 RBX: ffff88808990f80d RCX: 0000000000000004
RDX: 0000000000000005 RSI: ffff88809dd32625 RDI: ffff88808990f7b0
RBP: ffff88808990f730 R08: 000000002caf1dd4 R09: 0000000000000001
R10: 0000000000000000 R11: ffff88808af3e100 R12: dffffc0000000000
R13: ffff88808990f828 R14: 000000000000000f R15: ffff88809dd325b0
find_stack lib/stackdepot.c:176 [inline]
depot_save_stack+0x11c/0x410 lib/stackdepot.c:225
save_stack+0xa9/0xd0 mm/kasan/kasan.c:453
set_track mm/kasan/kasan.c:459 [inline]
kasan_kmalloc mm/kasan/kasan.c:551 [inline]
kasan_kmalloc+0xce/0xf0 mm/kasan/kasan.c:529
kasan_slab_alloc+0xf/0x20 mm/kasan/kasan.c:489
kmem_cache_alloc+0x12e/0x780 mm/slab.c:3552
kmem_cache_zalloc include/linux/slab.h:651 [inline]
ebitmap_cpy+0xcd/0x270 security/selinux/ss/ebitmap.c:60
mls_context_cpy security/selinux/ss/context.h:51 [inline]
mls_compute_sid+0x22f/0xd60 security/selinux/ss/mls.c:556
security_compute_sid.part.0+0xa8f/0x10f0
security/selinux/ss/services.c:1725
security_compute_sid security/selinux/ss/services.c:1764 [inline]
security_transition_sid+0xd6/0x130 security/selinux/ss/services.c:1764
socket_sockcreate_sid security/selinux/hooks.c:4356 [inline]
socket_sockcreate_sid security/selinux/hooks.c:4348 [inline]
selinux_socket_create+0x36d/0x4d0 security/selinux/hooks.c:4389
security_socket_create+0x83/0xc0 security/security.c:1346
__sock_create+0x67/0x620 net/socket.c:1230
sock_create net/socket.c:1315 [inline]
SYSC_socket net/socket.c:1345 [inline]
SyS_socket+0xd3/0x170 net/socket.c:1325
do_syscall_64+0x1e8/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x42/0xb7
RIP: 0033:0x446ce9
RSP: 002b:00007f5697f5edb8 EFLAGS: 00000246 ORIG_RAX: 0000000000000029
RAX: ffffffffffffffda RBX: 00000000006dbc48 RCX: 0000000000446ce9
RDX: 0000000000000000 RSI: 0000000000000003 RDI: 0000000000000010
RBP: 00000000006dbc40 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00000000006dbc4c
R13: 00007ffea591daef R14: 00007f5697f5f9c0 R15: 0000000000000000


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches
Reply all
Reply to author
Forward
0 new messages