Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp1167993rdh; Fri, 24 Nov 2023 06:39:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdceuHVaadJp4spyjsqH5otHoZjDTBL/FK8VXychN17gbOZvqw2OnasaXt5XbMkXOUPCBe X-Received: by 2002:a05:6a21:33aa:b0:18a:d7a8:5e65 with SMTP id yy42-20020a056a2133aa00b0018ad7a85e65mr3899899pzb.0.1700836766011; Fri, 24 Nov 2023 06:39:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700836765; cv=none; d=google.com; s=arc-20160816; b=TghdNWhOEhmnsTWGy6pWTwDlN5FNAGb2PbRbOJTBBEgzLlFGK3qxdgRqX44t9hiNKY D4hJz56GemcLm/eHrPOJ4RIgNOIpFAyi5V0Brx89jkshLO9178Uv5nnO8WwdyhIgdijE QI400OvhMhrwBgQj+h+ZrLqUSvDu3Hoe15xlvsDd5imIP4uBibbHscXbniAQlFgkEfmL /3BXTJAek8fC9jewHDXuZqV+5hayjuQ1daeNSv24kbUH4PWGxogQZeJaElRlkBE2Ts8R uhQ3KMBnW52Zr2D2DcZO52IstcS9H5N9euh2xylfRVxhOj3Hjd/ZSOMTWr75r06ql3AZ +bwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=5qT9ijJ1bpTu4n/ZbJUawbOnA+vfnCrxXXqloSbnIeQ=; fh=UYqJMs6WMcJTgG3rqmQTj9U0T/O1P3O0f+VPV/aeFno=; b=lnFXoUHA5ispUcfp551d8ZeY2jvX2GzUfKhHMjf6aGJYjpQFY1IrWcE0lgivw4Pdml WQulCIaJT3e8mjUpP7rEP17iS1yp1Mg16vBT8It9BuJJVk7l7SJMyue6+/OfKby23+Cc LtGiahDDpLcbTa+p4gy8kfSyIPTjQkBWXVY/ejbo/73ZHIQgXJ+qHPz/BnpUYaat/mQR GO8eMpdN51QI7GXwifUvmoSbas9EtCYVNbKDKWMM69YXIqYeDUx8DKaXCxgI17ZHXP8l bNq+PH/2DiT8hdcQlK/22sf/5q7/ZkTYnVgd7T6kGkd0Z0P1wx9JCspmL9imtDWMiUM/ cT8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yDesW49T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id a21-20020a056a001d1500b006cbee4dc5ffsi2947837pfx.359.2023.11.24.06.39.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Nov 2023 06:39:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=yDesW49T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D81B980B2D77; Fri, 24 Nov 2023 06:39:22 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230159AbjKXOiz (ORCPT + 99 others); Fri, 24 Nov 2023 09:38:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231133AbjKXOiy (ORCPT ); Fri, 24 Nov 2023 09:38:54 -0500 Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 852FA19A8 for ; Fri, 24 Nov 2023 06:39:00 -0800 (PST) Received: by mail-ed1-x533.google.com with SMTP id 4fb4d7f45d1cf-54744e66d27so25014a12.0 for ; Fri, 24 Nov 2023 06:39:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700836739; x=1701441539; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=5qT9ijJ1bpTu4n/ZbJUawbOnA+vfnCrxXXqloSbnIeQ=; b=yDesW49T0+1evvm89TEnbWe/ZJLfnelZU76CL2gT+DrlXkFsU8RJ9HXX7T4xBS3nqG YWvsclM5ILHTglF4+l518OLadzDDUjzfi0cwS0+rRB+kzOrai1+Ovgyb3G5TJFIba6H1 m9822nmo4TsdOkRtMaEfcpUlX1CgNMFRhmRNLpQsvNVrJjA/9hco8fRTkBs7v70cXe5r OjnqoxQ22Kdrr+091RVsrfNbDXrOrLgdhxYzn7a1MuSpkQ5lNR9UmGK5HBx90kGv72RW tX94HqQfSjb/6rLy7V6LkgrKhSNkA+Wlr+bv2DHqly7Xz3JUm71fCb3c4Cy++mbMmlfo T4ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700836739; x=1701441539; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5qT9ijJ1bpTu4n/ZbJUawbOnA+vfnCrxXXqloSbnIeQ=; b=VIZuUW4Mo1FeG2x4ZuHOd5VMF5U8W7N610726AUXziM5IDNBgJ9d169CL0cbyWGClF O98WG/5ulUUvnxCzniL8eMs0a6lAXpMyPItf2koMVpuUO+PHBedHSHyprxADw9VHfgBx XML/CzwNLx+TWNNU+z0T4qPjg/ME+KRTZzC7VieXNbl9Gyp3jlG3veMEoiZe5+g1xroH 9mM5CQV9w2o+wkNhjWMHPZuIfgtQUvj31uUhrlYTjwPmZRLSMlYCivXVbF1cObuoAK5n YXgzyAK47dWwtVYSNKKE96K/bgzaH19/sW2imLqGKTqmUKwxpJkejzOh08SmpuAWBFJ1 cgWw== X-Gm-Message-State: AOJu0YxJeF3CnZfY4cB9jQVGRojWjBIBUEmg/pKPy9I084FncRbq/Eq/ rHNIAtQHavtc9Xf77Y+Yp+tQJx5xj7S46m0QqYroDQ== X-Received: by 2002:a05:6402:11c6:b0:54a:ee8b:7a8c with SMTP id j6-20020a05640211c600b0054aee8b7a8cmr102165edw.0.1700836738829; Fri, 24 Nov 2023 06:38:58 -0800 (PST) MIME-Version: 1.0 References: <000000000000778f1005dab1558e@google.com> <1037989.1647878628@warthog.procyon.org.uk> In-Reply-To: From: Jann Horn Date: Fri, 24 Nov 2023 15:38:21 +0100 Message-ID: Subject: Re: [syzbot] possible deadlock in pipe_write To: David Howells Cc: syzbot , 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" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Fri, 24 Nov 2023 06:39:23 -0800 (PST) On Mon, Mar 21, 2022 at 5:17=E2=80=AFPM Jann Horn wrote: > On Mon, Mar 21, 2022 at 5:03 PM David Howells wrote= : > > Jann Horn wrote: > > > > > The syz reproducer is: > > > > > > #{"threaded":true,"procs":1,"slowdown":1,"sandbox":"","close_fds":fal= se} > > > pipe(&(0x7f0000000240)=3D{0xffffffffffffffff, 0xfffffff= fffffffff}) > > > pipe2(&(0x7f00000001c0)=3D{0xffffffffffffffff, 0xfffffffffffff= fff}, 0x80) > > > splice(r0, 0x0, r2, 0x0, 0x1ff, 0x0) > > > vmsplice(r1, &(0x7f00000006c0)=3D[{&(0x7f0000000080)=3D"b5", 0x1}], 0= x1, 0x0) > > > > > > That 0x80 is O_NOTIFICATION_PIPE (=3D=3DO_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 th= e > > > 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. > > > > Is this then a bug/feature in iter_file_splice_write() rather than in t= he > > watch queue code, per se? > > I think at least when you call splice() on two normal pipes from > userspace, it'll never go through this codepath for real pipes, > because pipe-to-pipe splicing is special-cased? And sendfile() bails > out in that case because pipes don't have a .splice_read() handler. > > And with notification pipes, we don't take that special path in > splice(), and so we hit the lockdep warning. But I don't know whether > that makes it the fault of notification pipes... > > Maybe it would be enough to just move the "if (pipe->watch_queue)" > check in pipe_write() up above the __pipe_lock(pipe)? [coming back to this thread 1.5 years later...] I've turned that idea into a fix, let's have syzbot try it out before I submit the fix patch: #syz test: https://github.com/thejh/linux.git 56c486e68166