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] [day] [month] [year] [list]
Date:	Thu, 18 Dec 2014 22:48:20 -0800
From:	Omar Sandoval <osandov@...ndov.com>
To:	Trond Myklebust <trond.myklebust@...marydata.com>,
	linux-nfs@...r.kernel.org, linux-kernel@...r.kernel.org
Cc:	Al Viro <viro@...IV.linux.org.uk>, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] nfs: prevent truncate on active swapfile

On Thu, Dec 18, 2014 at 10:29:18PM -0800, Omar Sandoval wrote:
> Most filesystems prevent truncation of an active swapfile by way of
> inode_newsize_ok, called from inode_change_ok. NFS doesn't call either
> from nfs_setattr, presumably because most of these checks are expected
> to be done server-side. However, the IS_SWAPFILE check can only be done
> client-side, and not doing so is dangerous.
> 
> Signed-off-by: Omar Sandoval <osandov@...ndov.com>
> ---
>  fs/nfs/inode.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 4bffe63..9205513 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -506,10 +506,15 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
>  		attr->ia_valid &= ~ATTR_MODE;
>  
>  	if (attr->ia_valid & ATTR_SIZE) {
> +		loff_t i_size;
> +
>  		BUG_ON(!S_ISREG(inode->i_mode));
>  
> -		if (attr->ia_size == i_size_read(inode))
> +		i_size = i_size_read(inode);
> +		if (attr->ia_size == i_size)
>  			attr->ia_valid &= ~ATTR_SIZE;
> +		else if (attr->ia_size < i_size && IS_SWAPFILE(inode))
> +			return -ETXTBSY;
>  	}
>  
>  	/* Optimization: if the end result is no change, don't RPC */
> -- 
> 2.2.0
> 
Sorry, forgot to mention that this applies to Linus' tree as of today.

-- 
Omar
--
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