diff options
author | Amerigo Wang <amwang@redhat.com> | 2009-08-20 22:29:02 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2009-08-21 00:25:30 -0400 |
commit | bc6a6008e5e3c7a30191a7f19ab19e85b14b1705 (patch) | |
tree | 46504659c2303224cb3c8ad13e1d1b580351b41b /security/selinux | |
parent | ece13879e74313e62109e0755dd3d4f172df89e2 (diff) |
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.
[hirofumi@mail.parknet.co.jp: tweaks]
Signed-off-by: WANG Cong <amwang@redhat.com>
Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Acked-by: Eric Paris <eparis@redhat.com>
Cc: Eugene Teo <eteo@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@lst.de>
Acked-by: James Morris <jmorris@namei.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security/selinux')
-rw-r--r-- | security/selinux/hooks.c | 16 |
1 files changed, 11 insertions, 5 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) | |||
2711 | static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr) | 2711 | static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr) |
2712 | { | 2712 | { |
2713 | const struct cred *cred = current_cred(); | 2713 | const struct cred *cred = current_cred(); |
2714 | unsigned int ia_valid = iattr->ia_valid; | ||
2715 | |||
2716 | /* ATTR_FORCE is just used for ATTR_KILL_S[UG]ID. */ | ||
2717 | if (ia_valid & ATTR_FORCE) { | ||
2718 | ia_valid &= ~(ATTR_KILL_SUID | ATTR_KILL_SGID | ATTR_MODE | | ||
2719 | ATTR_FORCE); | ||
2720 | if (!ia_valid) | ||
2721 | return 0; | ||
2722 | } | ||
2714 | 2723 | ||
2715 | if (iattr->ia_valid & ATTR_FORCE) | 2724 | if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | |
2716 | return 0; | 2725 | ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_TIMES_SET)) |
2717 | |||
2718 | if (iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | | ||
2719 | ATTR_ATIME_SET | ATTR_MTIME_SET)) | ||
2720 | return dentry_has_perm(cred, NULL, dentry, FILE__SETATTR); | 2726 | return dentry_has_perm(cred, NULL, dentry, FILE__SETATTR); |
2721 | 2727 | ||
2722 | return dentry_has_perm(cred, NULL, dentry, FILE__WRITE); | 2728 | return dentry_has_perm(cred, NULL, dentry, FILE__WRITE); |