aboutsummaryrefslogtreecommitdiffstats
path: root/security
diff options
context:
space:
mode:
authorAl Viro <viro@zeniv.linux.org.uk>2011-06-20 19:38:15 -0400
committerAl Viro <viro@zeniv.linux.org.uk>2011-07-20 01:43:26 -0400
commite74f71eb78a4a8b9eaf1bc65f20f761648e85f76 (patch)
tree7bc7fc1344f5ed6e3ce8132b36125ef5cec6407c /security
parent10556cb21a0d0b24d95f00ea6df16f599a3345b2 (diff)
->permission() sanitizing: don't pass flags to ->inode_permission()
pass that via mask instead. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'security')
-rw-r--r--security/capability.c2
-rw-r--r--security/security.c7
-rw-r--r--security/selinux/hooks.c5
-rw-r--r--security/smack/smack_lsm.c5
4 files changed, 12 insertions, 7 deletions
diff --git a/security/capability.c b/security/capability.c
index bbb51156261b..2984ea4f776f 100644
--- a/security/capability.c
+++ b/security/capability.c
@@ -181,7 +181,7 @@ static int cap_inode_follow_link(struct dentry *dentry,
181 return 0; 181 return 0;
182} 182}
183 183
184static int cap_inode_permission(struct inode *inode, int mask, unsigned flags) 184static int cap_inode_permission(struct inode *inode, int mask)
185{ 185{
186 return 0; 186 return 0;
187} 187}
diff --git a/security/security.c b/security/security.c
index 4ba6d4cc061f..db3b750da353 100644
--- a/security/security.c
+++ b/security/security.c
@@ -518,14 +518,17 @@ int security_inode_permission(struct inode *inode, int mask)
518{ 518{
519 if (unlikely(IS_PRIVATE(inode))) 519 if (unlikely(IS_PRIVATE(inode)))
520 return 0; 520 return 0;
521 return security_ops->inode_permission(inode, mask, 0); 521 return security_ops->inode_permission(inode, mask);
522} 522}
523 523
524int security_inode_exec_permission(struct inode *inode, unsigned int flags) 524int security_inode_exec_permission(struct inode *inode, unsigned int flags)
525{ 525{
526 int mask = MAY_EXEC;
526 if (unlikely(IS_PRIVATE(inode))) 527 if (unlikely(IS_PRIVATE(inode)))
527 return 0; 528 return 0;
528 return security_ops->inode_permission(inode, MAY_EXEC, flags); 529 if (flags)
530 mask |= MAY_NOT_BLOCK;
531 return security_ops->inode_permission(inode, mask);
529} 532}
530 533
531int security_inode_setattr(struct dentry *dentry, struct iattr *attr) 534int security_inode_setattr(struct dentry *dentry, struct iattr *attr)
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 20219ef5439a..47a059fff344 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2659,12 +2659,13 @@ static int selinux_inode_follow_link(struct dentry *dentry, struct nameidata *na
2659 return dentry_has_perm(cred, dentry, FILE__READ); 2659 return dentry_has_perm(cred, dentry, FILE__READ);
2660} 2660}
2661 2661
2662static int selinux_inode_permission(struct inode *inode, int mask, unsigned flags) 2662static int selinux_inode_permission(struct inode *inode, int mask)
2663{ 2663{
2664 const struct cred *cred = current_cred(); 2664 const struct cred *cred = current_cred();
2665 struct common_audit_data ad; 2665 struct common_audit_data ad;
2666 u32 perms; 2666 u32 perms;
2667 bool from_access; 2667 bool from_access;
2668 unsigned __flags = mask & MAY_NOT_BLOCK ? IPERM_FLAG_RCU : 0;
2668 2669
2669 from_access = mask & MAY_ACCESS; 2670 from_access = mask & MAY_ACCESS;
2670 mask &= (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND); 2671 mask &= (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND);
@@ -2681,7 +2682,7 @@ static int selinux_inode_permission(struct inode *inode, int mask, unsigned flag
2681 2682
2682 perms = file_mask_to_av(inode->i_mode, mask); 2683 perms = file_mask_to_av(inode->i_mode, mask);
2683 2684
2684 return inode_has_perm(cred, inode, perms, &ad, flags); 2685 return inode_has_perm(cred, inode, perms, &ad, __flags);
2685} 2686}
2686 2687
2687static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr) 2688static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 9831a39c11f6..f375eb2e1957 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -689,9 +689,10 @@ static int smack_inode_rename(struct inode *old_inode,
689 * 689 *
690 * Returns 0 if access is permitted, -EACCES otherwise 690 * Returns 0 if access is permitted, -EACCES otherwise
691 */ 691 */
692static int smack_inode_permission(struct inode *inode, int mask, unsigned flags) 692static int smack_inode_permission(struct inode *inode, int mask)
693{ 693{
694 struct smk_audit_info ad; 694 struct smk_audit_info ad;
695 int no_block = mask & MAY_NOT_BLOCK;
695 696
696 mask &= (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND); 697 mask &= (MAY_READ|MAY_WRITE|MAY_EXEC|MAY_APPEND);
697 /* 698 /*
@@ -701,7 +702,7 @@ static int smack_inode_permission(struct inode *inode, int mask, unsigned flags)
701 return 0; 702 return 0;
702 703
703 /* May be droppable after audit */ 704 /* May be droppable after audit */
704 if (flags & IPERM_FLAG_RCU) 705 if (no_block)
705 return -ECHILD; 706 return -ECHILD;
706 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_INODE); 707 smk_ad_init(&ad, __func__, LSM_AUDIT_DATA_INODE);
707 smk_ad_setfield_u_fs_inode(&ad, inode); 708 smk_ad_setfield_u_fs_inode(&ad, inode);