From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65534C433DB for ; Thu, 25 Mar 2021 14:53:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4429961A25 for ; Thu, 25 Mar 2021 14:53:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231229AbhCYOws (ORCPT ); Thu, 25 Mar 2021 10:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55940 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230229AbhCYOwk (ORCPT ); Thu, 25 Mar 2021 10:52:40 -0400 Received: from mail-vs1-xe32.google.com (mail-vs1-xe32.google.com [IPv6:2607:f8b0:4864:20::e32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F17A5C06174A for ; Thu, 25 Mar 2021 07:52:39 -0700 (PDT) Received: by mail-vs1-xe32.google.com with SMTP id i126so1026120vsi.3 for ; Thu, 25 Mar 2021 07:52:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GCLGgJAKjLjI5ddp5Jx+57wqu5xxECcnAuNRZawig58=; b=mx+29ho7ycm8+QllWhmew29rye/m0r1+H3mer3m0RGn23pJdOCvHFW7tk1Fm3/mgSi p0CTehFJAES/LIFMxlsbGfeakvD4Qqdca1yEVEtOY6pMrlC1zFHKpmzBgwtjpZ0I9SGB 2wNZYUBJ5REOohRaEbG0TV4pz3QKjR9Su6LrQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GCLGgJAKjLjI5ddp5Jx+57wqu5xxECcnAuNRZawig58=; b=SuDz8YYts80pwXjVs85jweViBKigtz6WlsHpqnSvU5UeCd/eb7PwXR7abWAMWIuIim Dsfk1ZkAs71m9vAR0BTZVMGBBxDgmx6l2QYnyBuhmCG+7U8IfaFutNWxgPN4m7EvxLDH qUCeFs2poWiXhhKg0+0/DVBpdulgIb07BL2bXcYek7q/5FseSH+ZE0zxMBPad4gQlqGI kq7k8AerWtO6EHl4rUmxXvrgI4OMW+eWJdcAivVgpI+7ujfYaObLI9w4PBiyJsm3LLwY aDZfatILHkq7XmJNwQ8acjwqXAfVyzK5jpUbo+Y92aA9+WnfMUOH8Vsqr5jQJq7c6vjY tfgw== X-Gm-Message-State: AOAM532tW5JbGXnhwlPuP7Jfvo0votha0LzZJ7xwwkN+EOOOZfYGUEHc VyESLUH+L9wvklYXpnh30fvMLea4u56hRdmTC3TL0A== X-Google-Smtp-Source: ABdhPJyMZ7+hzDX13eHsxwbk6uA8EAhPRCptc8WwFFINhCjTxMFXxulI+bsZ5Lz39az8S8z1BdRvm/p9QNhGlC3MkAc= X-Received: by 2002:a67:ffc1:: with SMTP id w1mr5408105vsq.47.1616683959214; Thu, 25 Mar 2021 07:52:39 -0700 (PDT) MIME-Version: 1.0 References: <20210203124112.1182614-1-mszeredi@redhat.com> <20210203124112.1182614-2-mszeredi@redhat.com> In-Reply-To: From: Miklos Szeredi Date: Thu, 25 Mar 2021 15:52:28 +0100 Message-ID: Subject: Re: [PATCH 01/18] vfs: add miscattr ops To: Eric Biggers Cc: Miklos Szeredi , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Al Viro , 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 Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Thanks, Miklos