possible deadlock in proc_pid_stack

5 views
Skip to first unread message

syzbot

unread,
Aug 9, 2020, 9:43:18 AM8/9/20
to syzkaller...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 14b58326 Linux 4.14.193
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=140774e2900000
kernel config: https://syzkaller.appspot.com/x/.config?x=68ef0287ccbc3b42
dashboard link: https://syzkaller.appspot.com/bug?extid=b6ae406d9b2b1c08371f
compiler: gcc (GCC) 10.1.0-syz 20200507

Unfortunately, I don't have any reproducer for this issue yet.

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

======================================================
WARNING: possible circular locking dependency detected
4.14.193-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor.0/12019 is trying to acquire lock:
(&sig->cred_guard_mutex){+.+.}, at: [<ffffffff81a6de5f>] lock_trace fs/proc/base.c:407 [inline]
(&sig->cred_guard_mutex){+.+.}, at: [<ffffffff81a6de5f>] proc_pid_stack+0x13f/0x2f0 fs/proc/base.c:457

but task is already holding lock:
(&p->lock){+.+.}, at: [<ffffffff8195115a>] seq_read+0xba/0x1120 fs/seq_file.c:165

which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:

-> #3 (&p->lock){+.+.}:
__mutex_lock_common kernel/locking/mutex.c:756 [inline]
__mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
seq_read+0xba/0x1120 fs/seq_file.c:165
proc_reg_read+0xee/0x1a0 fs/proc/inode.c:217
do_loop_readv_writev fs/read_write.c:695 [inline]
do_loop_readv_writev fs/read_write.c:682 [inline]
do_iter_read+0x3eb/0x5b0 fs/read_write.c:919
vfs_readv+0xc8/0x120 fs/read_write.c:981
kernel_readv fs/splice.c:361 [inline]
default_file_splice_read+0x418/0x910 fs/splice.c:416
do_splice_to+0xfb/0x140 fs/splice.c:880
splice_direct_to_actor+0x207/0x730 fs/splice.c:952
do_splice_direct+0x164/0x210 fs/splice.c:1061
do_sendfile+0x47f/0xb30 fs/read_write.c:1441
SYSC_sendfile64 fs/read_write.c:1502 [inline]
SyS_sendfile64+0xff/0x110 fs/read_write.c:1488
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

-> #2 (sb_writers#3){.+.+}:
percpu_down_read_preempt_disable include/linux/percpu-rwsem.h:36 [inline]
percpu_down_read include/linux/percpu-rwsem.h:59 [inline]
__sb_start_write+0x19a/0x2e0 fs/super.c:1363
sb_start_write include/linux/fs.h:1549 [inline]
mnt_want_write+0x3a/0xb0 fs/namespace.c:386
ovl_create_object+0x75/0x1d0 fs/overlayfs/dir.c:538
lookup_open+0x77a/0x1750 fs/namei.c:3241
do_last fs/namei.c:3334 [inline]
path_openat+0xe08/0x2970 fs/namei.c:3569
do_filp_open+0x179/0x3c0 fs/namei.c:3603
do_sys_open+0x296/0x410 fs/open.c:1081
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

-> #1 (&ovl_i_mutex_dir_key[depth]){++++}:
down_read+0x36/0x80 kernel/locking/rwsem.c:24
inode_lock_shared include/linux/fs.h:729 [inline]
do_last fs/namei.c:3333 [inline]
path_openat+0x149b/0x2970 fs/namei.c:3569
do_filp_open+0x179/0x3c0 fs/namei.c:3603
do_open_execat+0xd3/0x450 fs/exec.c:849
do_execveat_common+0x711/0x1f30 fs/exec.c:1742
do_execve fs/exec.c:1847 [inline]
SYSC_execve fs/exec.c:1928 [inline]
SyS_execve+0x3b/0x50 fs/exec.c:1923
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

-> #0 (&sig->cred_guard_mutex){+.+.}:
lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
__mutex_lock_common kernel/locking/mutex.c:756 [inline]
__mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
lock_trace fs/proc/base.c:407 [inline]
proc_pid_stack+0x13f/0x2f0 fs/proc/base.c:457
proc_single_show+0xe7/0x150 fs/proc/base.c:761
seq_read+0x4cf/0x1120 fs/seq_file.c:237
do_loop_readv_writev fs/read_write.c:695 [inline]
do_loop_readv_writev fs/read_write.c:682 [inline]
do_iter_read+0x3eb/0x5b0 fs/read_write.c:919
vfs_readv+0xc8/0x120 fs/read_write.c:981
do_preadv fs/read_write.c:1065 [inline]
SYSC_preadv fs/read_write.c:1115 [inline]
SyS_preadv+0x15a/0x200 fs/read_write.c:1110
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb

