linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: RFC: permit link(2)  to work across --bind mounts ?
@ 2007-12-20  1:33 linux
  2007-12-20  2:06 ` Mark Lord
  0 siblings, 1 reply; 26+ messages in thread
From: linux @ 2007-12-20  1:33 UTC (permalink / raw)
  To: linux-kernel, lkml

> Why does link(2) not support hard-linking across bind mount points
> of the same underlying filesystem ?

Whenever we get mount -r --bind working properly (which I use to place
copies of necessary shared libraries inside chroot jails while allowing
page cache sharing), this feature would break security.

mkdir /usr/lib/libs.jail
for i in $LIST_OF_LIBRARIES; do
	ln /usr/lib/$i /usr/lib/libs.jail/$i
done
mount -r /usr/lib/libs.jail /jail/lib
chown prisoner /usr/log/jail
mount /usr/log/jail /jail/usr/log
chrootuid /jail prisoner /bin/untrusted &

Although protections should be enough, but I'd rather avoid having the
prisoner link /jail/lib/libfoo.so (write returns EROFS) to /jail/usr/log
where it's potentially writeable.

^ permalink raw reply	[flat|nested] 26+ messages in thread
[parent not found: <9BTqk-2ck-31@gated-at.bofh.it>]
* RFC: permit link(2)  to work across --bind mounts ?
@ 2007-12-18 22:46 Mark Lord
  2007-12-18 22:57 ` Mark Lord
                   ` (2 more replies)
  0 siblings, 3 replies; 26+ messages in thread
From: Mark Lord @ 2007-12-18 22:46 UTC (permalink / raw)
  To: Alexander Viro, Andrew Morton, Linux Kernel

Why does link(2) not support hard-linking across bind mount points
of the same underlying filesystem ?

Is it as simple as something like this patch below (minus the printk)?
Not likely, but then I'm not a filesystem guru.

???

--- old/fs/namei.c	2007-12-15 12:33:13.000000000 -0500
+++ linux/fs/namei.c	2007-12-18 17:37:04.000000000 -0500
@@ -2398,8 +2398,11 @@
 	if (error)
 		goto out;
 	error = -EXDEV;
-	if (old_nd.mnt != nd.mnt)
-		goto out_release;
+	if (old_nd.mnt != nd.mnt) {
+		if (old_nd.mnt->mnt_sb != nd.mnt->mnt_sb)
+			goto out_release;
+		printk("sys_linkat: old_nd.mnt != nd.mnt, but sb is the same. Continuing..\n");
+	}
 	new_dentry = lookup_create(&nd, 0);
 	error = PTR_ERR(new_dentry);
 	if (IS_ERR(new_dentry))

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

end of thread, other threads:[~2007-12-30  3:55 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-20  1:33 RFC: permit link(2) to work across --bind mounts ? linux
2007-12-20  2:06 ` Mark Lord
     [not found] <9BTqk-2ck-31@gated-at.bofh.it>
     [not found] ` <9BTJN-2Sv-21@gated-at.bofh.it>
     [not found]   ` <9BTTr-35L-13@gated-at.bofh.it>
2007-12-19 13:43     ` Bodo Eggert
2007-12-19 14:23       ` Al Viro
2007-12-19 15:42         ` Johannes Weiner
2007-12-19 16:44         ` Mark Lord
2007-12-20 20:55         ` Bodo Eggert
  -- strict thread matches above, loose matches on Subject: below --
2007-12-18 22:46 Mark Lord
2007-12-18 22:57 ` Mark Lord
2007-12-18 23:00 ` Al Viro
2007-12-18 23:14   ` Al Viro
2007-12-19  3:54     ` Mark Lord
2007-12-19  3:59       ` David Newall
2007-12-19 16:47         ` Mark Lord
2007-12-19 18:38           ` David Newall
2007-12-29  2:53         ` dean gaudet
2007-12-29  3:31           ` Jan Engelhardt
2007-12-29  6:02             ` dean gaudet
2007-12-29  6:48               ` Jan Engelhardt
2007-12-29  8:29           ` David Newall
2007-12-29 16:18             ` dean gaudet
2007-12-29 20:35               ` David Newall
2007-12-29 20:40                 ` dean gaudet
2007-12-30  3:43                   ` Valdis.Kletnieks
2007-12-30  3:55                     ` dean gaudet
2007-12-27  3:43 ` Rogelio M. Serrano Jr.

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).