All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] deny sys_{rename,link} across subvolumes of same disk
@ 2008-10-09  1:40 Christian Parpart
  2008-10-09  5:55 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Parpart @ 2008-10-09  1:40 UTC (permalink / raw)
  To: linux-btrfs

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

This patch denies renames and linking of inodes across subvolumes, as it 
causes disk format corruption.

I guess a long-term goal *might* be to just handle these special cases with 
care, to allow them by properly handling this case in the implementation, 
however, I wasn't unable to do that with my limited knowledge.

Best regards,
Christian Parpart.



[-- Attachment #2: cross-subvol-change-fix.diff --]
[-- Type: text/x-patch, Size: 842 bytes --]

diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index ff0c359..20a3772 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -2748,6 +2748,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;
+
 	btrfs_inc_nlink(inode);
 	err = btrfs_check_free_space(root, 1, 0);
 	if (err)
@@ -3577,6 +3581,10 @@ static int btrfs_rename(struct inode * old_dir, struct dentry *old_dentry,
 		return -ENOTEMPTY;
 	}
 
+	/* do not allow sys_rename's with other subvols of the same device */
+	if (root->objectid != BTRFS_I(new_dir)->root->objectid)
+		return -EPERM;
+
 	ret = btrfs_check_free_space(root, 1, 0);
 	if (ret)
 		goto out_unlock;

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] deny sys_{rename,link} across subvolumes of same disk
  2008-10-09  1:40 [PATCH] deny sys_{rename,link} across subvolumes of same disk Christian Parpart
@ 2008-10-09  5:55 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2008-10-09  5:55 UTC (permalink / raw)
  To: Christian Parpart; +Cc: linux-btrfs

On Thu, Oct 09, 2008 at 03:40:50AM +0200, Christian Parpart wrote:
> This patch denies renames and linking of inodes across subvolumes, as it 
> causes disk format corruption.
> 
> I guess a long-term goal *might* be to just handle these special cases with 
> care, to allow them by properly handling this case in the implementation, 
> however, I wasn't unable to do that with my limited knowledge.

I'll post patches in a few days that make sure every subvolume is under
a different vfsmount which also solves this problem.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-09  5:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-09  1:40 [PATCH] deny sys_{rename,link} across subvolumes of same disk Christian Parpart
2008-10-09  5:55 ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.