Skip to contentSkip to conversation

RFC: permit link(2) to work across --bind mounts ?

DISCUSSION Bodo Eggert 4 participants 5 messages Dec 19, 2007 – Dec 20, 2007 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 8 lines · Al Viro
Quoted 6 lines · Al Viro
Quoted 2 lines · Mark Lord

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

Because it gives you a security boundary around a subtree.

Quoted 8 lines

PS: that had been discussed quite a few times, but to avoid searches:
consider e.g. mount --bind /tmp /tmp; now you've got a situation when users can't create links to elsewhere no root fs, even though they have /tmp writable to them. Similar technics works for other isolation needs - basically, you can confine rename/link to given subtree. IOW, it's a deliberate feature. Note that you can bind a bunch of trees into chroot and get predictable restrictions regardless of how the stuff might get rearranged a year later in the main tree, etc.

Since nobody knows about this "security boundary" and everybody knows about the annoying "can't link across bind-mountpoints bug", what about introducing a mount option to allow link()ing?

#4 lore raw
Quoted 2 lines · Bodo Eggert

Since nobody knows about this "security boundary" and everybody knows about the annoying "can't link across bind-mountpoints bug",

... how about teaching people to RTFM? Starting, perhaps, with man 2 link?

#5 lore raw

Hi Al,

Quoted 7 lines · Al Viro
Quoted 2 lines · Bodo Eggert

Since nobody knows about this "security boundary" and everybody knows about the annoying "can't link across bind-mountpoints bug",

... how about teaching people to RTFM? Starting, perhaps, with man 2 link?

Making people RTFM? Are you trippin? ;)

But in the sense of providing mechanism not (only) policy, a mount option for that behaviour would still be nice.

Hannes

#6 lore raw
In reply to Al Viro
Quoted 6 lines · Al Viro
Quoted 2 lines · Bodo Eggert

Since nobody knows about this "security boundary" and everybody knows about the annoying "can't link across bind-mountpoints bug",

... how about teaching people to RTFM? Starting, perhaps, with man 2 link?

..

Mmm.. that's a programmers' man page, not a user/admin page. Something in mv(1) would be very useful to have.

And perhaps a mount flag to select desired behaviour, since virtually everyone expects it to "just work" that way, and it doesn't.

I'll happily generate a patch if we can agree on the correctness of the sample patch I posted earlier, plus a suitable mount flag name.

Cheers

#7 lore raw
In reply to Al Viro
Quoted 6 lines · Al Viro
Quoted 2 lines · Bodo Eggert

Since nobody knows about this "security boundary" and everybody knows about the annoying "can't link across bind-mountpoints bug",

... how about teaching people to RTFM? Starting, perhaps, with man 2 link?

What about reading POSIX which says

1264 [EXDEV]
1265 Improper link. A link to a file on another file system was attempted.

So if the link creates a file on NOT another filesystem (which is the point of bind mounts), it should NOT return EXDEV.

Having an artificial boundary between different views to a fs may happen to be a security feature if used with care, but most users do expect the opposite and wonder why mv is needlessly slow. I'm not even sure if defaulting to having a barrier is sane at all, but if people confuse filesystems and mountpoints^W^W^W^Wuse this feature, they will depend on this feature not changing:-)

Signature · 3 lines
"It is generally inadvisable to eject directly over the area you just
bombed."
-U.S. Air Force Manual