linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Andreas Grünbacher" <andreas.gruenbacher@gmail.com>
To: Andreas Dilger <adilger@dilger.ca>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Andreas Gruenbacher <agruenba@redhat.com>,
	Linux FS-devel Mailing List <linux-fsdevel@vger.kernel.org>
Subject: Re: posix_acl_permission() and MAY_* flags
Date: Fri, 12 Oct 2018 11:09:38 +0200	[thread overview]
Message-ID: <CAHpGcMKV8MnKNovt4H7ZfjJtQ5AAaD+hC5L65mAWtV5MeKu_kA@mail.gmail.com> (raw)
In-Reply-To: <ADCDD815-9330-4BF2-B3BB-67F7AA223098@dilger.ca>

Am Fr., 12. Okt. 2018 um 02:44 Uhr schrieb Andreas Dilger <adilger@dilger.ca>:
> I was looking at POSIX ACL on-disk and in-memory code and it looks like
> there is a subtle dependency between the on-disk format and what (IMHO)
> would be considered in-memory declarations.
>
> When a POSIX ACL is read from disk, posix_acl_from_mode() copies the file
> mode (S_I[RWX][UGO]) into the e_perm fields of the ACL default entries.
> Similarly, in posix_acl_equiv_mode() and posix_acl_create_masq() it uses
> S_IRWXO to mask the e_perm flags.
>
> However, later on in posix_acl_permission() it directly uses the "want"
> flag contains MAY_{READ,WRITE,EXEC} flags and compares those to e_perm of
> each ACL entry.

As far as I can tell, this practice even goes back to before POSIX
ACLs. For example, if you look at function vfs_permission in
fs/namei.c in a v2.4 tree, you'll find something like this:

    if (((mode & mask & (MAY_READ|MAY_WRITE|MAY_EXEC)) == mask))
        return 0;

Here, mode is inode->i_mode shifted so that the bits that matter are
the lowest three (S_IRWXO) and mask is a combination of MAY_ flags.

> In posix_acl_valid() it compares e_perm with ACL_{READ,WRITE,EXECUTE}.
>
> While the MAY_[RWX] and ACL_[RWX] currently have the same value as
> S_I[RWX]OTH, it isn't very clear that these flags MUST all have the same
> values or POSIX ACLs will break.
>
> This definitely doesn't seem quite right.  Are the ACL_* constants the
> values to be used, with "conversion" in between the flags/modes?  Should
> there be a BUILD_BUG_ON() that trips if those values ever differ?

The ACL_{READ,WRITE,EXECUTE} and MAY_{READ,WRITE,EXEC} values must
definitely have the same values. This wouldn't be true for higher
bits, but POSIX ACLs don't support anything beyond rwx.

Andreas

  reply	other threads:[~2018-10-12 16:41 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1254FD78-8392-4B97-A191-EDA01B719635@whamcloud.com>
2018-10-12  0:43 ` Fwd: posix_acl_permission() and MAY_* flags Andreas Dilger
2018-10-12  9:09   ` Andreas Grünbacher [this message]
2018-10-13  3:56     ` Al Viro
2018-10-13  4:08       ` Andreas Dilger
2018-10-13  4:37         ` Al Viro
2018-10-13  3:40   ` Fwd: " Al Viro

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAHpGcMKV8MnKNovt4H7ZfjJtQ5AAaD+hC5L65mAWtV5MeKu_kA@mail.gmail.com \
    --to=andreas.gruenbacher@gmail.com \
    --cc=adilger@dilger.ca \
    --cc=agruenba@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).