f2fs: avoid selinux denial on CAP_SYS_RESOURCE
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 9 Mar 2018 04:47:33 +0000 (20:47 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Sun, 8 Apr 2018 11:11:41 +0000 (04:11 -0700)
This fixes CAP_SYS_RESOURCE denial of selinux when using resgid, since it
seems selinux reports it at the first place, but mostly we don't need to
check this condition first.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/f2fs.h

index 7bf9d61593a7f6bffe2e7e572739f58d61fad1c1..ca3713633500971ef7634fc02d83854c43fce618 100644 (file)
@@ -1607,13 +1607,13 @@ static inline bool __allow_reserved_blocks(struct f2fs_sb_info *sbi,
                return false;
        if (IS_NOQUOTA(inode))
                return true;
-       if (capable(CAP_SYS_RESOURCE))
-               return true;
        if (uid_eq(sbi->s_resuid, current_fsuid()))
                return true;
        if (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) &&
                                        in_group_p(sbi->s_resgid))
                return true;
+       if (capable(CAP_SYS_RESOURCE))
+               return true;
        return false;
 }