summaryrefslogtreecommitdiffstats
path: root/fs/inode.c
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2017-06-21 18:53:06 +0200
committerAl Viro <viro@zeniv.linux.org.uk>2017-06-30 02:08:32 +0200
commitcc658db47d6897a8571fb6227f59d1d18151b0b2 (patch)
tree67d1bd8c5c8f3f7c90a6f24c39832fc0218de07a /fs/inode.c
parentfs: warn in case userspace lied about modprobe return (diff)
downloadlinux-cc658db47d6897a8571fb6227f59d1d18151b0b2.tar.xz
linux-cc658db47d6897a8571fb6227f59d1d18151b0b2.zip
fs: Reorder inode_owner_or_capable() to avoid needless
Checking for capabilities should be the last operation when performing access control tests so that PF_SUPERPRIV is set only when it was required for success (implying that the capability was needed for the operation). Reported-by: Solar Designer <solar@openwall.com> Signed-off-by: Kees Cook <keescook@chromium.org> Acked-by: Serge Hallyn <serge@hallyn.com> Reviewed-by: Andy Lutomirski <luto@kernel.org> Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/inode.c')
-rw-r--r--fs/inode.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/inode.c b/fs/inode.c
index db5914783a71..7092debe90cc 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2023,7 +2023,7 @@ bool inode_owner_or_capable(const struct inode *inode)
return true;
ns = current_user_ns();
- if (ns_capable(ns, CAP_FOWNER) && kuid_has_mapping(ns, inode->i_uid))
+ if (kuid_has_mapping(ns, inode->i_uid) && ns_capable(ns, CAP_FOWNER))
return true;
return false;
}