aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux/hooks.c
diff options
context:
space:
mode:
authorAmerigo Wang <[email protected]>2009-08-21 02:29:02 +0000
committerJames Morris <[email protected]>2009-08-21 04:25:30 +0000
commitbc6a6008e5e3c7a30191a7f19ab19e85b14b1705 (patch)
tree46504659c2303224cb3c8ad13e1d1b580351b41b /security/selinux/hooks.c
parentMerge branch 'master' into next (diff)
downloadkernel-bc6a6008e5e3c7a30191a7f19ab19e85b14b1705.tar.gz
kernel-bc6a6008e5e3c7a30191a7f19ab19e85b14b1705.zip
selinux: adjust rules for ATTR_FORCE
As suggested by OGAWA Hirofumi in thread: http://lkml.org/lkml/2009/8/7/132, we should let selinux_inode_setattr() to match our ATTR_* rules. ATTR_FORCE should not force things like ATTR_SIZE. [[email protected]: tweaks] Signed-off-by: WANG Cong <[email protected]> Signed-off-by: OGAWA Hirofumi <[email protected]> Acked-by: Stephen Smalley <[email protected]> Acked-by: Eric Paris <[email protected]> Cc: Eugene Teo <[email protected]> Cc: Al Viro <[email protected]> Cc: Christoph Hellwig <[email protected]> Acked-by: James Morris <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: James Morris <[email protected]>
Diffstat (limited to 'security/selinux/hooks.c')
-rw-r--r--security/selinux/hooks.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 6d0b1ccb5b99..ac79f9ef2da8 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -2711,12 +2711,18 @@ static int selinux_inode_permission(struct inode *inode, int mask)
static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
{
const struct cred *cred = current_cred();
+ unsigned int ia_valid = iattr->ia_valid;
- if (iattr->ia_valid & ATTR_FORCE)
- return 0;
+ /* ATTR_FORCE is just used for ATTR_KILL_S[UG]ID. */
+ if (ia_valid & ATTR_FORCE) {
+ ia_valid &= ~(ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_MODE |
+ ATTR_FORCE);
+ if (!ia_valid)
+ return 0;
+ }
- if (iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
- ATTR_ATIME_SET | ATTR_MTIME_SET))
+ if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
+ ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_TIMES_SET))
return dentry_has_perm(cred, NULL, dentry, FILE__SETATTR);
return dentry_has_perm(cred, NULL, dentry, FILE__WRITE);