possible deadlock in free_ioctx_users

10 views
Skip to first unread message

syzbot

unread,
Jun 4, 2019, 4:56:06 PM6/4/19
to syzkaller...@googlegroups.com
Hello,

syzbot found the following crash on:

HEAD commit: e109a984 Linux 4.19.48
git tree: linux-4.19.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15d98186a00000
kernel config: https://syzkaller.appspot.com/x/.config?x=2d14dd88554f26bc
dashboard link: https://syzkaller.appspot.com/bug?extid=c9e3f2d9d4922e995e69
compiler: gcc (GCC) 9.0.0 20181231 (experimental)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=105435baa00000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1234a536a00000

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

audit: type=1400 audit(1559677938.243:36): avc: denied { map } for
pid=7813 comm="syz-executor496" path="/root/syz-executor496840080"
dev="sda1" ino=16483 scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:object_r:user_home_t:s0 tclass=file permissive=1
========================================================
WARNING: possible irq lock inversion dependency detected
4.19.48 #20 Not tainted
--------------------------------------------------------
swapper/1/0 just changed the state of lock:
000000002173f197 (&(&ctx->ctx_lock)->rlock){..-.}, at: spin_lock_irq
include/linux/spinlock.h:354 [inline]
000000002173f197 (&(&ctx->ctx_lock)->rlock){..-.}, at:
free_ioctx_users+0x2d/0x490 fs/aio.c:614
but this lock took another, SOFTIRQ-unsafe lock in the past:
(&fiq->waitq){+.+.}


and interrupts could create inverse lock ordering between them.


other info that might help us debug this:
Possible interrupt unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&fiq->waitq);
local_irq_disable();
lock(&(&ctx->ctx_lock)->rlock);
lock(&fiq->waitq);
<Interrupt>
lock(&(&ctx->ctx_lock)->rlock);

*** DEADLOCK ***

2 locks held by swapper/1/0:
#0: 00000000d64f8bab (rcu_callback){....}, at: __rcu_reclaim
kernel/rcu/rcu.h:226 [inline]
#0: 00000000d64f8bab (rcu_callback){....}, at: rcu_do_batch
kernel/rcu/tree.c:2584 [inline]
#0: 00000000d64f8bab (rcu_callback){....}, at: invoke_rcu_callbacks
kernel/rcu/tree.c:2897 [inline]
#0: 00000000d64f8bab (rcu_callback){....}, at: __rcu_process_callbacks
kernel/rcu/tree.c:2864 [inline]
#0: 00000000d64f8bab (rcu_callback){....}, at:
rcu_process_callbacks+0xc79/0x1a30 kernel/rcu/tree.c:2881
#1: 0000000015f53a81 (rcu_read_lock_sched){....}, at:
percpu_ref_call_confirm_rcu lib/percpu-refcount.c:119 [inline]
#1: 0000000015f53a81 (rcu_read_lock_sched){....}, at:
percpu_ref_switch_to_atomic_rcu+0x1ca/0x540 lib/percpu-refcount.c:158

