linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Fwd: allow rename to "--bind"-mounted filesystem
@ 2003-05-06 10:04 Alex Riesen
  2003-05-06 14:30 ` viro
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Riesen @ 2003-05-06 10:04 UTC (permalink / raw)
  To: viro; +Cc: linux-kernel, Eric Lammerts

Hi,
i just came over this patch, and wondered why is it missing
in both 2.4 and 2.5 (the code in do_rename is identical in both
kernels).

Are such renames really not allowed, or was it just fixed differently?

-alex

----- Forwarded message from Eric Lammerts <eric@lammerts.org> -----

Date: 	Sun, 19 Jan 2003 00:34:59 +0100
Subject: [PATCH] allow rename to "--bind"-mounted filesystem 
From: Eric Lammerts <eric@lammerts.org>
To: linux-kernel@vger.kernel.org
Message-ID: <20030118233459.GA18011@ally.lammerts.org>
X-Mailing-List: 	linux-kernel@vger.kernel.org


Hi,
I just discovered that rename(2) does not allow you to rename a file within
the same filesystem if there is a "--bind" in the way. For example:

# mkdir mydir
# mount --bind . mydir
# touch myfile
# strace -erename perl -e 'rename "myfile", "mydir/myfile2"'
rename("myfile", "mydir/myfile2") = -1 EXDEV (Invalid cross-device link)

IMHO it should be possible to do a rename in this situation.

I propose to remove the check in do_rename() altogether. It shouldn't be
necessary, since there's also a check for a cross-device rename in
vfs_rename_dir() and vfs_rename_other().

Patch below has been tested.

Eric


--- linux-2.4.21-pre3/fs/namei.c.orig	2003-01-18 23:56:46.000000000 +0100
+++ linux-2.4.21-pre3/fs/namei.c	2003-01-18 23:57:30.000000000 +0100
@@ -1860,10 +1860,6 @@
 	if (error)
 		goto exit1;
 
-	error = -EXDEV;
-	if (oldnd.mnt != newnd.mnt)
-		goto exit2;
-
 	old_dir = oldnd.dentry;
 	error = -EBUSY;
 	if (oldnd.last_type != LAST_NORM)

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

* Re: Fwd: allow rename to "--bind"-mounted filesystem
  2003-05-06 10:04 Fwd: allow rename to "--bind"-mounted filesystem Alex Riesen
@ 2003-05-06 14:30 ` viro
  2003-05-06 14:34   ` Alex Riesen
  0 siblings, 1 reply; 6+ messages in thread
From: viro @ 2003-05-06 14:30 UTC (permalink / raw)
  To: Alex Riesen; +Cc: linux-kernel, Eric Lammerts

On Tue, May 06, 2003 at 12:04:35PM +0200, Alex Riesen wrote:
> Hi,
> i just came over this patch, and wondered why is it missing
> in both 2.4 and 2.5 (the code in do_rename is identical in both
> kernels).
> 
> Are such renames really not allowed, or was it just fixed differently?

Such remames are _deliberately_ not allowed.

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

* Re: Fwd: allow rename to "--bind"-mounted filesystem
  2003-05-06 14:30 ` viro
@ 2003-05-06 14:34   ` Alex Riesen
  2003-05-06 15:02     ` viro
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Riesen @ 2003-05-06 14:34 UTC (permalink / raw)
  To: viro; +Cc: linux-kernel

viro@parcelfarce.linux.theplanet.co.uk, Tue, May 06, 2003 16:30:26 +0200:
> On Tue, May 06, 2003 at 12:04:35PM +0200, Alex Riesen wrote:
> > Hi,
> > i just came over this patch, and wondered why is it missing
> > in both 2.4 and 2.5 (the code in do_rename is identical in both
> > kernels).
> > 
> > Are such renames really not allowed, or was it just fixed differently?
> 
> Such remames are _deliberately_ not allowed.
> 

because that would be against semantics of a mounted filesystem?
(which, in turn, would break something)



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

