Skip to content

Commit

Permalink
xfs: set inode size after creating symlink
Browse files Browse the repository at this point in the history
commit 8aa921a upstream.

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.
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@starlab.io>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
JeffreyMitchellSL authored and gregkh committed Jun 9, 2022
1 parent d27f000 commit af26bfb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/xfs/xfs_symlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit af26bfb

Please sign in to comment.