other info that might help us debug this:

Chain exists of:
&sig->cred_guard_mutex --> sb_writers#3 --> &p->lock

Possible unsafe locking scenario:

CPU0 CPU1
---- ----
lock(&p->lock);
lock(sb_writers#3);
lock(&p->lock);
lock(&sig->cred_guard_mutex);

*** DEADLOCK ***

1 lock held by syz-executor.0/12019:
#0: (&p->lock){+.+.}, at: [<ffffffff8195115a>] seq_read+0xba/0x1120 fs/seq_file.c:165

stack backtrace:
CPU: 1 PID: 12019 Comm: syz-executor.0 Not tainted 4.14.193-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:17 [inline]
dump_stack+0x1b2/0x283 lib/dump_stack.c:58
print_circular_bug.constprop.0.cold+0x2d7/0x41e kernel/locking/lockdep.c:1258
check_prev_add kernel/locking/lockdep.c:1905 [inline]
check_prevs_add kernel/locking/lockdep.c:2022 [inline]
validate_chain kernel/locking/lockdep.c:2464 [inline]
__lock_acquire+0x2e0e/0x3f20 kernel/locking/lockdep.c:3491
lock_acquire+0x170/0x3f0 kernel/locking/lockdep.c:3998
__mutex_lock_common kernel/locking/mutex.c:756 [inline]
__mutex_lock+0xc4/0x1310 kernel/locking/mutex.c:893
lock_trace fs/proc/base.c:407 [inline]
proc_pid_stack+0x13f/0x2f0 fs/proc/base.c:457
proc_single_show+0xe7/0x150 fs/proc/base.c:761
seq_read+0x4cf/0x1120 fs/seq_file.c:237
do_loop_readv_writev fs/read_write.c:695 [inline]
do_loop_readv_writev fs/read_write.c:682 [inline]
do_iter_read+0x3eb/0x5b0 fs/read_write.c:919
vfs_readv+0xc8/0x120 fs/read_write.c:981
do_preadv fs/read_write.c:1065 [inline]
SYSC_preadv fs/read_write.c:1115 [inline]
SyS_preadv+0x15a/0x200 fs/read_write.c:1110
do_syscall_64+0x1d5/0x640 arch/x86/entry/common.c:292
entry_SYSCALL_64_after_hwframe+0x46/0xbb
RIP: 0033:0x45ce69
RSP: 002b:00007fb9aaa58c78 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 0000000000024ac0 RCX: 000000000045ce69
RDX: 0000000000000375 RSI: 00000000200017c0 RDI: 0000000000000006
RBP: 000000000118c150 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000118c10c
R13: 00007ffc2f26963f R14: 00007fb9aaa599c0 R15: 000000000118c10c
PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
PM: Marking nosave pages: [mem 0x0009f000-0x000fffff]
PM: Marking nosave pages: [mem 0xbfffd000-0xffffffff]
netlink: 116 bytes leftover after parsing attributes in process `syz-executor.2'.
PM: Basic memory bitmaps created
audit: type=1800 audit(1596980554.897:14): pid=12467 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.3" name="bus" dev="sda1" ino=15906 res=0
PM: Basic memory bitmaps freed
PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
PM: Marking nosave pages: [mem 0x0009f000-0x000fffff]
PM: Marking nosave pages: [mem 0xbfffd000-0xffffffff]
PM: Basic memory bitmaps created
PM: Basic memory bitmaps freed
netlink: 116 bytes leftover after parsing attributes in process `syz-executor.2'.
audit: type=1800 audit(1596980555.117:15): pid=12494 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.3" name="bus" dev="sda1" ino=16391 res=0
PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
PM: Marking nosave pages: [mem 0x0009f000-0x000fffff]
PM: Marking nosave pages: [mem 0xbfffd000-0xffffffff]
netlink: 116 bytes leftover after parsing attributes in process `syz-executor.2'.
PM: Basic memory bitmaps created
audit: type=1800 audit(1596980555.277:16): pid=12520 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.3" name="bus" dev="sda1" ino=16391 res=0
PM: Basic memory bitmaps freed
PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
PM: Marking nosave pages: [mem 0x0009f000-0x000fffff]
PM: Marking nosave pages: [mem 0xbfffd000-0xffffffff]
netlink: 116 bytes leftover after parsing attributes in process `syz-executor.2'.
audit: type=1800 audit(1596980555.457:17): pid=12536 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.3" name="bus" dev="sda1" ino=16392 res=0
PM: Basic memory bitmaps created
audit: type=1800 audit(1596980555.577:18): pid=12550 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.3" name="bus" dev="sda1" ino=16392 res=0
audit: type=1800 audit(1596980555.647:19): pid=12551 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.2" name="bus" dev="sda1" ino=16393 res=0
audit: type=1800 audit(1596980555.687:20): pid=12555 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.3" name="bus" dev="sda1" ino=16392 res=0
audit: type=1800 audit(1596980555.737:21): pid=12559 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.2" name="bus" dev="sda1" ino=16393 res=0
audit: type=1800 audit(1596980555.747:22): pid=12563 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.3" name="bus" dev="sda1" ino=16392 res=0
PM: Basic memory bitmaps freed
audit: type=1800 audit(1596980555.807:23): pid=12568 uid=0 auid=0 ses=4 subj=system_u:system_r:kernel_t:s0 op="collect_data" cause="failed(directio)" comm="syz-executor.2" name="bus" dev="sda1" ino=16393 res=0
PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
PM: Marking nosave pages: [mem 0x0009f000-0x000fffff]
PM: Marking nosave pages: [mem 0xbfffd000-0xffffffff]
PM: Basic memory bitmaps created
PM: Basic memory bitmaps freed
PM: Marking nosave pages: [mem 0x00000000-0x00000fff]
PM: Marking nosave pages: [mem 0x0009f000-0x000fffff]
PM: Marking nosave pages: [mem 0xbfffd000-0xffffffff]
PM: Basic memory bitmaps created
mmap: syz-executor.2 (12640): VmData 54177792 exceed data ulimit 0. Update limits or use boot option ignore_rlimit_data.
PM: Basic memory bitmaps freed
kvm_hv_set_msr: 14 callbacks suppressed
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x40000007 data 0x0
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x40000035 data 0x8600
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x40000035 data 0x8600
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x40000035 data 0x8600
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x4000002f data 0x8600
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x40000069 data 0x8600
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x40000009 data 0x8600
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x40000031 data 0x8600
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x40000031 data 0x8600
kvm [12853]: vcpu0, guest rIP: 0xc5 Hyper-V uhandled wrmsr: 0x40000011 data 0x8600
ieee80211 phy2: Selected rate control algorithm 'minstrel_ht'
ieee80211 phy2: hwaddr 02:00:00:00:02:00 registered
ieee80211 phy3: Selected rate control algorithm 'minstrel_ht'
ieee80211 phy3: hwaddr 02:00:00:00:03:00 registered
ieee80211 phy4: Selected rate control algorithm 'minstrel_ht'
ieee80211 phy4: hwaddr 02:00:00:00:04:00 registered


---
This report 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 issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

syzbot

unread,
Aug 9, 2020, 10:23:27 PM8/9/20
to syzkaller...@googlegroups.com
syzbot has found a reproducer for the following issue on:

HEAD commit: 14b58326 Linux 4.14.193
git tree: linux-4.14.y
console output: https://syzkaller.appspot.com/x/log.txt?x=15d39776900000
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=13cc2334900000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=12b98406900000

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

audit: type=1400 audit(1597025995.386:8): avc: denied { execmem } for pid=6349 comm="syz-executor905" scontext=system_u:system_r:kernel_t:s0 tcontext=system_u:system_r:kernel_t:s0 tclass=process permissive=1
======================================================
WARNING: possible circular locking dependency detected
4.14.193-syzkaller #0 Not tainted
------------------------------------------------------
syz-executor905/6349 is trying to acquire lock:
1 lock held by syz-executor905/6349:
#0: (&p->lock){+.+.}, at: [<ffffffff8195115a>] seq_read+0xba/0x1120 fs/seq_file.c:165

stack backtrace:
CPU: 0 PID: 6349 Comm: syz-executor905 Not tainted 4.14.193-syzkaller #0
RIP: 0033:0x4405b9
RSP: 002b:00007fffae48d538 EFLAGS: 00000246 ORIG_RAX: 0000000000000127
RAX: ffffffffffffffda RBX: 00007fffae48d540 RCX: 00000000004405b9
RDX: 0000000000000375 RSI: 00000000200017c0 RDI: 0000000000000005
RBP: 0

Reply all
Reply to author
Forward
0 new messages