[RFC v2 4/4] btrfs: verify symlinks with append/immutable flags

From: Luis R. Rodriguez
Date: Thu May 10 2018 - 19:14:22 EST


The Linux VFS does not allow a way to set append/immuttable
attributes to symlinks, this is just not possible. If this is
detected inform the user as the filesystem must be corrupted.

Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxxxx>
---
fs/btrfs/inode.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index c4bdb597b323..d9c786be408c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -3933,6 +3933,15 @@ static int btrfs_read_locked_inode(struct inode *inode)
inode->i_op = &btrfs_dir_inode_operations;
break;
case S_IFLNK:
+ /* VFS does not allow setting these so must be corruption */
+ if (IS_APPEND(inode) || IS_IMMUTABLE(inode)) {
+ ret = -EUCLEAN;
+ btrfs_crit(fs_info,
+ "corrupt symlink with append/immutable ino=%llu root=%llu\n",
+ btrfs_ino(BTRFS_I(inode)),
+ root->root_key.objectid);
+ goto make_bad;
+ }
inode->i_op = &btrfs_symlink_inode_operations;
inode_nohighmem(inode);
inode->i_mapping->a_ops = &btrfs_symlink_aops;
--
2.17.0