* Re: Fwd: allow rename to "--bind"-mounted filesystem
  2003-05-06 14:34   ` Alex Riesen
@ 2003-05-06 15:02     ` viro
  2003-05-06 15:09       ` Alex Riesen
  0 siblings, 1 reply; 6+ messages in thread
From: viro @ 2003-05-06 15:02 UTC (permalink / raw)
  To: Alex Riesen; +Cc: linux-kernel

On Tue, May 06, 2003 at 04:34:59PM +0200, Alex Riesen wrote:
> viro@parcelfarce.linux.theplanet.co.uk, Tue, May 06, 2003 16:30:26 +0200:
> > On Tue, May 06, 2003 at 12:04:35PM +0200, Alex Riesen wrote:
> > > Hi,
> > > i just came over this patch, and wondered why is it missing
> > > in both 2.4 and 2.5 (the code in do_rename is identical in both
> > > kernels).
> > > 
> > > Are such renames really not allowed, or was it just fixed differently?
> > 
> > Such remames are _deliberately_ not allowed.
> > 
> 
> because that would be against semantics of a mounted filesystem?
> (which, in turn, would break something)

Binding a subtree creates a sandbox of sorts.  You can bind a bunch of
subtrees of the same fs into namespace and have normal protection
against rename and link between them.

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

* Re: Fwd: allow rename to "--bind"-mounted filesystem
  2003-05-06 15:02     ` viro
@ 2003-05-06 15:09       ` Alex Riesen
  2003-05-06 16:13         ` Carl-Daniel Hailfinger
  0 siblings, 1 reply; 6+ messages in thread
From: Alex Riesen @ 2003-05-06 15:09 UTC (permalink / raw)
  To: viro; +Cc: linux-kernel

viro@parcelfarce.linux.theplanet.co.uk, Tue, May 06, 2003 17:02:19 +0200:
> On Tue, May 06, 2003 at 04:34:59PM +0200, Alex Riesen wrote:
> > viro@parcelfarce.linux.theplanet.co.uk, Tue, May 06, 2003 16:30:26 +0200:
> > > On Tue, May 06, 2003 at 12:04:35PM +0200, Alex Riesen wrote:
> > > > i just came over this patch, and wondered why is it missing in
> > > > both 2.4 and 2.5 (the code in do_rename is identical in both
> > > > kernels).
> > > > 
> > > > Are such renames really not allowed, or was it just fixed
> > > > differently?
> > > 
> > > Such remames are _deliberately_ not allowed.
> > 
> > because that would be against semantics of a mounted filesystem?
> > (which, in turn, would break something)
> 
> Binding a subtree creates a sandbox of sorts.  You can bind a bunch of
> subtrees of the same fs into namespace and have normal protection
> against rename and link between them.

sounds useful, even though i can't think of real example of such a use :)

Thank you, that clarifies the behaviour, at least to me.

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

* Re: Fwd: allow rename to "--bind"-mounted filesystem
  2003-05-06 15:09       ` Alex Riesen
@ 2003-05-06 16:13         ` Carl-Daniel Hailfinger
  0 siblings, 0 replies; 6+ messages in thread
From: Carl-Daniel Hailfinger @ 2003-05-06 16:13 UTC (permalink / raw)
  To: alexander.riesen; +Cc: linux-kernel

Alex Riesen wrote:
> viro@parcelfarce.linux.theplanet.co.uk, Tue, May 06, 2003 17:02:19 +0200:

>>Binding a subtree creates a sandbox of sorts.  You can bind a bunch of
>>subtrees of the same fs into namespace and have normal protection
>>against rename and link between them.
> 
> sounds useful, even though i can't think of real example of such a use :)

chroot? As Al said, you create a sandbox this way. Saved me more than
once from stupid mistakes.

Carl-Daniel


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

end of thread, other threads:[~2003-05-06 16:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-06 10:04 Fwd: allow rename to "--bind"-mounted filesystem Alex Riesen
2003-05-06 14:30 ` viro
2003-05-06 14:34   ` Alex Riesen
2003-05-06 15:02     ` viro
2003-05-06 15:09       ` Alex Riesen
2003-05-06 16:13         ` Carl-Daniel Hailfinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).