lkml.org 
[lkml]   [2009]   [Aug]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [Patch 1/2] selinux: ajust rules for ATTR_FORCE
From
Date
On Mon, 2009-08-17 at 03:07 -0400, Amerigo Wang wrote:
> 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.
>
> Cc: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
> Cc: Stephen Smalley <sds@tycho.nsa.gov>
> Cc: Eric Paris <eparis@redhat.com>
> Signed-off-by: WANG Cong <amwang@redhat.com>
>
> ---
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 1e8cfc4..3ee3365 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -2708,18 +2708,24 @@ static int selinux_inode_permission(struct inode *inode, int mask)
> file_mask_to_av(inode->i_mode, mask), NULL);
> }
>
> +#define SELINUX_FORCED_MASK (ATTR_MODE | ATTR_UID | ATTR_GID | \
> + ATTR_ATIME_SET | ATTR_MTIME_SET)
> static int selinux_inode_setattr(struct dentry *dentry, struct iattr *iattr)
> {
> const struct cred *cred = current_cred();
> + unsigned int ia_valid = iattr->ia_valid;
> + int err = 0;
>
> - if (iattr->ia_valid & ATTR_FORCE)
> - return 0;
> -
> - if (iattr->ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID |
> - ATTR_ATIME_SET | ATTR_MTIME_SET))
> - return dentry_has_perm(cred, NULL, dentry, FILE__SETATTR);
> -
> - return dentry_has_perm(cred, NULL, dentry, FILE__WRITE);
> + if ((ia_valid & ATTR_FORCE) && (ia_valid & SELINUX_FORCED_MASK)) {
> + err = dentry_has_perm(cred, NULL, dentry, FILE__SETATTR);
> + if (err)
> + return err;
> + ia_valid &= ~SELINUX_FORCED_MASK;
> + ia_valid &= ~ATTR_FORCE;
> + }

This will only apply the setattr check if ATTR_FORCE was specified,
which is not the current behavior nor what we want.

NAK.

> + if (ia_valid)
> + err = dentry_has_perm(cred, NULL, dentry, FILE__WRITE);
> + return err;
> }
>
> static int selinux_inode_getattr(struct vfsmount *mnt, struct dentry *dentry)
--
Stephen Smalley
National Security Agency



\
 
 \ /
  Last update: 2009-08-17 14:15    [W:0.938 / U:0.600 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site