[PATCH 2/2] xfs: kill suid/sgid through the truncate path.
Christoph Hellwig
hch at infradead.org
Fri May 24 05:02:46 CDT 2013
On Fri, May 24, 2013 at 06:58:08PM +1000, Dave Chinner wrote:
> From: Dave Chinner <dchinner at redhat.com>
>
> XFS has failed to kill suid/sgid bits correctly when truncating
> files of non-zero size since commit c4ed4243 ("xfs: split
> xfs_setattr") introduced in the 3.1 kernel. Fix it.
This should get a testcase in xfstests.
> +xfs_setattr_mode(
> + struct inode *inode,
> + struct iattr *iattr)
> +{
> + struct xfs_inode *ip = XFS_I(inode);
> + umode_t mode = iattr->ia_mode;
> +
> + if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID))
> + mode &= ~S_ISGID;
> +
> + ip->i_d.di_mode &= S_IFMT;
> + ip->i_d.di_mode |= mode & ~S_IFMT;
> +
> + inode->i_mode &= S_IFMT;
> + inode->i_mode |= mode & ~S_IFMT;
This function should have assers that the xfs_inode is locked
exclusively and joined to a transaction.
More information about the xfs
mailing list