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]
Message-ID: <20210121184137.GB1282159@magnolia>
Date:   Thu, 21 Jan 2021 10:41:37 -0800
From:   "Darrick J. Wong" <djwong@...nel.org>
To:     Jeffrey Mitchell <jeffrey.mitchell@...rlab.io>
Cc:     linux-xfs@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] xfs: set inode size after creating symlink

On Thu, Jan 21, 2021 at 09:19:12AM -0600, Jeffrey Mitchell wrote:
> When XFS creates a new symlink, it writes its size to disk but not to the
> VFS inode. This causes i_size_read() to return 0 for that symlink until
> it is re-read from disk, for example when the system is rebooted.
> 
> I found this inconsistency while protecting directories with eCryptFS.

Heh.  No doubt caused by the fact that we only call i_size_write for
regular files, ecryptfs copies i_size_read() of the lower dentry into
the ecryptfs inode, and ecryptfs_getattr_link and doesn't call ->getattr
on the lower inode.

Do directories have the same problem?  I'm guessing no because every
other file type calls vfs_getattr on the lower dentry, which should link
us to xfs_vn_getattr.

Reviewed-by: Darrick J. Wong <djwong@...nel.org>

--D


> The command "stat path/to/symlink/in/ecryptfs" will report "Size: 0" if
> the symlink was created after the last reboot on an XFS root.
> 
> Call i_size_write() in xfs_symlink()
> 
> Signed-off-by: Jeffrey Mitchell <jeffrey.mitchell@...rlab.io>
> ---
>  fs/xfs/xfs_symlink.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 1f43fd7f3209..c835827ae389 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -300,6 +300,7 @@ xfs_symlink(
>  		}
>  		ASSERT(pathlen == 0);
>  	}
> +	i_size_write(VFS_I(ip), ip->i_d.di_size);
>  
>  	/*
>  	 * Create the directory entry for the symlink.
> -- 
> 2.25.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