Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp503210pxf; Thu, 25 Mar 2021 08:22:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqQGMHoS318hJPOPVNY5Qm+eZ8OJa/9xCt9SwsF+kxBgIM9c6FjDTpl8n8saqQ4gmIzn9V X-Received: by 2002:aa7:d0cb:: with SMTP id u11mr9703538edo.163.1616685732179; Thu, 25 Mar 2021 08:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616685732; cv=none; d=google.com; s=arc-20160816; b=0hJ/uZTY1QRiYN77S4xGR3TdeKmncc3HA9mNUeUZkO4hEX1GUJyLO2DXGqQnnD1yLZ VWsQEYpAg5vRXqebRX9PK8LZdx+eOtRk5Y9LZXDH8VvkUco7WQ1MUmkpM9qmr8XNFFJe ajEqsa3cA8MbNiHJZVmy7aFgHFdk90HJh/dbG/aiN6m+PjHMZ+yQlW+61/BU+PSE2hbU cmuYVVYUuzoHaNRjHyuGEtRFcg6trx5vzapzixEPi4+gNG+Q8qvclS0rbRQR/pCglDtP xfFZENGbdNoz8m4kxE+dxR/Enz5jD6sxXXFYdzTakwJIQRCV7XYWqXf9EWv+H+PZeLMQ 2xrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=8jygsq7tD2Tcu0oIckEEFflg4UNv0W095Cf7PshiQzg=; b=OtojYd57zBIAqHECXQxpi13UqnK18anOH73pMUymU3ZF9pqZue5hzJ3JrXqz8v8gHo I/rC2GZt3tnZfdBFx5OJ85zarXp+kak6YhA+9A1KMWQpx6TnVvgQzSDR0/dMPiQA9iKW FDGrUDSQZx0NFzCJK0I9JHQt1IqxGNeG9ytEJwLa2PQpMCdYi9RJ3rK2bWddOeeU1niX rCax5PbcXemoH0JOtoiKNLd0bwRz+rzyGkDNDRXzwzkeb5hMDpK+5w84Pu7t1oc397VP sGN+84G+E9SKziuENGgnR1qZIUPGzzql4M/9IhktLYlWmHWn80o9YbsaqpWXLtnVQMRd AZFA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i20si4360341ejg.680.2021.03.25.08.21.47; Thu, 25 Mar 2021 08:22:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231459AbhCYPUV (ORCPT + 99 others); Thu, 25 Mar 2021 11:20:21 -0400 Received: from zeniv-ca.linux.org.uk ([142.44.231.140]:58720 "EHLO zeniv-ca.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230095AbhCYPUD (ORCPT ); Thu, 25 Mar 2021 11:20:03 -0400 Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94 #2 (Red Hat Linux)) id 1lPRjt-009CM7-Rc; Thu, 25 Mar 2021 15:17:38 +0000 Date: Thu, 25 Mar 2021 15:17:37 +0000 From: Al Viro To: Miklos Szeredi Cc: Eric Biggers , Miklos Szeredi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Andreas Dilger , Andreas Gruenbacher , Christoph Hellwig , "Darrick J . Wong" , Dave Kleikamp , David Sterba , Jaegeuk Kim , Jan Kara , Joel Becker , Matthew Garrett , Mike Marshall , Richard Weinberger , Ryusuke Konishi , Theodore Ts'o , Tyler Hicks Subject: Re: [PATCH 01/18] vfs: add miscattr ops Message-ID: References: <20210203124112.1182614-1-mszeredi@redhat.com> <20210203124112.1182614-2-mszeredi@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 25, 2021 at 03:52:28PM +0100, Miklos Szeredi wrote: > On Tue, Mar 23, 2021 at 1:24 AM Eric Biggers wrote: > > > > +int vfs_miscattr_set(struct dentry *dentry, struct miscattr *ma) > > > +{ > > > + struct inode *inode = d_inode(dentry); > > > + struct miscattr old_ma = {}; > > > + int err; > > > + > > > + if (d_is_special(dentry)) > > > + return -ENOTTY; > > > + > > > + if (!inode->i_op->miscattr_set) > > > + return -ENOIOCTLCMD; > > > + > > > + if (!inode_owner_or_capable(inode)) > > > + return -EPERM; > > > > Shouldn't this be EACCES, not EPERM? > > $ git diff master.. | grep -C1 inode_owner_or_capable | grep > "^-.*\(EPERM\|EACCES\)" | cut -d- -f3 | sort | uniq -c > 12 EACCES; > 4 EPERM; > > So EACCES would win if this was a democracy. However: > > "[EACCES] > Permission denied. An attempt was made to access a file in a way > forbidden by its file access permissions." > > "[EPERM] > Operation not permitted. An attempt was made to perform an operation > limited to processes with appropriate privileges or to the owner of a > file or other resource." > > The EPERM description matches the semantics of > inode_owner_or_capable() exactly. It's a pretty clear choice. Except that existing implementation (e.g. for ext2) gives -EACCES here... OTOH, EPERM matches the behaviour of chown(2), as well as that of *BSD chflags(2), which is the best match to functionality (setting and clearing immutable/append-only/etc.) So I'd probably go with EPERM, and watched for userland breakage; if something *does* rely upon the historical EACCES here, we might have to restore that.