Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4873412rdb; Tue, 12 Dec 2023 11:38:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IFvHqkS8jNfEUbVztTNB/SM2DAFrYOkogKmPNm5NYetRVFOskwrCQnEEzv3ReB0gGiXEv6g X-Received: by 2002:a17:90a:de82:b0:286:f3d8:de2a with SMTP id n2-20020a17090ade8200b00286f3d8de2amr8943709pjv.45.1702409900151; Tue, 12 Dec 2023 11:38:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702409900; cv=none; d=google.com; s=arc-20160816; b=vJOd39RBw6rh16Oj2Rr1Np/CTE5lCqfpBmE6hW/HKadLCf/riVyEN6FWfJD8N0B5tu 8Y2fTltqrABJVqNXIZ/o5V3MdxcGoDX0+GCpnCdYnj11CgcB+PPGlj9XRCMe1WqknC3e GE41H5BW4K1JQqNOx68iI3x4kzCJa9pjLxtn6eSHo0fd2AxnkQA4c834q99Hr/0iqdKv aJzxIXqGcg4BcAODHBE6Z1yxdFCp52EM/NvR7gK99AdDlYkDmxBayJaO/XX4jmeJyf16 ShSxEL/WiefITR1eA9KAk3hQ326IzcReshlBQUdwlf0V6sef3nESBm3f13Tkt8PNRR/A UxqA== 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=7IuPeLZWXHE618u58SYZuwlY/nbyijM369pAi7qe4tc=; fh=vYsHgl/sSBoKyLcXXmxWShEmPgl6003o6WOwQWqLdf4=; b=k2JaPyhmCxSyZVQu/hmj3e4EVWjgSZhRD3xtRyEgZWjegSvPU+HwlW7cwTcYI6rXnc gbc86ZT4CxkJMo9zHtksKjpRaWwh5/MNes94WQ3rckTARh3d5tRAkeKYi7MG07iafpZn TM8HdJ5UhkeTc4cocRMlqCYpAoqr2Cc3vJS08Z4UjDY2c0/4VzdA54wdcVDEJUWzFeCl qELxwrFbZ3I54iQchviirLvCs3ZsZb2us7HpHq44/NGAoFEUkp+E3mCaL0Az2sgcUIbC /nuQW4D5HArgZ6Zv14kEg+uGVDDJL3iXQTiLJ3N7K5XUhLMsG9YzXHSIN2GoAQk/T6LA g/AQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TErN9J6w; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id u19-20020a17090ae01300b002864c15489dsi8372598pjy.173.2023.12.12.11.38.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 11:38:20 -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=@redhat.com header.s=mimecast20190719 header.b=TErN9J6w; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id CE7938021592; Tue, 12 Dec 2023 11:38:15 -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 S1377123AbjLLTiD (ORCPT + 99 others); Tue, 12 Dec 2023 14:38:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbjLLTiC (ORCPT ); Tue, 12 Dec 2023 14:38:02 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC856E3 for ; Tue, 12 Dec 2023 11:38:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702409887; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7IuPeLZWXHE618u58SYZuwlY/nbyijM369pAi7qe4tc=; b=TErN9J6wBBWeXWGVnSvnlWF8MwY6G5r9LWtymLiiwq+YlfWC4IyvdkXRacl0soTLCJbguW e1u6DcAqeNGDe0T/n9+60dNcf1xNplzNLtdwU2KC+ftHQjTjHDU4BCS5kaNWnBJQxG5fk/ tS6juAT+d1GsvKPH6Bpt6F51h9R2qv0= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-353-4hvy0escO82QLaECBEMHsQ-1; Tue, 12 Dec 2023 14:38:06 -0500 X-MC-Unique: 4hvy0escO82QLaECBEMHsQ-1 Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-5c1b986082dso3797853a12.0 for ; Tue, 12 Dec 2023 11:38:06 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702409885; x=1703014685; 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=7IuPeLZWXHE618u58SYZuwlY/nbyijM369pAi7qe4tc=; b=ufMU2edca9qe4kDT6ToIpTyP3dZtpr0ygk8pOk7RJfpcRJYrdJqZen3JEP9aybGbbB Y6p+BisxNUtZQKvIBzBgvikc7M1E17IOy6jCWp/1zSJd+dUf/n9pgDCj+SHCdpj06afL vBRsmuU7vmoCv4/WUHInNFOYi9q5rkbcgjuipgUVTSFmkCaL3GbctuYt6PGKu7fQbUGs VmiOOl1GOGCJx7C1CoQN0Vcalk0mMjWQrLwqgUGF1QPK00mIMrPUhBuqiVims6mKez+5 QlDbDTA16rQoFiEcvsh6LI7DB9RXTmliALXr70aZV3qres8phbBydFBCDc6mGIYoknYa jHlw== X-Gm-Message-State: AOJu0YyP27UJ0PuvFG8BNNmOo29+nf8b2I9Y5FdEWjfRKyXXOFRFzWCj 3Zi9iJT1TXa3md1wq+reB2UvW51uo8X+85ciKiglT6zNMRG2136jgPebOhwdMCmJ2f/oqedzdIL nWJ+OM4EuSQ3/XG4WJk2PRBRRGW6eK04L76/f49KW X-Received: by 2002:a05:6a20:8e14:b0:190:23b2:cf1a with SMTP id y20-20020a056a208e1400b0019023b2cf1amr8374156pzj.22.1702409885415; Tue, 12 Dec 2023 11:38:05 -0800 (PST) X-Received: by 2002:a05:6a20:8e14:b0:190:23b2:cf1a with SMTP id y20-20020a056a208e1400b0019023b2cf1amr8374144pzj.22.1702409885088; Tue, 12 Dec 2023 11:38:05 -0800 (PST) MIME-Version: 1.0 References: <20231109190844.2044940-1-agruenba@redhat.com> <20231109220018.GI1957730@ZenIV> <20231109222254.GK1957730@ZenIV> In-Reply-To: <20231109222254.GK1957730@ZenIV> From: Abhi Das Date: Tue, 12 Dec 2023 13:37:54 -0600 Message-ID: Subject: Re: [PATCH] fs: RESOLVE_CACHED final path component fix To: Al Viro Cc: =?UTF-8?Q?Andreas_Gr=C3=BCnbacher?= , Andreas Gruenbacher , Jens Axboe , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Eric Sandeen Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Tue, 12 Dec 2023 11:38:16 -0800 (PST) Hi Al, Did you get a chance to look into the RCU pathwalk stuff a bit more? Any ideas on how to allow may_open() to indicate to inode_permission() that it's part of a RESOLVE_CACHED lookup? Cheers! --Abhi On Thu, Nov 9, 2023 at 4:23=E2=80=AFPM Al Viro wr= ote: > > On Thu, Nov 09, 2023 at 11:12:32PM +0100, Andreas Gr=C3=BCnbacher wrote: > > Am Do., 9. Nov. 2023 um 23:00 Uhr schrieb Al Viro : > > > On Thu, Nov 09, 2023 at 08:08:44PM +0100, Andreas Gruenbacher wrote: > > > > Jens, > > > > > > > > since your commit 99668f618062, applications can request cached loo= kups > > > > with the RESOLVE_CACHED openat2() flag. When adding support for th= at in > > > > gfs2, we found that this causes the ->permission inode operation to= be > > > > called with the MAY_NOT_BLOCK flag set for directories along the pa= th, > > > > which is good, but the ->permission check on the final path compone= nt is > > > > missing that flag. The filesystem will then sleep when it needs to= read > > > > in the ACL, for example. > > > > > > > > This doesn't look like the intended RESOLVE_CACHED behavior. > > > > > > > > The file permission checks in path_openat() happen as follows: > > > > > > > > (1) link_path_walk() -> may_lookup() -> inode_permission() is calle= d for > > > > each but the final path component. If the LOOKUP_RCU nameidata flag= is > > > > set, may_lookup() passes the MAY_NOT_BLOCK flag on to > > > > inode_permission(), which passes it on to the permission inode > > > > operation. > > > > > > > > (2) do_open() -> may_open() -> inode_permission() is called for the > > > > final path component. The MAY_* flags passed to inode_permission() = are > > > > computed by build_open_flags(), outside of do_open(), and passed do= wn > > > > from there. The MAY_NOT_BLOCK flag doesn't get set. > > > > > > > > I think we can fix this in build_open_flags(), by setting the > > > > MAY_NOT_BLOCK flag when a RESOLVE_CACHED lookup is requested, right > > > > where RESOLVE_CACHED is mapped to LOOKUP_CACHED as well. > > > > > > No. This will expose ->permission() instances to previously impossib= le > > > cases of MAY_NOT_BLOCK lookups, and we already have enough trouble > > > in that area. > > > > True, lockdep wouldn't be happy. > > > > > See RCU pathwalk patches I posted last cycle; > > > > Do you have a pointer? Thanks. > > Thread starting with Message-ID: <20231002022815.GQ800259@ZenIV> > I don't remember if I posted the audit notes into it; I'll get around > to resurrecting that stuff this weekend, when the mainline settles down > enough to bother with that. >