Re: [PATCH resend] fs/namei.c: micro-optimize acl_permission_check

From: Al Viro
Date: Sun Jun 07 2020 - 22:05:28 EST


On Sun, Jun 07, 2020 at 12:48:53PM -0700, Linus Torvalds wrote:

> Rasmus, say the word and I'll mark you for authorship on the first one.
>
> Comments? Can you find something else wrong here, or some other fixup to do?
>
> Al, any reaction?

It's correct, but this

> + if (mask & (mode ^ (mode >> 3))) {
> + if (in_group_p(inode->i_gid))
> + mode >>= 3;
> + }
> +
> + /* Bits in 'mode' clear that we require? */
> + return (mask & ~mode) ? -EACCES : 0;

might be easier to follow if we had, from the very beginning done
unsigned int deny = ~inode->i_mode;
and turned that into

// for group the bits 3..5 apply, for others - 0..2
// we only care which to use when they do not
// agree anyway.
if (mask & (deny ^ (deny >> 3))) // mask & deny != mask & (deny >> 3)
if (in_...
deny >>= 3;
return mask & deny ? -EACCES : 0;

Hell knows...