From cc658db47d6897a8571fb6227f59d1d18151b0b2 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Wed, 21 Jun 2017 09:53:06 -0700 Subject: 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 Signed-off-by: Kees Cook Acked-by: Serge Hallyn Reviewed-by: Andy Lutomirski Signed-off-by: Al Viro --- fs/namei.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'fs/namei.c') diff --git a/fs/namei.c b/fs/namei.c index 6571a5f5112e..efe53a5d0737 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1008,7 +1008,7 @@ static int may_linkat(struct path *link) /* Source inode owner (or CAP_FOWNER) can hardlink all they like, * otherwise, it must be a safe source. */ - if (inode_owner_or_capable(inode) || safe_hardlink_source(inode)) + if (safe_hardlink_source(inode) || inode_owner_or_capable(inode)) return 0; audit_log_link_denied("linkat", link); -- cgit v1.2.1