the shortest dependencies between 2nd lock and 1st lock:
-> (&fiq->waitq){+.+.} ops: 4 {
HARDIRQ-ON-W at:
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3900
__raw_spin_lock include/linux/spinlock_api_smp.h:142
[inline]
_raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:144
spin_lock include/linux/spinlock.h:329 [inline]
flush_bg_queue+0x1f3/0x3d0 fs/fuse/dev.c:368
fuse_request_send_background_locked+0x26d/0x4e0
fs/fuse/dev.c:609
fuse_request_send_background+0x12b/0x180
fs/fuse/dev.c:617
cuse_send_init fs/fuse/cuse.c:458 [inline]
cuse_channel_open+0x5ba/0x830 fs/fuse/cuse.c:518
misc_open+0x395/0x4c0 drivers/char/misc.c:141
chrdev_open+0x245/0x6b0 fs/char_dev.c:423
do_dentry_open+0x4c3/0x1200 fs/open.c:777
vfs_open+0xa0/0xd0 fs/open.c:886
do_last fs/namei.c:3418 [inline]
path_openat+0x10d7/0x4690 fs/namei.c:3534
do_filp_open+0x1a1/0x280 fs/namei.c:3564
do_sys_open+0x3fe/0x550 fs/open.c:1069
__do_sys_openat fs/open.c:1096 [inline]
__se_sys_openat fs/open.c:1090 [inline]
__x64_sys_openat+0x9d/0x100 fs/open.c:1090
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
SOFTIRQ-ON-W at:
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3900
__raw_spin_lock include/linux/spinlock_api_smp.h:142
[inline]
_raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:144
spin_lock include/linux/spinlock.h:329 [inline]
flush_bg_queue+0x1f3/0x3d0 fs/fuse/dev.c:368
fuse_request_send_background_locked+0x26d/0x4e0
fs/fuse/dev.c:609
fuse_request_send_background+0x12b/0x180
fs/fuse/dev.c:617
cuse_send_init fs/fuse/cuse.c:458 [inline]
cuse_channel_open+0x5ba/0x830 fs/fuse/cuse.c:518
misc_open+0x395/0x4c0 drivers/char/misc.c:141
chrdev_open+0x245/0x6b0 fs/char_dev.c:423
do_dentry_open+0x4c3/0x1200 fs/open.c:777
vfs_open+0xa0/0xd0 fs/open.c:886
do_last fs/namei.c:3418 [inline]
path_openat+0x10d7/0x4690 fs/namei.c:3534
do_filp_open+0x1a1/0x280 fs/namei.c:3564
do_sys_open+0x3fe/0x550 fs/open.c:1069
__do_sys_openat fs/open.c:1096 [inline]
__se_sys_openat fs/open.c:1090 [inline]
__x64_sys_openat+0x9d/0x100 fs/open.c:1090
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
INITIAL USE at:
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3900
__raw_spin_lock include/linux/spinlock_api_smp.h:142
[inline]
_raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:144
spin_lock include/linux/spinlock.h:329 [inline]
flush_bg_queue+0x1f3/0x3d0 fs/fuse/dev.c:368
fuse_request_send_background_locked+0x26d/0x4e0
fs/fuse/dev.c:609
fuse_request_send_background+0x12b/0x180
fs/fuse/dev.c:617
cuse_send_init fs/fuse/cuse.c:458 [inline]
cuse_channel_open+0x5ba/0x830 fs/fuse/cuse.c:518
misc_open+0x395/0x4c0 drivers/char/misc.c:141
chrdev_open+0x245/0x6b0 fs/char_dev.c:423
do_dentry_open+0x4c3/0x1200 fs/open.c:777
vfs_open+0xa0/0xd0 fs/open.c:886
do_last fs/namei.c:3418 [inline]
path_openat+0x10d7/0x4690 fs/namei.c:3534
do_filp_open+0x1a1/0x280 fs/namei.c:3564
do_sys_open+0x3fe/0x550 fs/open.c:1069
__do_sys_openat fs/open.c:1096 [inline]
__se_sys_openat fs/open.c:1090 [inline]
__x64_sys_openat+0x9d/0x100 fs/open.c:1090
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
}
... key at: [<ffffffff8a41ae40>] __key.42196+0x0/0x40
... acquired at:
__raw_spin_lock include/linux/spinlock_api_smp.h:142 [inline]
_raw_spin_lock+0x2f/0x40 kernel/locking/spinlock.c:144
spin_lock include/linux/spinlock.h:329 [inline]
aio_poll fs/aio.c:1741 [inline]
__io_submit_one fs/aio.c:1849 [inline]
io_submit_one+0xef2/0x2eb0 fs/aio.c:1885
__do_sys_io_submit fs/aio.c:1929 [inline]
__se_sys_io_submit fs/aio.c:1900 [inline]
__x64_sys_io_submit+0x1aa/0x520 fs/aio.c:1900
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> (&(&ctx->ctx_lock)->rlock){..-.} ops: 2 {
IN-SOFTIRQ-W at:
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3900
__raw_spin_lock_irq
include/linux/spinlock_api_smp.h:128 [inline]
_raw_spin_lock_irq+0x60/0x80
kernel/locking/spinlock.c:160
spin_lock_irq include/linux/spinlock.h:354 [inline]
free_ioctx_users+0x2d/0x490 fs/aio.c:614
percpu_ref_put_many include/linux/percpu-refcount.h:284
[inline]
percpu_ref_put include/linux/percpu-refcount.h:300
[inline]
percpu_ref_call_confirm_rcu lib/percpu-refcount.c:123
[inline]
percpu_ref_switch_to_atomic_rcu+0x407/0x540
lib/percpu-refcount.c:158
__rcu_reclaim kernel/rcu/rcu.h:236 [inline]
rcu_do_batch kernel/rcu/tree.c:2584 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
rcu_process_callbacks+0xba0/0x1a30
kernel/rcu/tree.c:2881
__do_softirq+0x25c/0x921 kernel/softirq.c:292
invoke_softirq kernel/softirq.c:372 [inline]
irq_exit+0x180/0x1d0 kernel/softirq.c:412
exiting_irq arch/x86/include/asm/apic.h:536 [inline]
smp_apic_timer_interrupt+0x13b/0x550
arch/x86/kernel/apic/apic.c:1056
apic_timer_interrupt+0xf/0x20
arch/x86/entry/entry_64.S:869
native_safe_halt+0xe/0x10
arch/x86/include/asm/irqflags.h:60
arch_cpu_idle+0xa/0x10 arch/x86/kernel/process.c:556
default_idle_call+0x36/0x90 kernel/sched/idle.c:93
cpuidle_idle_call kernel/sched/idle.c:153 [inline]
do_idle+0x377/0x560 kernel/sched/idle.c:262
cpu_startup_entry+0xc8/0xe0 kernel/sched/idle.c:368
start_secondary+0x3e8/0x5b0
arch/x86/kernel/smpboot.c:271
secondary_startup_64+0xa4/0xb0
arch/x86/kernel/head_64.S:243
INITIAL USE at:
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3900
__raw_spin_lock_irq include/linux/spinlock_api_smp.h:128
[inline]
_raw_spin_lock_irq+0x60/0x80
kernel/locking/spinlock.c:160
spin_lock_irq include/linux/spinlock.h:354 [inline]
aio_poll fs/aio.c:1739 [inline]
__io_submit_one fs/aio.c:1849 [inline]
io_submit_one+0xead/0x2eb0 fs/aio.c:1885
__do_sys_io_submit fs/aio.c:1929 [inline]
__se_sys_io_submit fs/aio.c:1900 [inline]
__x64_sys_io_submit+0x1aa/0x520 fs/aio.c:1900
do_syscall_64+0xfd/0x620 arch/x86/entry/common.c:293
entry_SYSCALL_64_after_hwframe+0x49/0xbe
}
... key at: [<ffffffff8a3813a0>] __key.50187+0x0/0x40
... acquired at:
mark_lock_irq kernel/locking/lockdep.c:2755 [inline]
mark_lock+0x420/0x1370 kernel/locking/lockdep.c:3127
mark_irqflags kernel/locking/lockdep.c:3005 [inline]
__lock_acquire+0xc65/0x48f0 kernel/locking/lockdep.c:3368
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3900
__raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline]
_raw_spin_lock_irq+0x60/0x80 kernel/locking/spinlock.c:160
spin_lock_irq include/linux/spinlock.h:354 [inline]
free_ioctx_users+0x2d/0x490 fs/aio.c:614
percpu_ref_put_many include/linux/percpu-refcount.h:284 [inline]
percpu_ref_put include/linux/percpu-refcount.h:300 [inline]
percpu_ref_call_confirm_rcu lib/percpu-refcount.c:123 [inline]
percpu_ref_switch_to_atomic_rcu+0x407/0x540 lib/percpu-refcount.c:158
__rcu_reclaim kernel/rcu/rcu.h:236 [inline]
rcu_do_batch kernel/rcu/tree.c:2584 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
rcu_process_callbacks+0xba0/0x1a30 kernel/rcu/tree.c:2881
__do_softirq+0x25c/0x921 kernel/softirq.c:292
invoke_softirq kernel/softirq.c:372 [inline]
irq_exit+0x180/0x1d0 kernel/softirq.c:412
exiting_irq arch/x86/include/asm/apic.h:536 [inline]
smp_apic_timer_interrupt+0x13b/0x550 arch/x86/kernel/apic/apic.c:1056
apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:869
native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:60
arch_cpu_idle+0xa/0x10 arch/x86/kernel/process.c:556
default_idle_call+0x36/0x90 kernel/sched/idle.c:93
cpuidle_idle_call kernel/sched/idle.c:153 [inline]
do_idle+0x377/0x560 kernel/sched/idle.c:262
cpu_startup_entry+0xc8/0xe0 kernel/sched/idle.c:368
start_secondary+0x3e8/0x5b0 arch/x86/kernel/smpboot.c:271
secondary_startup_64+0xa4/0xb0 arch/x86/kernel/head_64.S:243


