Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp2304086pxp; Mon, 21 Mar 2022 16:23:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJynHbg143zW58wvJhVpcaZIt9jahewpwhGOe7r/TduY+Cbxxq73yB3PDNvRGBnl7X4TK0d7 X-Received: by 2002:a63:7f06:0:b0:382:7f20:3b57 with SMTP id a6-20020a637f06000000b003827f203b57mr6236090pgd.107.1647905022228; Mon, 21 Mar 2022 16:23:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1647905022; cv=none; d=google.com; s=arc-20160816; b=vINKYlQ5quK5dAr0r24LpnG31cWkDixjjkYu+2dhh7mGNYMjclWdcgSpxI5T2q9JOY GnvyaqECjBZMo1BWHjn4YJlUvSVzQShdmvJnMZq9Qw13BTUw2MhvvbKvL97dqRoFLeiX 5yQ4rBGPKErvVwAtOPI4nP1JixOsLI9WYreBIh/fRgpXnbQnGEX+untFGf3wJmVbxrKn 0dgTANxfv8o+1WxEnoiYZnergV113hBGitM8cnf+cf+8drKFXDk0PkpWiyf1qLgeCn9W PcllSICXvDkCpHPV6381Bzl6puKu89KLqtstxd8X0rL63mfql2v1hHZevh59TuB8kXM1 T07w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=75Gwq4uHWEN6DEz0j9a7FSUGeVHdNTQqq72dygCbFyU=; b=yP4Z9CmdMV1YcYa/OO8VNesvpFsA8WqVkeX3eWLKlxJA4y33+/7nySyXpqOwtkY2GU iEsyY+ectPVE3RETEQuFvN8KKtwCoiLG+jZm/VAyDVcUMWuS04NXFN7i9ptGKKgF6tK3 /Zca6RCKEYH4zo2p+lAwY7LUSGnwfD9JNNFfYybQw0EqN+FFWKNuv8gQu/eudfSvMJ5+ aCjkfs8vtvdgpXzmfIVWx91LmbLkC7Cq+c31Jh8gCXmmjOrCxUn2QpdQyn9pLDsHYnb+ KKDkksqAU+/xRX0AzNlQDLnEloUH2NiS03N17q4mPMDr+fo4p1wSt8ieU0yWM+2wX6lc 63Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Ifna/CHr"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id h9-20020a170902b94900b00153bd1573c1si11799630pls.85.2022.03.21.16.23.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Mar 2022 16:23:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b="Ifna/CHr"; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CFFC742D485; Mon, 21 Mar 2022 15:24:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349518AbiCUOn1 (ORCPT + 99 others); Mon, 21 Mar 2022 10:43:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349692AbiCUOnR (ORCPT ); Mon, 21 Mar 2022 10:43:17 -0400 Received: from mail-lj1-x22d.google.com (mail-lj1-x22d.google.com [IPv6:2a00:1450:4864:20::22d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B60D118B7B9 for ; Mon, 21 Mar 2022 07:41:51 -0700 (PDT) Received: by mail-lj1-x22d.google.com with SMTP id 25so20132256ljv.10 for ; Mon, 21 Mar 2022 07:41:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=75Gwq4uHWEN6DEz0j9a7FSUGeVHdNTQqq72dygCbFyU=; b=Ifna/CHrQAnT5/LK1JI6Od2Y8qAp5JdHTZcb3L0bAL46Po6MAUaw/J4QGSXVe9707j u0uFsPlTz9sIRnWTYp7DNDUP21oh0G4LcxsNoGKVZHFddg6ODUHI6m1w2niZBfPhvSZI OQUOtNu54JuwLFTixxAq+TNT0AUNt68NWqmhxp/mVw+mLczveaAoXZV11lojcttCPnmG RstKBoKuDN/AVRRRcZr8WZ/V8CbOmjesp4D/OdrPD1vvXe9wWPdaE80nTe8CJ4HWZUbR Piboqu2cqzJUSiO/iconevRs9Ky6bTDkgk3oewG3BvY8fdgHdqkHXHO6iti1V49K9qJy M+GA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=75Gwq4uHWEN6DEz0j9a7FSUGeVHdNTQqq72dygCbFyU=; b=15IEn0k0tPoHnfkukMguFDhn1cES4PspcDJolTazzfYkkfAFp1ZLzjqpTv/7hgtehJ 2zmRGWf6ulgQ4Syh/R6XpiVGqeqWCHvz/fvnUANbYgOKZTl34JZxbUf+iQ+QmyplyS5G 5/rQtk0gCAoB2jc+S53m78dVqDRS6gZl7oFS6gKzlM28YMbA5c4XB+rewwkPPRZsbu07 Hkp1SZQBI1XOegQtHIY9g+RdlmqbomXWiDMg063NQD68IJyW/gKvcqWRp8tzjyczMBH9 Ma/keM7lW6lwtj4trNuH7FGU2rMj7eNtUxTAJf9KYdARDjoALe0KlM97AlceO8zLoiUO cCPg== X-Gm-Message-State: AOAM531Wb1/wGfonbSZ5R7QK4Z6pA/ZMi+YxxudbMi8ZSRsyk7hFjHm7 Otm7/9SiQ4722X2y/fT2ixdceTkP4aA7FiUeGv8xbWcoBiRgXQ== X-Received: by 2002:a2e:3607:0:b0:249:87a5:af18 with SMTP id d7-20020a2e3607000000b0024987a5af18mr2707697lja.93.1647873709522; Mon, 21 Mar 2022 07:41:49 -0700 (PDT) MIME-Version: 1.0 References: <000000000000778f1005dab1558e@google.com> In-Reply-To: <000000000000778f1005dab1558e@google.com> From: Jann Horn Date: Mon, 21 Mar 2022 15:41:13 +0100 Message-ID: Subject: Re: [syzbot] possible deadlock in pipe_write To: syzbot , David Howells Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com, viro@zeniv.linux.org.uk Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This also looks like a watch_queue bug. On Mon, Mar 21, 2022 at 3:34 AM syzbot wrote: > > Hello, > > syzbot found the following issue on: > > HEAD commit: 56e337f2cf13 Revert "gpio: Revert regression in sysfs-gpio.. > git tree: upstream > console output: https://syzkaller.appspot.com/x/log.txt?x=13f00f7e700000 > kernel config: https://syzkaller.appspot.com/x/.config?x=d35f9bc6884af6c9 > dashboard link: https://syzkaller.appspot.com/bug?extid=011e4ea1da6692cf881c > compiler: gcc (Debian 10.2.1-6) 10.2.1 20210110, GNU ld (GNU Binutils for Debian) 2.35.2 > syz repro: https://syzkaller.appspot.com/x/repro.syz?x=133235c5700000 The syz reproducer is: #{"threaded":true,"procs":1,"slowdown":1,"sandbox":"","close_fds":false} pipe(&(0x7f0000000240)={0xffffffffffffffff, 0xffffffffffffffff}) pipe2(&(0x7f00000001c0)={0xffffffffffffffff, 0xffffffffffffffff}, 0x80) splice(r0, 0x0, r2, 0x0, 0x1ff, 0x0) vmsplice(r1, &(0x7f00000006c0)=[{&(0x7f0000000080)="b5", 0x1}], 0x1, 0x0) That 0x80 is O_NOTIFICATION_PIPE (==O_EXCL). It looks like the bug is that when you try to splice between a normal pipe and a notification pipe, get_pipe_info(..., true) fails, so splice() falls back to treating the notification pipe like a normal pipe - so we end up in iter_file_splice_write(), which first locks the input pipe, then calls vfs_iter_write(), which locks the output pipe. I think this probably (?) can't actually lead to deadlocks, since you'd need another way to nest locking a normal pipe into locking a watch_queue pipe, but the lockdep annotations don't make that clear. > C reproducer: https://syzkaller.appspot.com/x/repro.c?x=1248ca89700000 > > Bisection is inconclusive: the issue happens on the oldest tested release. > > bisection log: https://syzkaller.appspot.com/x/bisect.txt?x=12f235c5700000 > final oops: https://syzkaller.appspot.com/x/report.txt?x=11f235c5700000 > console output: https://syzkaller.appspot.com/x/log.txt?x=16f235c5700000 > > IMPORTANT: if you fix the issue, please add the following tag to the commit: > Reported-by: syzbot+011e4ea1da6692cf881c@syzkaller.appspotmail.com > > ============================================ > WARNING: possible recursive locking detected > 5.17.0-rc8-syzkaller-00003-g56e337f2cf13 #0 Not tainted > -------------------------------------------- > syz-executor190/3593 is trying to acquire lock: > ffff888078020868 (&pipe->mutex/1){+.+.}-{3:3}, at: __pipe_lock fs/pipe.c:103 [inline] > ffff888078020868 (&pipe->mutex/1){+.+.}-{3:3}, at: pipe_write+0x132/0x1c00 fs/pipe.c:431 > > but task is already holding lock: > ffff888078020468 (&pipe->mutex/1){+.+.}-{3:3}, at: pipe_lock_nested fs/pipe.c:82 [inline] > ffff888078020468 (&pipe->mutex/1){+.+.}-{3:3}, at: pipe_lock fs/pipe.c:90 [inline] > ffff888078020468 (&pipe->mutex/1){+.+.}-{3:3}, at: pipe_wait_readable+0x39b/0x420 fs/pipe.c:1049 > > other info that might help us debug this: > Possible unsafe locking scenario: > > CPU0 > ---- > lock(&pipe->mutex/1); > lock(&pipe->mutex/1); > > *** DEADLOCK *** > > May be due to missing lock nesting notation > > 1 lock held by syz-executor190/3593: > #0: ffff888078020468 (&pipe->mutex/1){+.+.}-{3:3}, at: pipe_lock_nested fs/pipe.c:82 [inline] > #0: ffff888078020468 (&pipe->mutex/1){+.+.}-{3:3}, at: pipe_lock fs/pipe.c:90 [inline] > #0: ffff888078020468 (&pipe->mutex/1){+.+.}-{3:3}, at: pipe_wait_readable+0x39b/0x420 fs/pipe.c:1049 > > stack backtrace: > CPU: 1 PID: 3593 Comm: syz-executor190 Not tainted 5.17.0-rc8-syzkaller-00003-g56e337f2cf13 #0 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 > Call Trace: > > __dump_stack lib/dump_stack.c:88 [inline] > dump_stack_lvl+0xcd/0x134 lib/dump_stack.c:106 > print_deadlock_bug kernel/locking/lockdep.c:2956 [inline] > check_deadlock kernel/locking/lockdep.c:2999 [inline] > validate_chain kernel/locking/lockdep.c:3788 [inline] > __lock_acquire.cold+0x213/0x3a9 kernel/locking/lockdep.c:5027 > lock_acquire kernel/locking/lockdep.c:5639 [inline] > lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5604 > __mutex_lock_common kernel/locking/mutex.c:600 [inline] > __mutex_lock+0x12f/0x12f0 kernel/locking/mutex.c:733 > __pipe_lock fs/pipe.c:103 [inline] > pipe_write+0x132/0x1c00 fs/pipe.c:431 > call_write_iter include/linux/fs.h:2074 [inline] > do_iter_readv_writev+0x47a/0x750 fs/read_write.c:725 > do_iter_write+0x188/0x710 fs/read_write.c:851 > vfs_iter_write+0x70/0xa0 fs/read_write.c:892 > iter_file_splice_write+0x723/0xc70 fs/splice.c:689 > do_splice_from fs/splice.c:767 [inline] > do_splice+0xb7e/0x1960 fs/splice.c:1079 > __do_splice+0x134/0x250 fs/splice.c:1144 > __do_sys_splice fs/splice.c:1350 [inline] > __se_sys_splice fs/splice.c:1332 [inline] > __x64_sys_splice+0x198/0x250 fs/splice.c:1332 > do_syscall_x64 arch/x86/entry/common.c:50 [inline] > do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80 > entry_SYSCALL_64_after_hwframe+0x44/0xae > RIP: 0033:0x7fb9ac14bca9 > Code: 28 00 00 00 75 05 48 83 c4 28 c3 e8 81 14 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48 > RSP: 002b:00007fb9ac0fe308 EFLAGS: 00000246 ORIG_RAX: 0000000000000113 > RAX: fffffff > > > --- > 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@googlegroups.com. > > syzbot will keep track of this issue. See: > https://goo.gl/tpsmEJ#status for how to communicate with syzbot. > For information about bisection process see: https://goo.gl/tpsmEJ#bisection > syzbot can test patches for this issue, for details see: > https://goo.gl/tpsmEJ#testing-patches >