Re: [syzbot] possible deadlock in smc_switch_to_fallback

From: Pavel Skripkin
Date: Sat Nov 20 2021 - 09:55:17 EST


On 11/20/21 05:47, syzbot wrote:
Hello,

syzbot found the following issue on:

HEAD commit: 9539ba4308ad Merge tag 'riscv-for-linus-5.16-rc2' of git:/..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=17f79d01b00000
kernel config: https://syzkaller.appspot.com/x/.config?x=6d3b8fd1977c1e73
dashboard link: https://syzkaller.appspot.com/bug?extid=e979d3597f48262cb4ee
compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2

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+e979d3597f48262cb4ee@xxxxxxxxxxxxxxxxxxxxxxxxx

============================================
WARNING: possible recursive locking detected
5.16.0-rc1-syzkaller #0 Not tainted
--------------------------------------------
syz-executor.3/1337 is trying to acquire lock:
ffff88809466ce58 (&ei->socket.wq.wait){..-.}-{2:2}, at: spin_lock include/linux/spinlock.h:349 [inline]
ffff88809466ce58 (&ei->socket.wq.wait){..-.}-{2:2}, at: smc_switch_to_fallback+0x3d5/0x8c0 net/smc/af_smc.c:588
> but task is already holding lock:
ffff88809466c258 (&ei->socket.wq.wait){..-.}-{2:2}, at: smc_switch_to_fallback+0x3ca/0x8c0 net/smc/af_smc.c:587
> other info that might help us debug this:
Possible unsafe locking scenario:

CPU0
----
lock(&ei->socket.wq.wait);
lock(&ei->socket.wq.wait);


There is simple code block in net/smc/af_smc.c:

spin_lock_irqsave(&smc_wait->lock, flags);
spin_lock(&clc_wait->lock);
list_splice_init(&smc_wait->head, &clc_wait->head);
spin_unlock(&clc_wait->lock);
spin_unlock_irqrestore(&smc_wait->lock, flags);

smc_wait and clc_wait are too different pointers (based on report), but these 2 different wait_queue locks registered to lockdep map via sock_alloc_inode(), where init_waitqueue_head(&ei->socket.wq.wait); is called. So any nested wait_queue_head_t locking will cause lockdep warning.

Have no idea how to handle it, just my thoughts about root case :)





With regards,
Pavel Skripkin