]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
fs: optimize acl_permission_check()
authorLinus Torvalds <torvalds@linux-foundation.org>
Fri, 1 Nov 2024 12:52:25 +0000 (13:52 +0100)
committerChristian Brauner <brauner@kernel.org>
Fri, 1 Nov 2024 13:12:34 +0000 (14:12 +0100)
commitcb80d9074f2a56c8226657b01f19656584fc3ab5
tree5ca2aa0a02efcfb9e426ef1bd02eddcdcca527ce
parente017671f534dd3f568db9e47b0583e853d2da9b5
fs: optimize acl_permission_check()

generic_permission() turned out to be costlier than expected. The reason
is that acl_permission_check() performs owner checks that involve costly
pointer dereferences.

There's already code that skips expensive group checks if the group and
other permission bits are the same wrt to the mask that is checked. This
logic can be extended to also shortcut permission checking in
acl_permission_check().

If the inode doesn't have POSIX ACLs than ownership doesn't matter. If
there are no missing UGO permissions the permission check can be
shortcut.

Acked-by: Al Viro <viro@zeniv.linux.org.uk>
Link: https://lore.kernel.org/all/CAHk-=wgXEoAOFRkDg+grxs+p1U+QjWXLixRGmYEfd=vG+OBuFw@mail.gmail.com
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/namei.c