Re: WARNING: suspicious RCU usage in io_init_identity

From: Qian Cai
Date: Fri Oct 16 2020 - 11:02:35 EST


On Fri, 2020-10-16 at 01:12 -0700, syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: b2926c10 Add linux-next specific files for 20201016
> git tree: linux-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=12fc877f900000
> kernel config: https://syzkaller.appspot.com/x/.config?x=6160209582f55fb1
> dashboard link: https://syzkaller.appspot.com/bug?extid=4596e1fcf98efa7d1745
> 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+4596e1fcf98efa7d1745@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> =============================
> WARNING: suspicious RCU usage
> 5.9.0-next-20201016-syzkaller #0 Not tainted
> -----------------------------
> include/linux/cgroup.h:494 suspicious rcu_dereference_check() usage!

Introduced by the linux-next commits:

07950f53f85b ("io_uring: COW io_identity on mismatch")

Can't find the patchset was posted anywhere. Anyway, this should fix it?

--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -1049,7 +1049,9 @@ static void io_init_identity(struct io_identity *id)
id->files = current->files;
id->mm = current->mm;
#ifdef CONFIG_BLK_CGROUP
+ rcu_read_lock();
id->blkcg_css = blkcg_css();
+ rcu_read_unlock();
#endif
id->creds = current_cred();
id->nsproxy = current->nsproxy;

>
> other info that might help us debug this:
>
>
> rcu_scheduler_active = 2, debug_locks = 1
> no locks held by syz-executor.0/8301.
>
> stack backtrace:
> CPU: 0 PID: 8301 Comm: syz-executor.0 Not tainted 5.9.0-next-20201016-
> syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google
> 01/01/2011
> Call Trace:
> __dump_stack lib/dump_stack.c:77 [inline]
> dump_stack+0x198/0x1fb lib/dump_stack.c:118
> task_css include/linux/cgroup.h:494 [inline]
> blkcg_css include/linux/blk-cgroup.h:224 [inline]
> blkcg_css include/linux/blk-cgroup.h:217 [inline]
> io_init_identity+0x3a9/0x450 fs/io_uring.c:1052
> io_uring_alloc_task_context+0x176/0x250 fs/io_uring.c:7730
> io_uring_add_task_file+0x10d/0x180 fs/io_uring.c:8653
> io_uring_get_fd fs/io_uring.c:9144 [inline]
> io_uring_create fs/io_uring.c:9308 [inline]
> io_uring_setup+0x2727/0x3660 fs/io_uring.c:9342
> do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
> RIP: 0033:0x45de59
> 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:00007f7e11fe1bf8 EFLAGS: 00000206 ORIG_RAX: 00000000000001a9
> RAX: ffffffffffffffda RBX: 0000000020000080 RCX: 000000000045de59
> RDX: 00000000206d4000 RSI: 0000000020000080 RDI: 0000000000000087
> RBP: 000000000118c020 R08: 0000000020000040 R09: 0000000020000040
> R10: 0000000020000000 R11: 0000000000000206 R12: 00000000206d4000
> R13: 0000000020ee7000 R14: 0000000020000040 R15: 0000000020000000
>
>
> ---
> 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 syzkaller@xxxxxxxxxxxxxxxx.
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.