Skip to content

Commit

Permalink
vfs: clean up posix_acl_permission() logic aroudn MAY_NOT_BLOCK
Browse files Browse the repository at this point in the history
posix_acl_permission() does not care about MAY_NOT_BLOCK, and in fact
the permission logic internally must not check that bit (it's only for
upper layers to decide whether they can block to do IO to look up the
acl information or not).

But the way the code was written, it _looked_ like it cared, since the
function explicitly did not mask that bit off.

But it has exactly two callers: one for when that bit is set, which
first clears the bit before calling posix_acl_permission(), and the
other call site when that bit was clear.

So stop the silly games "saving" the MAY_NOT_BLOCK bit that must not be
used for the actual permission test, and that currently is pointlessly
cleared by the callers when the function itself should just not care.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Linus Torvalds committed Jun 8, 2020
1 parent 5fc475b commit 63d72b9
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion fs/namei.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ static int check_acl(struct inode *inode, int mask)
/* no ->get_acl() calls in RCU mode... */
if (is_uncached_acl(acl))
return -ECHILD;
return posix_acl_permission(inode, acl, mask & ~MAY_NOT_BLOCK);
return posix_acl_permission(inode, acl, mask);
}

acl = get_acl(inode, ACL_TYPE_ACCESS);
Expand Down
2 changes: 1 addition & 1 deletion fs/posix_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ posix_acl_permission(struct inode *inode, const struct posix_acl *acl, int want)
const struct posix_acl_entry *pa, *pe, *mask_obj;
int found = 0;

want &= MAY_READ | MAY_WRITE | MAY_EXEC | MAY_NOT_BLOCK;
want &= MAY_READ | MAY_WRITE | MAY_EXEC;

FOREACH_ACL_ENTRY(pa, acl, pe) {
switch(pa->e_tag) {
Expand Down

0 comments on commit 63d72b9

Please sign in to comment.