Skip to content

Commit bc6a600

Browse files
Amerigo WangJames Morris
authored andcommitted
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]>
1 parent ece1387 commit bc6a600

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

security/selinux/hooks.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2711,12 +2711,18 @@ static int selinux_inode_permission(struct inode *inode, int mask)
27112711
static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
27122712
{
27132713
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+
}
27142723

2715-
if (iattr->ia_valid & ATTR_FORCE)
2716-
return 0;
2717-
2718-
if (iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
2719-
ATTR_ATIME_SET | ATTR_MTIME_SET))
2724+
if (ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
2725+
ATTR_ATIME_SET | ATTR_MTIME_SET | ATTR_TIMES_SET))
27202726
return dentry_has_perm(cred, NULL, dentry, FILE__SETATTR);
27212727

27222728
return dentry_has_perm(cred, NULL, dentry, FILE__WRITE);

0 commit comments

Comments
 (0)