stack backtrace:
CPU: 1 PID: 0 Comm: swapper/1 Not tainted 4.19.48 #20
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Call Trace:
<IRQ>
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x172/0x1f0 lib/dump_stack.c:113
print_irq_inversion_bug.part.0+0x2c0/0x2cd kernel/locking/lockdep.c:2621
print_irq_inversion_bug kernel/locking/lockdep.c:2624 [inline]
check_usage_forwards.cold+0x20/0x29 kernel/locking/lockdep.c:2646
mark_lock_irq kernel/locking/lockdep.c:2755 [inline]
mark_lock+0x420/0x1370 kernel/locking/lockdep.c:3127
mark_irqflags kernel/locking/lockdep.c:3005 [inline]
__lock_acquire+0xc65/0x48f0 kernel/locking/lockdep.c:3368
lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3900
__raw_spin_lock_irq include/linux/spinlock_api_smp.h:128 [inline]
_raw_spin_lock_irq+0x60/0x80 kernel/locking/spinlock.c:160
spin_lock_irq include/linux/spinlock.h:354 [inline]
free_ioctx_users+0x2d/0x490 fs/aio.c:614
percpu_ref_put_many include/linux/percpu-refcount.h:284 [inline]
percpu_ref_put include/linux/percpu-refcount.h:300 [inline]
percpu_ref_call_confirm_rcu lib/percpu-refcount.c:123 [inline]
percpu_ref_switch_to_atomic_rcu+0x407/0x540 lib/percpu-refcount.c:158
__rcu_reclaim kernel/rcu/rcu.h:236 [inline]
rcu_do_batch kernel/rcu/tree.c:2584 [inline]
invoke_rcu_callbacks kernel/rcu/tree.c:2897 [inline]
__rcu_process_callbacks kernel/rcu/tree.c:2864 [inline]
rcu_process_callbacks+0xba0/0x1a30 kernel/rcu/tree.c:2881
__do_softirq+0x25c/0x921 kernel/softirq.c:292
invoke_softirq kernel/softirq.c:372 [inline]
irq_exit+0x180/0x1d0 kernel/softirq.c:412
exiting_irq arch/x86/include/asm/apic.h:536 [inline]
smp_apic_timer_interrupt+0x13b/0x550 arch/x86/kernel/apic/apic.c:1056
apic_timer_interrupt+0xf/0x20 arch/x86/entry/entry_64.S:869
</IRQ>
RIP: 0010:native_safe_halt+0xe/0x10 arch/x86/include/asm/irqflags.h:61
Code: ff ff 48 89 df e8 72 4c b2 fa eb 82 e9 07 00 00 00 0f 00 2d e4 aa 58
00 f4 c3 66 90 e9 07 00 00 00 0f 00 2d d4 aa 58 00 fb f4 <c3> 90 55 48 89
e5 41 57 41 56 41 55 41 54 53 e8 4e 7e 6a fa e8 a9
RSP: 0018:ffff8880aa27fd00 EFLAGS: 00000282 ORIG_RAX: ffffffffffffff13
RAX: 1ffffffff10e46cc RBX: ffff8880aa2703c0 RCX: 0000000000000000
RDX: dffffc0000000000 RSI: 0000000000000001 RDI: ffff8880aa270c3c
RBP: ffff8880aa27fd30 R08: ffff8880aa2703c0 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 0000000000000001
R13: ffffffff88723650 R14: 0000000000000001 R15: 0000000000000000
arch_cpu_idle+0xa/0x10 arch/x86/kernel/process.c:556
default_idle_call+0x36/0x90 kernel/sched/idle.c:93
cpuidle_idle_call kernel/sched/idle.c:153 [inline]
do_idle+0x377/0x560 kernel/sched/idle.c:262
cpu_startup_entry+0xc8/0xe0 kernel/sched/idle.c:368
start_secondary+0x3e8/0x5b0 arch/x86/kernel/smpboot.c:271


---
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

syzbot

unread,
Dec 11, 2019, 12:45:02 PM12/11/19
to syzkaller...@googlegroups.com
syzbot suspects this bug was fixed by commit:

commit 5bead06b3443c784637d454c5c64a3bd05752cf4
Author: Eric Biggers <ebig...@google.com>
Date: Mon Sep 9 03:15:18 2019 +0000

fuse: fix deadlock with aio poll and fuse_iqueue::waitq.lock

bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=1272aaeae00000
start commit: d573e8a7 Linux 4.19.75
git tree: linux-4.19.y
kernel config: https://syzkaller.appspot.com/x/.config?x=50b385e67c7b7cdf
dashboard link: https://syzkaller.appspot.com/bug?extid=c9e3f2d9d4922e995e69
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=170979a9600000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1520c8ed600000

If the result looks correct, please mark the bug fixed by replying with:

#syz fix: fuse: fix deadlock with aio poll and fuse_iqueue::waitq.lock

For information about bisection process see: https://goo.gl/tpsmEJ#bisection

Eric Biggers

unread,
Dec 11, 2019, 12:46:16 PM12/11/19
to syzbot, syzkaller...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages