diff options
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 15c2a08a66f1..d6f64783acd1 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -2938,11 +2938,6 @@ static int selinux_revalidate_file_permission(struct file *file, int mask) | |||
2938 | const struct cred *cred = current_cred(); | 2938 | const struct cred *cred = current_cred(); |
2939 | struct inode *inode = file->f_path.dentry->d_inode; | 2939 | struct inode *inode = file->f_path.dentry->d_inode; |
2940 | 2940 | ||
2941 | if (!mask) { | ||
2942 | /* No permission to check. Existence test. */ | ||
2943 | return 0; | ||
2944 | } | ||
2945 | |||
2946 | /* file_mask_to_av won't add FILE__WRITE if MAY_APPEND is set */ | 2941 | /* file_mask_to_av won't add FILE__WRITE if MAY_APPEND is set */ |
2947 | if ((file->f_flags & O_APPEND) && (mask & MAY_WRITE)) | 2942 | if ((file->f_flags & O_APPEND) && (mask & MAY_WRITE)) |
2948 | mask |= MAY_APPEND; | 2943 | mask |= MAY_APPEND; |
@@ -2953,10 +2948,20 @@ static int selinux_revalidate_file_permission(struct file *file, int mask) | |||
2953 | 2948 | ||
2954 | static int selinux_file_permission(struct file *file, int mask) | 2949 | static int selinux_file_permission(struct file *file, int mask) |
2955 | { | 2950 | { |
2951 | struct inode *inode = file->f_path.dentry->d_inode; | ||
2952 | struct file_security_struct *fsec = file->f_security; | ||
2953 | struct inode_security_struct *isec = inode->i_security; | ||
2954 | u32 sid = current_sid(); | ||
2955 | |||
2956 | if (!mask) | 2956 | if (!mask) |
2957 | /* No permission to check. Existence test. */ | 2957 | /* No permission to check. Existence test. */ |
2958 | return 0; | 2958 | return 0; |
2959 | 2959 | ||
2960 | if (sid == fsec->sid && fsec->isid == isec->sid && | ||
2961 | fsec->pseqno == avc_policy_seqno()) | ||
2962 | /* No change since dentry_open check. */ | ||
2963 | return 0; | ||
2964 | |||
2960 | return selinux_revalidate_file_permission(file, mask); | 2965 | return selinux_revalidate_file_permission(file, mask); |
2961 | } | 2966 | } |
2962 | 2967 | ||