From: TARUISI Hiroaki Date: Thu, 12 Nov 2009 07:14:26 +0000 (+0000) Subject: Btrfs: deny sys_link across subvolumes. X-Git-Tag: firefly_0821_release~10186^2~1175 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8db426bbfeef206a8cd6002d6790f936f3071f0c;p=firefly-linux-kernel-4.4.55.git Btrfs: deny sys_link across subvolumes. commit 4a8be425a8fb8fbb5d881eb55fa6634c3463b9c9 upstream. I rebased Christian Parpart's patch to deny hard link across subvolumes. Original patch modifies also btrfs_rename, but I excluded it because we can move across subvolumes now and it make no problem. ----------------- Hard link across subvolumes should not allowed in Btrfs. btrfs_link checks root of 'to' directory is same as root of 'from' file. If not same, btrfs_link returns -EPERM. Signed-off-by: TARUISI Hiroaki Signed-off-by: Chris Mason Acked-by: Jeff Mahoney Signed-off-by: Greg Kroah-Hartman --- diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 168e8c040aab..da76cad92ecf 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -4462,6 +4462,10 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir, if (inode->i_nlink == 0) return -ENOENT; + /* do not allow sys_link's with other subvols of the same device */ + if (root->objectid != BTRFS_I(inode)->root->objectid) + return -EPERM; + /* * 1 item for inode ref * 2 items for dir items