lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 17 Aug 2009 08:15:13 -0400
From:	Stephen Smalley <sds@...ho.nsa.gov>
To:	Amerigo Wang <amwang@...hat.com>
Cc:	linux-kernel@...r.kernel.org, esandeen@...hat.com, eteo@...hat.com,
	eparis@...hat.com, linux-fsdevel@...r.kernel.org,
	akpm@...ux-foundation.org, hirofumi@...l.parknet.co.jp,
	viro@...iv.linux.org.uk
Subject: Re: [Patch 1/2] selinux: ajust rules for ATTR_FORCE

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@...l.parknet.co.jp>
> Cc: Stephen Smalley <sds@...ho.nsa.gov>
> Cc: Eric Paris <eparis@...hat.com>
> Signed-off-by: WANG Cong <amwang@...hat.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

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