diff options
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r-- | security/selinux/hooks.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c index 0c98846f188d..650947a72a2b 100644 --- a/security/selinux/hooks.c +++ b/security/selinux/hooks.c | |||
@@ -2644,16 +2644,26 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *na | |||
2644 | static int selinux_inode_permission(struct inode *inode, int mask) | 2644 | static int selinux_inode_permission(struct inode *inode, int mask) |
2645 | { | 2645 | { |
2646 | const struct cred *cred = current_cred(); | 2646 | const struct cred *cred = current_cred(); |
2647 | struct common_audit_data ad; | ||
2648 | u32 perms; | ||
2649 | bool from_access; | ||
2647 | 2650 | ||
2651 | from_access = mask & MAY_ACCESS; | ||
2648 | mask &= (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND); | 2652 | mask &= (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND); |
2649 | 2653 | ||
2650 | if (!mask) { | 2654 | /* No permission to check. Existence test. */ |
2651 | /* No permission to check. Existence test. */ | 2655 | if (!mask) |
2652 | return 0; | 2656 | return 0; |
2653 | } | ||
2654 | 2657 | ||
2655 | return inode_has_perm(cred, inode, | 2658 | COMMON_AUDIT_DATA_INIT(&ad, FS); |
2656 | file_mask_to_av(inode->i_mode, mask), NULL); | 2659 | ad.u.fs.inode = inode; |
2660 | |||
2661 | if (from_access) | ||
2662 | ad.selinux_audit_data.auditdeny |= FILE__AUDIT_ACCESS; | ||
2663 | |||
2664 | perms = file_mask_to_av(inode->i_mode, mask); | ||
2665 | |||
2666 | return inode_has_perm(cred, inode, perms, &ad); | ||
2657 | } | 2667 | } |
2658 | 2668 | ||
2659 | static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr) | 2669 | static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr) |