Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp158381rwb; Thu, 27 Jul 2023 10:43:38 -0700 (PDT) X-Google-Smtp-Source: APBJJlH38ygRO8pMCcXygZ9TfRnnS/MzalLtC2aLpe9MvZqctDpL4ffYLqAygYw7m8KhD1TIVK6k X-Received: by 2002:a05:6a00:1ad3:b0:677:c5bf:dcc7 with SMTP id f19-20020a056a001ad300b00677c5bfdcc7mr7031719pfv.17.1690479817504; Thu, 27 Jul 2023 10:43:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690479817; cv=none; d=google.com; s=arc-20160816; b=TkF5YBUgNHd5F8yYckf/+EFpnhd44pb/n4a82Hya0eYUTyFk5ZuXTn3swvuEf1KgoT KDIv5EXxnUDbFs2tQS2J4xOyzQlZiG9ItO23h5exxw7gbLmfYtAe62UJbP9N6g9U4MAU v7JYmhhCSaM6CgTd/PXORT0ia4K8CtF1dHH9GRPgt4wmcLQuBbXBENGiedd2xg9Z33dW b7zjbg8YkZ+osil54doctuN5ySykO3uIGFEXxFypG29QanI80lFTqV9nPMdGxS33gzL7 mdFlmd1i/C1y8qMnI1vUWisSXpqdAsH2Y5K/7rql9Amct5p7Q27DRXUAhINH7VYoHpu8 xBmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=LL2uIHyyOv8vYvkBQ08NxWHfyeZ6ioMBr2e3//XyjR8=; fh=QQARtMhMUktG+nrfH3KVJ1WwZaTSoh/EOB38YlCGQqA=; b=fOjoUfKvWJIkwJK1zyB80jzFUTXWNGUEnJmqsgnrdyO8zMb0YvO+JsfW09BK5GvZME Ikt/0d4XEbmZBuEPZGIO9N0eggurwg+rR9mc4au+N7b0Idxcguub46XV88q8meWfXBUM jjV9MJ3b0uhHdxOyUtmt7MNhahGZukXnL4GGP4cZrO08N/ozi36D6Q5VqGqIsch28qaG dv6ZeYvVVY7Cct3bgtvcalJig6mZbIS6A5E6pvWzAo+yp8sCw2fukSELeSlDiG5eNVus VlpHa06QjEsynRXKR5p7noN8iCiDdji+/Xv+/iSfsJbrdh98F14Q/B2IJLjTW55WQt6B +ylA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VxumH8hG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id be7-20020a056a001f0700b00687080bf7a0si340316pfb.369.2023.07.27.10.43.24; Thu, 27 Jul 2023 10:43:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=VxumH8hG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230140AbjG0Rgl (ORCPT + 99 others); Thu, 27 Jul 2023 13:36:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbjG0Rgi (ORCPT ); Thu, 27 Jul 2023 13:36:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 579EF2D67; Thu, 27 Jul 2023 10:36:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id AB42B61EFB; Thu, 27 Jul 2023 17:36:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AD2AC433C8; Thu, 27 Jul 2023 17:36:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690479396; bh=iU7zvXpvxPSg5KiGe2n535PFFdPoC8EIhqciU1h+3Zw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=VxumH8hGN053L+FyKWAl7yNCuep6zB52SgRtI5W/3VmZXm+mmZ4jBeoyIQx8UEPBz KB2g3ckpL1rFkA8SxtOo/2sVYVEfDaKNkKBz1lQ8P2ADzxBiSuYz1s4+mgNIaH8PHC mgTZjyPGv647aIhCLp9wnBJ2zOHZU59iFOFLNAEflHY4ZPUF7p4ROHHXQAz2E75cTe Vin+UGvlA56e4nxESt9X2PQkCsoXkmtj+oV/UF3bLR5Ny1I9LiKjhW+1r+2WJ/O6Yd TgUSACO81o4AuGEsdvCy68dJhSXgXujDC+IFg4xwGOBHFACldMWcZVQg7TP9JlZNoG 348a+hccYCeEA== Date: Thu, 27 Jul 2023 19:36:21 +0200 From: Christian Brauner To: "dalias@libc.org" Cc: Andreas Schwab , David Laight , 'Aleksa Sarai' , Alexey Gladkov , LKML , Arnd Bergmann , "linux-api@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "viro@zeniv.linux.org.uk" , "James.Bottomley@hansenpartnership.com" , "acme@kernel.org" , "alexander.shishkin@linux.intel.com" , "axboe@kernel.dk" , "benh@kernel.crashing.org" , "borntraeger@de.ibm.com" , "bp@alien8.de" , "catalin.marinas@arm.com" , "christian@brauner.io" , "davem@davemloft.net" , "deepa.kernel@gmail.com" , "deller@gmx.de" , "dhowells@redhat.com" , "fenghua.yu@intel.com" , "fweimer@redhat.com" , "geert@linux-m68k.org" , "glebfm@altlinux.org" , "gor@linux.ibm.com" , "hare@suse.com" , "hpa@zytor.com" , "ink@jurassic.park.msu.ru" , "jhogan@kernel.org" , "kim.phillips@arm.com" , "ldv@altlinux.org" , "linux-alpha@vger.kernel.org" , "linux-arch@vger.kernel.org" , "linux-ia64@vger.kernel.org" , "linux-m68k@lists.linux-m68k.org" , "linux-mips@vger.kernel.org" , "linux-parisc@vger.kernel.org" , "linux-s390@vger.kernel.org" , "linux-sh@vger.kernel.org" , "linux@armlinux.org.uk" , "linuxppc-dev@lists.ozlabs.org" , "luto@kernel.org" , "mattst88@gmail.com" , "mingo@redhat.com" , "monstr@monstr.eu" , "mpe@ellerman.id.au" , "namhyung@kernel.org" , "paulus@samba.org" , "peterz@infradead.org" , "ralf@linux-mips.org" , "sparclinux@vger.kernel.org" , "stefan@agner.ch" , "tglx@linutronix.de" , "tony.luck@intel.com" , "tycho@tycho.ws" , "will@kernel.org" , "x86@kernel.org" , "ysato@users.sourceforge.jp" , Palmer Dabbelt Subject: Re: [PATCH v4 2/5] fs: Add fchmodat2() Message-ID: <20230727-boxte-wohnviertel-74b8541d27ec@brauner> References: <87ila5jp2y.fsf@igel.home> <20230727-zerrt-leitmotiv-9e8b60abf690@brauner> <20230727171336.GC20050@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230727171336.GC20050@brightrain.aerifal.cx> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Thu, Jul 27, 2023 at 01:13:37PM -0400, dalias@libc.org wrote: > On Thu, Jul 27, 2023 at 07:02:53PM +0200, Christian Brauner wrote: > > On Thu, Jul 27, 2023 at 06:28:53PM +0200, Andreas Schwab wrote: > > > On Jul 27 2023, David Laight wrote: > > > > > > > From: Aleksa Sarai > > > >> Sent: 25 July 2023 17:36 > > > > ... > > > >> We almost certainly want to support AT_EMPTY_PATH at the same time. > > > >> Otherwise userspace will still need to go through /proc when trying to > > > >> chmod a file handle they have. > > > > > > > > That can't be allowed. > > > > > > IIUC, fchmodat2(fd, "", m, AT_EMPTY_PATH) is equivalent to fchmod(fd, > > > m). With that, new architectures only need to implement the fchmodat2 > > > syscall to cover all chmod variants. > > > > There's a difference though as fchmod() doesn't work with O_PATH file > > descriptors while AT_EMPTY_PATH does. Similar to how fchown() doesn't > > work with O_PATH file descriptors. > > > > However, we do allow AT_EMPTY_PATH with fchownat() so there's no reason > > to not allow it for fchmodat2(). > > > > But it's a bit of a shame that O_PATH looks less and less like O_PATH. > > It came from can-do-barely-anything to can-do-quite-a-lot-of-things over > > the years. > > > > In any case, AT_EMPTY_PATH for fchmodat2() can be an additional patch on > > top. > > From a standpoint of implementing O_SEARCH/O_EXEC using it, I don't > see any reason fchown/fchmod should not work on O_PATH file > descriptors. And indeed when you have procfs available to emulate them > via procfs, it already does. So I don't see this as unwanted I'm really not talking about the fact that proc is a giant loophole for basically everyhing related to O_PATH and reopening fds. I'm saying that both fchmod() and fchown() don't work on O_PATH fds. They explicitly reject them. AT_EMPTY_PATH and therefore O_PATH for fchmodat2() is fine given that we do it for fchownat() already.