possible deadlock in ovl_dir_real_file

6 views
Skip to first unread message

syzbot

unread,
Feb 1, 2021, 4:17:14 AM2/1/21
to linux-...@vger.kernel.org, linux-...@vger.kernel.org, mik...@szeredi.hu, syzkall...@googlegroups.com
Hello,

syzbot found the following issue on:

HEAD commit: 6642d600 Merge tag '5.11-rc5-smb3' of git://git.samba.org/..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=148aef78d00000
kernel config: https://syzkaller.appspot.com/x/.config?x=9408d1770a50819c
dashboard link: https://syzkaller.appspot.com/bug?extid=6a023cb2262c79301432
compiler: clang version 11.0.1

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+6a023c...@syzkaller.appspotmail.com

============================================
WARNING: possible recursive locking detected
5.11.0-rc5-syzkaller #0 Not tainted
--------------------------------------------
syz-executor.2/3639 is trying to acquire lock:
ffff888084c0b5f0 (&ovl_i_mutex_dir_key[depth]){++++}-{3:3}, at: inode_lock include/linux/fs.h:773 [inline]
ffff888084c0b5f0 (&ovl_i_mutex_dir_key[depth]){++++}-{3:3}, at: ovl_dir_real_file+0x20b/0x310 fs/overlayfs/readdir.c:886

but task is already holding lock:
ffff888084c0b5f0 (&ovl_i_mutex_dir_key[depth]){++++}-{3:3}, at: inode_lock include/linux/fs.h:773 [inline]
ffff888084c0b5f0 (&ovl_i_mutex_dir_key[depth]){++++}-{3:3}, at: ovl_ioctl_set_flags fs/overlayfs/file.c:530 [inline]
ffff888084c0b5f0 (&ovl_i_mutex_dir_key[depth]){++++}-{3:3}, at: ovl_ioctl+0x2fb/0x960 fs/overlayfs/file.c:569

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

CPU0
----
lock(&ovl_i_mutex_dir_key[depth]);
lock(&ovl_i_mutex_dir_key[depth]);

*** DEADLOCK ***

May be due to missing lock nesting notation

2 locks held by syz-executor.2/3639:
#0: ffff88807a706460 (sb_writers#17){.+.+}-{0:0}, at: mnt_want_write_file+0x5a/0x250 fs/namespace.c:412
#1: ffff888084c0b5f0 (&ovl_i_mutex_dir_key[depth]){++++}-{3:3}, at: inode_lock include/linux/fs.h:773 [inline]
#1: ffff888084c0b5f0 (&ovl_i_mutex_dir_key[depth]){++++}-{3:3}, at: ovl_ioctl_set_flags fs/overlayfs/file.c:530 [inline]
#1: ffff888084c0b5f0 (&ovl_i_mutex_dir_key[depth]){++++}-{3:3}, at: ovl_ioctl+0x2fb/0x960 fs/overlayfs/file.c:569

stack backtrace:
CPU: 1 PID: 3639 Comm: syz-executor.2 Not tainted 5.11.0-rc5-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:79 [inline]
dump_stack+0x137/0x1be lib/dump_stack.c:120
__lock_acquire+0x2333/0x5e90 kernel/locking/lockdep.c:4670
lock_acquire+0x114/0x5e0 kernel/locking/lockdep.c:5442
down_write+0x56/0x120 kernel/locking/rwsem.c:1406
inode_lock include/linux/fs.h:773 [inline]
ovl_dir_real_file+0x20b/0x310 fs/overlayfs/readdir.c:886
ovl_real_fdget fs/overlayfs/file.c:136 [inline]
ovl_real_ioctl fs/overlayfs/file.c:499 [inline]
ovl_ioctl_set_flags fs/overlayfs/file.c:545 [inline]
ovl_ioctl+0x4de/0x960 fs/overlayfs/file.c:569
vfs_ioctl fs/ioctl.c:48 [inline]
__do_sys_ioctl fs/ioctl.c:753 [inline]
__se_sys_ioctl+0xfb/0x170 fs/ioctl.c:739
do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x45e219
Code: 0d b4 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 db b3 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f02ed677c68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010
RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 000000000045e219
RDX: 0000000000000000 RSI: 0000000040086602 RDI: 0000000000000003
RBP: 000000000119bfc0 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 000000000119bf8c
R13: 00007ffd373df6ef R14: 00007f02ed6789c0 R15: 000000000119bf8c


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

Amir Goldstein

unread,
Feb 1, 2021, 4:39:29 AM2/1/21
to syzbot, linux-kernel, overlayfs, Miklos Szeredi, syzkaller-bugs
#syz fix: ovl: avoid deadlock on directory ioctl

Should be in linux-next tree already.

Thanks,
Amir.
Reply all
Reply to author
Forward
0 new messages