Skip to contentSkip to conversation

private mounts

PATCH Bodo Eggert <[email protected]> 15 participants 81 messages Apr 25, 2005 – Apr 29, 2005 12 messages not in the archive VFS

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]

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]

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]

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]

#11 lore raw
Quoted 10 lines · Jan Hudec
Quoted 2 lines · Miklos Szeredi

How do you bind mount it from a different namespace? You _do_ need bind mount, since a new mount might require password input, etc...

Yes, I would need one thing from kernel. That one thing would be to mount bind a directory handle, instead of path.

And if you wonder how I get the handle, that's what SCM_RIGHTS message of unix-domain sockets is for.

You'll need something to get the FD from. What will that be if the mount was done from a subshell of the midnight commander run in a screen session?

What about X sessions? Open a xterm, do the mount and then do what to get the mount working for the programs run from the window manager? Relogin? The xterm with the mount will be gone.
Use a daemon to keep an additional reference to the namespace? That's UGLY.

With attachable namespaces, the whole thing should be as simple as (pseudocode)
mknamespace -p users/$UID # (like mkdir -p)
setnamespace users/$UID # (like cd)

Optionally, the namespaces and their private mounts might be scheduled to be removed if the last user is gone, or they need to be persistent, depending on the applicaton (e.g. ssh used as rexec or shared mounts).

Signature · 1 line
Remember, a retreating enemy is probably just falling back and regrouping. 
#12 lore raw
Quoted 20 lines · Bodo Eggert
Quoted 10 lines · Jan Hudec
Quoted 2 lines · Miklos Szeredi

How do you bind mount it from a different namespace? You _do_ need bind mount, since a new mount might require password input, etc...

Yes, I would need one thing from kernel. That one thing would be to mount bind a directory handle, instead of path.

And if you wonder how I get the handle, that's what SCM_RIGHTS message of unix-domain sockets is for.

You'll need something to get the FD from. What will that be if the mount was done from a subshell of the midnight commander run in a screen session?

What about X sessions? Open a xterm, do the mount and then do what to get the mount working for the programs run from the window manager? Relogin? The xterm with the mount will be gone.
Use a daemon to keep an additional reference to the namespace? That's UGLY.

Quoted 8 lines

With attachable namespaces, the whole thing should be as simple as (pseudocode)
mknamespace -p users/$UID # (like mkdir -p)
setnamespace users/$UID # (like cd)

Optionally, the namespaces and their private mounts might be scheduled to be removed if the last user is gone, or they need to be persistent, depending on the applicaton (e.g. ssh used as rexec or shared mounts).

Agreed.

I guess for this thread to make any progress, we need a set of coherent requirements from FUSE team.

RP

#13 lore raw
Quoted 2 lines · Ram

I guess for this thread to make any progress, we need a set of coherent requirements from FUSE team.

Yes. A list of use-cases from the FUSE team which would be nice to use would be a good start. Then people who aren't so close to FUSE can suggest alternative ways of doing those, until we whittle down to the essential features that aren't already available in the kernel, if any.

-- Jamie

#14 lore raw
Quoted 5 lines
Quoted 2 lines

I guess for this thread to make any progress, we need a set of coherent requirements from FUSE team.

Yes. A list of use-cases from the FUSE team which would be nice to use would be a good start.

What kind of usecases would you like to see? FUSE filesystems are used just like any other filesystem, so listing "copy file from x to z" and suchlike seems pointless ;)

Quoted 3 lines

Then people who aren't so close to FUSE can suggest alternative ways of doing those, until we whittle down to the essential features that aren't already available in the kernel, if any.

The most important difference between orinary filesystems and FUSE is the fact, that the filesystem data/metadata is provided by a userspace process run with the privileges of the mount "owner" instead of the kernel, or some remote entity usually running with elevated privileges.

The security implication of this is that a non-privileged user must not be able to use this capability to compromise the system. Obvious requirements arising from this are:

- mount owner should not be able to get elevated privileges with the help of the mounted filesystem

- mount owner should not be able to induce undesired behavior in other users' or the super user's processes

- mount owner should not get illegitimate access to information from other users' and the super user's processes

These are currently ensured with the following constraints:

1) mount is only allowed to directory or file which the mount owner can modify without limitation (write access + no sticky bit for directories)

2) nosuid,nodev mount options are forced

3) any process running with fsuid different from the owner is denied all access to the filesystem

1) and 2) are ensured by the "fusermount" mount utility which is a setuid root application doing the actual mount operation.

3) is ensured by a check in the permission() method in kernel

I started thinking about doing 3) in a different way because Christoph H. made a big deal out of it, saying that FUSE is unacceptable into mainline in this form.

The suggested use of private namespaces would be OK, but in their current form have many limitations that make their use impractical (as discussed in this thread).

Suggested improvements that would address these limitations:

- implement shared subtrees

- allow a process to join an existing namespace (make namespaces first-class objects)

- implement the namespace creation/joining in a PAM module

With all that in place the check of owner against current->fsuid may be removed from the FUSE kernel module, without compromising the security requirements.

Suid programs still interesting questions, since they get access even to the private namespace causing some information leak (exact order/timing of filesystem operations performed), giving some ptrace-like capabilities to unprivileged users. BTW this problem is not strictly limited to the namespace approach, since suid programs setting fsuid and accessing users' files will succeed with the current approach too.

Is this information enough for further progress to be made?

Thanks for the help,
Miklos

#15 lore raw
Quoted 5 lines · Miklos Szeredi

The most important difference between orinary filesystems and FUSE is the fact, that the filesystem data/metadata is provided by a userspace process run with the privileges of the mount "owner" instead of the kernel, or some remote entity usually running with elevated privileges.

define "mount owner". Right now mount requires CAP_SYS_ADMIN which means fairly privilegued. Having some kind of user mounts would be nice, but needs a fair amount of auditing first.

#16 lore raw
Quoted 9 lines
Quoted 6 lines

The most important difference between orinary filesystems and FUSE is the fact, that the filesystem data/metadata is provided by a userspace process run with the privileges of the mount "owner" instead of the kernel, or some remote entity usually running with elevated privileges.

define "mount owner". Right now mount requires CAP_SYS_ADMIN which means fairly privilegued.

FUSE uses a suid root helper (as explained below). Please read the whole mail.

Thanks,
Miklos

#17 lore raw
Quoted 5 lines · Miklos Szeredi
Quoted 2 lines

define "mount owner". Right now mount requires CAP_SYS_ADMIN which means fairly privilegued.

FUSE uses a suid root helper (as explained below). Please read the whole mail.

In that case you're totally out of luck. This is not a setup we want to account for.

#18 lore raw
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

define "mount owner". Right now mount requires CAP_SYS_ADMIN which means fairly privilegued.

FUSE uses a suid root helper (as explained below). Please read the whole mail.

In that case you're totally out of luck. This is not a setup we want to account for.

Christoph, you are being thickheaded, and this is not the first time. Please go away.

Thanks,
Miklos

#19 lore raw
Quoted 2 lines · Miklos Szeredi

Christoph, you are being thickheaded, and this is not the first time. Please go away.

Please stop the flaming. You're adding the equivalent of "I've added a suid shell, please make sure it can only affect the caller's files".

Do you really think we want to add such crap?

You're really falling into the Hans Reiser trap - if you just wanted to add a simple userland filesystem you'd be done by now, but you're trying to funnel new semantics in through it. Which is by far not as easy as adding a simple file system driver and needs a lot more though.

#20 lore raw
Quoted 7 lines
Quoted 2 lines

Christoph, you are being thickheaded, and this is not the first time. Please go away.

Please stop the flaming. You're adding the equivalent of "I've added a suid shell, please make sure it can only affect the caller's files".

Do you really think we want to add such crap?

Do you think I'd want such crap?

No. FUSE is not a suid shell, and it's definitely not crap. You are being impolite and without a reason. So don't be surprised if you get burned.

Quoted 4 lines

You're really falling into the Hans Reiser trap - if you just wanted to add a simple userland filesystem you'd be done by now, but you're trying to funnel new semantics in through it. Which is by far not as easy as adding a simple file system driver and needs a lot more though.

I've started FUSE in 2001. Did you think it was easy getting this far?

Come on!

Miklos

#21 lore raw
Quoted 3 lines · Miklos Szeredi

No. FUSE is not a suid shell, and it's definitely not crap. You are being impolite and without a reason. So don't be surprised if you get burned.

You're model for user mounts is total crap. The rest of the fuse kernel code is quite nice (1).

Quoted 6 lines
Quoted 4 lines

You're really falling into the Hans Reiser trap - if you just wanted to add a simple userland filesystem you'd be done by now, but you're trying to funnel new semantics in through it. Which is by far not as easy as adding a simple file system driver and needs a lot more though.

I've started FUSE in 2001. Did you think it was easy getting this far?

And that matters how exactly?

(1) except the rather fishy get_user_pages variant. but I'm not expert enough there to comment more

#22 lore raw
Quoted 6 lines
Quoted 3 lines

No. FUSE is not a suid shell, and it's definitely not crap. You are being impolite and without a reason. So don't be surprised if you get burned.

You're model for user mounts is total crap. The rest of the fuse kernel code is quite nice (1).

Oh, a compliment from Christoph H. himself, how flattering :)

And for the first part, please _explain_ why you think it's crap. Calling something crap, will surely not make it less crap, will it?

Miklos

#23 lore raw
Quoted 1 line · Miklos Szeredi

And for the first part, please _explain_ why you think it's crap.

Problem 1:

- you're mounting things into the global namespace, but expect it only be visible to a certain subset of processes. these processes are also not specicified by a tradition unix session / process group / etc but against all the process attributes we have based on the uid

Problem 2, which is related:

- in fuse you're re-routing filesystem request to userspace, so fine so good
- mount is currently a privilegued operation, and expects a privilegued filesystem implementation, not an ordinary user
- to bypass that you have a suid mount wrapper
- now you need various hacks to make sure this can't be used by other users

in short you are hacking around the namespace management which sits above the filesystems in a rather broken way.

#24 lore raw
Quoted 6 lines

Problem 1:

- you're mounting things into the global namespace, but expect it only be visible to a certain subset of processes. these processes are also not specicified by a tradition unix session / process group / etc but against all the process attributes we have based on the uid

Yes, so? You are harping on this without ever telling a concrete technical problem with it.

Yes root will assume it's a directory that can be read. And it will get -EACCESS. Is there a problem with this? Is there a problem with NFS exports with root_squash (which is the default btw)? See the similarity?

Quoted 7 lines

Problem 2, which is related:

- in fuse you're re-routing filesystem request to userspace, so fine so good
- mount is currently a privilegued operation, and expects a privilegued filesystem implementation, not an ordinary user
- to bypass that you have a suid mount wrapper
- now you need various hacks to make sure this can't be used by other users

Why is this a hack? What is the problem with it?

NFSv3 implements it's own permission checking based on credentials returned by the server. If client doesn't support Posix ACL and server does, the permission bits _will_ be out of sync with the actual permission you get on the file, and you will never know why. Is it a problem? Can it be avoided?

How would sshfs client create permission bits for files, which match the exact permissions that the user has on the server. The client doesn't even know the uid of the user on the remote system let alone what groups it belongs to.

Think about these problems, and if you have a _solution_ that you think is better, then pray tell me. If you don't have a solution, but just want to bad-mouth the current FUSE imlementation, I'm not interested.

Miklos

#25 lore raw
In reply to Christoph Hellwig
Quoted 7 lines · Christoph Hellwig
Quoted 3 lines · Miklos Szeredi

No. FUSE is not a suid shell, and it's definitely not crap. You are being impolite and without a reason. So don't be surprised if you get burned.

You're model for user mounts is total crap. The rest of the fuse kernel code is quite nice (1).

And btw, in case you think this flaming here is going to bring you forward in any way: it's not. User mounts and namespace-related changes don't belong into a lowelevel filesystem driver no matter what. Whatever way to handle user-private mount we're going to agree on it's not going to be inside the fuse code. So you're really better of stoppign the flaming, stripping out those bits and help writing down a scheme that you'd want to see in the VFS so we can see whether it makes sense and is implementable.

#26 lore raw
In reply to Christoph Hellwig

Hi!

Quoted 4 lines
Quoted 2 lines

Christoph, you are being thickheaded, and this is not the first time. Please go away.

Please stop the flaming. You're adding the equivalent of "I've added

...

Quoted 4 lines

You're really falling into the Hans Reiser trap - if you just wanted to add a simple userland filesystem you'd be done by now, but you're trying to funnel new semantics in through it. Which is by far not as easy as adding a simple file system driver and needs a lot more though.

Could we get root-only fuse in, please? It is usefull on its own...

In many cases you can just run one fused for all the users and handle priviledges inside fused...
Pavel

Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         
#27 lore raw
Quoted 1 line

Could we get root-only fuse in, please?

chmod u-s /usr/bin/fusermount

Miklos

#28 lore raw

Hi!

Quoted 3 lines
Quoted 1 line

Could we get root-only fuse in, please?

chmod u-s /usr/bin/fusermount

:-)))). I meant merging patches that are not controversial into mainline. AFAICT only controversial pieces are "make it safe for non-root users"...

Pavel

Signature · 1 line
Boycott Kodak -- for their patent abuse against Java.
#29 lore raw
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Could we get root-only fuse in, please?

chmod u-s /usr/bin/fusermount

:-)))). I meant merging patches that are not controversial into mainline. AFAICT only controversial pieces are "make it safe for non-root users"...

This is the controversial part in all it's glory:

	if (!(fc->flags & FUSE_ALLOW_OTHER) && current->fsuid != fc->user_id)
		return -EACCES;

Leaving it out would gain us what exactly?

I'm not trying to say that this is somehow better than the pam+shared-subtrees solution discuseed. That certainly has advantages over this (e.g. suid programs get permission to fuse mounted filesystems).

But leaving it out makes no sense. Zero, zilch, none.

Maybe I'm totally dumb, but I just don't get Christoph's argument.

Thanks,
Miklos

#30 lore raw

Hi!

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Could we get root-only fuse in, please?

chmod u-s /usr/bin/fusermount

:-)))). I meant merging patches that are not controversial into mainline. AFAICT only controversial pieces are "make it safe for non-root users"...

Quoted 6 lines

This is the controversial part in all it's glory:

	if (!(fc->flags & FUSE_ALLOW_OTHER) && current->fsuid != fc->user_id)
		return -EACCES;

Leaving it out would gain us what exactly?

Well, if it brings us ugly semantics, keeping those two lines out for a while can help merge a lot...
Pavel

Signature · 1 line
Boycott Kodak -- for their patent abuse against Java.
#31 lore raw
Quoted 9 lines
Quoted 6 lines

This is the controversial part in all it's glory:

	if (!(fc->flags & FUSE_ALLOW_OTHER) && current->fsuid != fc->user_id)
		return -EACCES;

Leaving it out would gain us what exactly?

Well, if it brings us ugly semantics, keeping those two lines out for a while can help merge a lot...

To the mount owner the semantics are quite normal. Others will be denied access to the mountpoint, which doesn't introduce any new semantics either.

If you look at it from the POV of _any_ process, there are NO NEW SEMANTICS. Nothing that programs, scripts or anything has to be modified for. Nothing that could cause _any_ problems later, if this check was removed.

Prove me wrong!

Thanks,
Miklos

#32 lore raw
Quoted 5 lines · Miklos Szeredi
Quoted 5 lines
Quoted 5 lines

This is the controversial part in all it's glory:

	if (!(fc->flags & FUSE_ALLOW_OTHER) && current->fsuid != fc->user_id)
		return -EACCES;
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Leaving it out would gain us what exactly?

Well, if it brings us ugly semantics, keeping those two lines out for a while can help merge a lot...

To the mount owner the semantics are quite normal. Others will be denied access to the mountpoint, which doesn't introduce any new semantics either.

What makes you think Pavel was talking about semantics?!

The point was that:
Ok, there is a strong disagreement about these two lines. Could we have a patch with everything but these two lines, so it can be integrated immediately to profit of the testing and generally be useful, and then the controversial bits when the issue is beaten to death?

So, please, could you send a stripped-down version, that is not safe for mounting by users, but can be tested for many cases where that is sufficient?

Quoted 6 lines

If you look at it from the POV of _any_ process, there are NO NEW SEMANTICS. Nothing that programs, scripts or anything has to be modified for. Nothing that could cause _any_ problems later, if this check was removed.

Prove me wrong!

As I understand it, doing things like this is butt ugly. Not just in fuse -- in NFS, in samba, everywhere where such hacks are employed. But now they just have enough of those hacks and want a cleaner solution.

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

#33 lore raw
Quoted 1 line

What makes you think Pavel was talking about semantics?!

Well, if it brings us ugly semantics, keeping those two lines out for
^^^^^^^^^
a while can help merge a lot...

Quoted 5 lines

The point was that:
Ok, there is a strong disagreement about these two lines. Could we have a patch with everything but these two lines, so it can be integrated immediately to profit of the testing and generally be useful, and then the controversial bits when the issue is beaten to death?

I could remove this check.

But it would only cause confusion. How would the userspace utilities differentiate between the safe out-of-kernel and the unsafe in-kernel module? Adding hacks to make this possible is far more ugly IMO than integrating the current well tested solution.

It makes no sense. If someone would give me a rational explanation why it is bad, I would be content. But you just tell me it's terrible, ugly, crap which may well be true, but are not technical terms, which I can relate to.

Quoted 3 lines

As I understand it, doing things like this is butt ugly. Not just in fuse -- in NFS, in samba, everywhere where such hacks are employed. But now they just have enough of those hacks and want a cleaner solution.

Please do. I want it too.

_When_ we have a better solution, all the hacks can be removed, and the world will rejoice.

Until then, let the hacks live! Please!

Thanks,
Miklos

#34 lore raw
Quoted 19 lines · Miklos Szeredi
Quoted 1 line

What makes you think Pavel was talking about semantics?!

Well, if it brings us ugly semantics, keeping those two lines out for
^^^^^^^^^
a while can help merge a lot...

Quoted 5 lines

The point was that:
Ok, there is a strong disagreement about these two lines. Could we have a patch with everything but these two lines, so it can be integrated immediately to profit of the testing and generally be useful, and then the controversial bits when the issue is beaten to death?

I could remove this check.

But it would only cause confusion. How would the userspace utilities differentiate between the safe out-of-kernel and the unsafe in-kernel module? Adding hacks to make this possible is far more ugly IMO than integrating the current well tested solution.

Quoted 4 lines

It makes no sense. If someone would give me a rational explanation why it is bad, I would be content. But you just tell me it's terrible, ugly, crap which may well be true, but are not technical terms, which I can relate to.

Where the hell do you see it above. The only thing I said above is it is controversial.

The userland tools don't need to know. They just need to not be suid.

Quoted 10 lines
Quoted 3 lines

As I understand it, doing things like this is butt ugly. Not just in fuse -- in NFS, in samba, everywhere where such hacks are employed. But now they just have enough of those hacks and want a cleaner solution.

Please do. I want it too.

_When_ we have a better solution, all the hacks can be removed, and the world will rejoice.

Until then, let the hacks live! Please!

Ok, here I say it is ugly (but not that it's crap). And the reason is, that there is a permission system, with some semantics, and then various filesystems adapt it in varous ways to fit what they want. So every filesystem ends up with it's onw little different behaviour.

That being said, fuse does just about the same as NFS, samba and others and I don't really see the reason why it couldn't be integrated. But I am not the one to decide.

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

#35 lore raw
Quoted 6 lines
Quoted 4 lines

It makes no sense. If someone would give me a rational explanation why it is bad, I would be content. But you just tell me it's terrible, ugly, crap which may well be true, but are not technical terms, which I can relate to.

Where the hell do you see it above.

I meant it as a plural "you" mainly refering to Christoph, who did use those words, and not too sparingly either :)

I did not mean it personally, please accept my apologies.

Quoted 1 line

The userland tools don't need to know. They just need to not be suid.

But I'd want to continue distribute the non-crippled kernel module too, with suid fusermount. Then fusermount _has_ to know which kernel module is currently active.

Quoted 8 lines

Ok, here I say it is ugly (but not that it's crap). And the reason is, that there is a permission system, with some semantics, and then various filesystems adapt it in varous ways to fit what they want. So every filesystem ends up with it's onw little different behaviour.

That being said, fuse does just about the same as NFS, samba and others and I don't really see the reason why it couldn't be integrated. But I am not the one to decide.

Every opinion counts.

I'm not trying to convince people that the current solution is perfect. What I'm saying that it's

a) not harmful

b) it makes non-privileged mounts possible

And b) is _the_ most important feature IMO, so the argument for stripping it out has to be very good.

Thanks,
Miklos

#36 lore raw
Quoted 5 lines · Miklos Szeredi
Quoted 1 line

The userland tools don't need to know. They just need to not be suid.

But I'd want to continue distribute the non-crippled kernel module too, with suid fusermount. Then fusermount _has_ to know which kernel module is currently active.

You can use a version number or feature-bitmask for that.

-- Jamie

#37 lore raw
In reply to Miklos Szeredi

Hi!

Quoted 5 lines
Quoted 1 line

The userland tools don't need to know. They just need to not be suid.

But I'd want to continue distribute the non-crippled kernel module too, with suid fusermount. Then fusermount _has_ to know which kernel module is currently active.

Add a mount flag and make kernel refuse mount on unknown flags?

Quoted 14 lines
Quoted 8 lines

Ok, here I say it is ugly (but not that it's crap). And the reason is, that there is a permission system, with some semantics, and then various filesystems adapt it in varous ways to fit what they want. So every filesystem ends up with it's onw little different behaviour.

That being said, fuse does just about the same as NFS, samba and others and I don't really see the reason why it couldn't be integrated. But I am not the one to decide.

Every opinion counts.

I'm not trying to convince people that the current solution is perfect. What I'm saying that it's

Quoted 6 lines

a) not harmful

b) it makes non-privileged mounts possible

And b) is _the_ most important feature IMO, so the argument for stripping it out has to be very good.

Well, you'll have problems with suid programs suddenly not being able to access files. nfs gets away with it, but nfs is perceived as "broken" anyway...

Pavel

Signature · 1 line
Boycott Kodak -- for their patent abuse against Java.
#38 lore raw

on den 27.04.2005 Klokka 16:58 (+0200) skreiv Pavel Machek:

Quoted 7 lines
Quoted 3 lines

And b) is _the_ most important feature IMO, so the argument for stripping it out has to be very good.

Well, you'll have problems with suid programs suddenly not being able to access files. nfs gets away with it, but nfs is perceived as "broken" anyway...

Really?

The NFS security model is based on the principle that the administrator of the SERVER can override access permissions on his/her hardware. Pray tell why you think that is "broken"?

Cheers,
Trond

Signature · 1 line
Trond Myklebust <[email protected]>
#39 lore raw
Quoted 10 lines · Trond Myklebust

on den 27.04.2005 Klokka 16:58 (+0200) skreiv Pavel Machek:

Quoted 7 lines
Quoted 3 lines

And b) is _the_ most important feature IMO, so the argument for stripping it out has to be very good.

Well, you'll have problems with suid programs suddenly not being able to access files. nfs gets away with it, but nfs is perceived as "broken" anyway...

Quoted 5 lines

Really?

The NFS security model is based on the principle that the administrator of the SERVER can override access permissions on his/her hardware. Pray tell why you think that is "broken"?

Well, administrator on CLIENT can impersonate whoever he wants, and if data happens to be cached, he can just read them from local memory. So whatever SERVER administrator does, CLIENT administrator can work around.
Pavel

Signature · 1 line
Boycott Kodak -- for their patent abuse against Java.
#40 lore raw
Quoted 5 lines
Quoted 3 lines

The NFS security model is based on the principle that the administrator of the SERVER can override access permissions on his/her hardware. Pray tell why you think that is "broken"?

Well, administrator on CLIENT can impersonate whoever he wants,

Not really. Root squash has the very important effect that whatever the client does, it cannot impersonate "root".

Miklos

#41 lore raw
In reply to Pavel Machek

to den 28.04.2005 Klokka 10:24 (+0200) skreiv Pavel Machek:

Quoted 4 lines

Well, administrator on CLIENT can impersonate whoever he wants, and if data happens to be cached, he can just read them from local memory. So whatever SERVER administrator does, CLIENT administrator can work around.

This is why you have identity squashing and/or strong security: to stop the CLIENT administrator impersonating whoever he wants and working around your security measures.

Yes there's all the FUD about how the administrator can still take over your RPCSEC_GSS creds and/or read cached data once you have logged in. If you log into a compromised client then you're screwed. What's new?

Trond

Signature · 1 line
Trond Myklebust <[email protected]>
#42 lore raw
Quoted 3 lines

This is why you have identity squashing and/or strong security: to stop the CLIENT administrator impersonating whoever he wants and working around your security measures.

That's more of a confirmation than a refutation of the statement that NFS root squashing is broken. Root squashing itself simply does not squash a typical system administrator's ability to get at other people's files. "broken" isn't the right word, because as long as you recognize root squashing for what it is, it's working as designed. It just isn't what it appears to be.

But, in the context of the current thread, I think the perception of NFS root squashing as something broken and not to be built upon with private mounts has to do with the fact that it messes up Linux's basic file permission scheme: a process with CAP_DAC_OVERRIDE can get EACCES. EACCESS means discretionary access controls (DAC) prevent access. So this behavior is unexpected and unnatural. Worse, an operation can succeed _without_ CAP_DAC_OVERRIDE, but not _with_ it. I've seen this behavior cause trouble a number of times -- mostly because it's entirely unanticipated.

--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems

#43 lore raw

to den 28.04.2005 Klokka 10:58 (-0700) skreiv Bryan Henderson:

Quoted 10 lines
Quoted 3 lines

This is why you have identity squashing and/or strong security: to stop the CLIENT administrator impersonating whoever he wants and working around your security measures.

That's more of a confirmation than a refutation of the statement that NFS root squashing is broken. Root squashing itself simply does not squash a typical system administrator's ability to get at other people's files. "broken" isn't the right word, because as long as you recognize root squashing for what it is, it's working as designed. It just isn't what it appears to be.

Root squashing is there to enforce the policy that nobody gets to access any files with uid=0,gid=0. IOW it is a policy that is first and foremost meant to make root-owned files untouchable.

Strong security, OTOH, enforces the policy that you need to authenticate as a given person in order to get at that person's files.

Neither can prevent man-in-the-middle style attacks by root on a client that is compromised nor can they stop someone who has managed to lift your username+password from somewhere. Every security policy has its limitations.

Quoted 9 lines

But, in the context of the current thread, I think the perception of NFS root squashing as something broken and not to be built upon with private mounts has to do with the fact that it messes up Linux's basic file permission scheme: a process with CAP_DAC_OVERRIDE can get EACCES. EACCESS means discretionary access controls (DAC) prevent access. So this behavior is unexpected and unnatural. Worse, an operation can succeed _without_ CAP_DAC_OVERRIDE, but not _with_ it. I've seen this behavior cause trouble a number of times -- mostly because it's entirely unanticipated.

Tough. Your administrator has set a certain policy on the fileserver, and it is being correctly enforced. If that policy decision turns out to be unnecessarily strict then you are quite free to plead with the administrator to change it.

Note that these days CAP_DAC_OVERRIDE is no longer guaranteed to be sufficient even for local disk if the administrator is using LSE to set up custom policies.

Cheers,
Trond

Signature · 1 line
Trond Myklebust <[email protected]>
#44 lore raw
Quoted 3 lines

Root squashing is there to enforce the policy that nobody gets to access any files with uid=0,gid=0. IOW it is a policy that is first and foremost meant to make root-owned files untouchable.

That's the only thing it does well, but you'd have to convince me that that's what it was designed for and that's what everyone expects out of it. The most salient effect of root squashing -- the one that takes people by surprise -- is that it removes the special rights an NFS server otherwise accords to uid 0. If protecting files owned by uid=0, gid=0 were the original design goal, the protocol could have been designed to do that while still giving uid 0 access to everybody else's files.

Quoted 2 lines
Quoted 1 line

a process with CAP_DAC_OVERRIDE can get EACCES. ... Whine, whine...

Tough.

This is actually off-topic. We're not talking about whether root squashing is a good compromise. We started with the statement that the only existing thing like (some private mount proposal) is NFS root squashing and the statement that some people consider that broken. That elicited a response from you that suggested you were unaware there was anything not to like about root squashing ("Really?") and then some descriptions of the objections. The fact is that negative perceptions of root squashing exist. I know you know that. There are respectable technical people who don't agree with the compromise. So if one is looking for a broadly acceptable design of private mounts, one might want to find one that doesn't use NFS root squashing as its precedent.

--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems

#45 lore raw

to den 28.04.2005 Klokka 15:38 (-0700) skreiv Bryan Henderson:

Quoted 11 lines
Quoted 3 lines

Root squashing is there to enforce the policy that nobody gets to access any files with uid=0,gid=0. IOW it is a policy that is first and foremost meant to make root-owned files untouchable.

That's the only thing it does well, but you'd have to convince me that that's what it was designed for and that's what everyone expects out of it. The most salient effect of root squashing -- the one that takes people by surprise -- is that it removes the special rights an NFS server otherwise accords to uid 0. If protecting files owned by uid=0, gid=0 were the original design goal, the protocol could have been designed to do that while still giving uid 0 access to everybody else's files.

That is much harder to do. The nfs server would have to take over the permissions checking on behalf of whatever it is exporting for all operations.

Quoted 14 lines
Quoted 2 lines
Quoted 1 line

a process with CAP_DAC_OVERRIDE can get EACCES. ... Whine, whine...

Tough.

This is actually off-topic. We're not talking about whether root squashing is a good compromise. We started with the statement that the only existing thing like (some private mount proposal) is NFS root squashing and the statement that some people consider that broken. That elicited a response from you that suggested you were unaware there was anything not to like about root squashing ("Really?") and then some descriptions of the objections. The fact is that negative perceptions of root squashing exist. I know you know that. There are respectable technical people who don't agree with the compromise. So if one is looking for a broadly acceptable design of private mounts, one might want to find one that doesn't use NFS root squashing as its precedent.

The lack of agreement on root squashing is a reason for it to be a matter of administrator-defined policy, and why the solution chosen _should_ allow for that kind of behaviour.

If the user is free to futz around with the namespace, then it makes a lot of sense for administrators to want to restrict access to this user-defined namespace to non-suid programs that won't start screwing round with opening files on arbitrary filesystems using the wrong credentials and/or capabilities.
Particularly so if the user is capable of mounting remote filesystems.

Trond

Signature · 1 line
Trond Myklebust <[email protected]>
#46 lore raw
In reply to Miklos Szeredi
Quoted 5 lines · Miklos Szeredi
Quoted 5 lines
Quoted 5 lines

This is the controversial part in all it's glory:

	if (!(fc->flags & FUSE_ALLOW_OTHER) && current->fsuid != fc->user_id)
		return -EACCES;
Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Leaving it out would gain us what exactly?

Well, if it brings us ugly semantics, keeping those two lines out for a while can help merge a lot...

To the mount owner the semantics are quite normal. Others will be denied access to the mountpoint, which doesn't introduce any new semantics either.

Why, exactly, is this check in the kernel and not the FUSE daemon?

Someone said the FUSE daemon knows which user is making filesystem requests, and can therefore do this. Is it true?

-- Jamie

#47 lore raw
Quoted 4 lines

Why, exactly, is this check in the kernel and not the FUSE daemon?

Someone said the FUSE daemon knows which user is making filesystem requests, and can therefore do this. Is it true?

Yes.

The check is in the kernel, because otherwise it couldn't be enforced.

It is not there for the purpose of protecting user's data. Rather for protecting other users (including root) from unknowingly entering the FUSE directory and thus leaking otherwise inaccessible information (exact file operations performed) to the mount owner.

It's probably not a great security risk, but it's better to be safe than sorry. If a sysadmin decides, it's not problematic, he can relax this by

echo user_allow_other >> /etc/fuse.conf

Miklos

#48 lore raw
Quoted 8 lines
Quoted 4 lines

Why, exactly, is this check in the kernel and not the FUSE daemon?

Someone said the FUSE daemon knows which user is making filesystem requests, and can therefore do this. Is it true?

Yes.

The check is in the kernel, because otherwise it couldn't be enforced.

I'm going to compile a fuse-user-mount FAQ. This is about the 4th time I answer this question in this thread :)

Miklos

#49 lore raw
In reply to Miklos Szeredi

Hello!

Quoted 4 lines

It is not there for the purpose of protecting user's data. Rather for protecting other users (including root) from unknowingly entering the FUSE directory and thus leaking otherwise inaccessible information (exact file operations performed) to the mount owner.

Huh? Do you really suppose that there could be anything secret in the operations somebody else is performing on your files?

I still don't see any real problem this check could ever solve.

Have a nice fortnight

Signature · 3 lines
Martin `MJ' Mares   <[email protected]>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
God is real, unless declared integer.
#50 lore raw
Quoted 7 lines · Martin Mares
Quoted 4 lines

It is not there for the purpose of protecting user's data. Rather for protecting other users (including root) from unknowingly entering the FUSE directory and thus leaking otherwise inaccessible information (exact file operations performed) to the mount owner.

Huh? Do you really suppose that there could be anything secret in the operations somebody else is performing on your files?

It is certainly an information leak not otherwise available. And with the ability to change the layout underneath, you might trigger bugs in root programs: Are they really capable of seeing the same filename twice, or can you throw them into a deep recursion by simulating infinitely deep directories/circular hardlinks...?

Certainly a useful tool for hardening applications, but I can see the point of not wanting to let unwary applications run into a namespace controlled by a user. Of course, this is sort-of similar to "find -xdev", but I'm not sure whether it is not indeed new behaviour.

Sincerely,
Lars Marowsky-Brée <[email protected]>

Signature · 8 lines
High Availability & Clustering
SUSE Labs, Research and Development
SUSE LINUX Products GmbH - A Novell Business

-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
#51 lore raw

Hello!

Quoted 5 lines

It is certainly an information leak not otherwise available. And with the ability to change the layout underneath, you might trigger bugs in root programs: Are they really capable of seeing the same filename twice, or can you throw them into a deep recursion by simulating infinitely deep directories/circular hardlinks...?

Yes, it can help you trigger bugs, but all these bugs are triggerable without user filesystems as well, although it's harder to do so.

Have a nice fortnight

Signature · 3 lines
Martin `MJ' Mares   <[email protected]>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
If the government wants us to respect the law, it should set a better example.
#52 lore raw
Quoted 8 lines
Quoted 5 lines

It is certainly an information leak not otherwise available. And with the ability to change the layout underneath, you might trigger bugs in root programs: Are they really capable of seeing the same filename twice, or can you throw them into a deep recursion by simulating infinitely deep directories/circular hardlinks...?

Yes, it can help you trigger bugs, but all these bugs are triggerable without user filesystems as well, although it's harder to do so.

It's not just triggering bugs. You have very fine control over what you present in your filesystem. Examples are huge files, huge directories, operations that complete slowly or never at all.

Is it possible to limit all these from kernelspace? Probably yes, although a timeout for operations is something that cuts either way. And the compexity of these checks would probably be orders of magnitude higher then the check we are currently discussing.

So this check _is_ needed on systems where the users cannot be trusted.

Thanks,
Miklos

#53 lore raw

Hi Miklos!

Quoted 4 lines

Is it possible to limit all these from kernelspace? Probably yes, although a timeout for operations is something that cuts either way. And the compexity of these checks would probably be orders of magnitude higher then the check we are currently discussing.

Yes ... but does the check we are discussing really solve the problem?

Let's say that you attempt to export home directories of users by a user-space NFS daemon. This daemon probably changes its fsuid to match the remote user, so the check happily accepts the access and the user is able to lock up the daemon.

It doesn't seem that there is any simple and universal cure -- root programs or setuid programs altering their fsuid are just too similar to the real user programs to separate them cleanly.

I see a lot of similarities with symlinks -- many programs also need to take extra care of symlinks to be safe. However, symlinks are already senior citizens of Unix systems and programs know how to cope with them since ages.

Maybe this could be taken advantage of by keeping all user mounts in a separate directory like /mnt/usr (and /mnt is very likely to be avoided by all programs traversing directory structure automatically) and symlinking from the requested mount points there (with symlinks naturally not followed by automatic traversals).

I agree it isn't a neat solution, but it seems to be the first one which is close to working.

Have a nice fortnight

Signature · 3 lines
Martin `MJ' Mares   <[email protected]>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
Lisp Users: Due to the holiday, there will be no garbage collection on Monday.
#54 lore raw
Quoted 5 lines
Quoted 4 lines

Is it possible to limit all these from kernelspace? Probably yes, although a timeout for operations is something that cuts either way. And the compexity of these checks would probably be orders of magnitude higher then the check we are currently discussing.

Quoted 7 lines

Yes ... but does the check we are discussing really solve the problem?

Let's say that you attempt to export home directories of users by a user-space NFS daemon. This daemon probably changes its fsuid to match the remote user, so the check happily accepts the access and the user is able to lock up the daemon.

Valid point. The only defense is that when a program set's fsuid, it's performing the operation "on behalf of the user". So the user is actually doing DoS against himself.

Of course this is not strictly true. E.g. in the userspace NFS case it's probably a DoS against all users of the mount.

Quoted 3 lines

It doesn't seem that there is any simple and universal cure -- root programs or setuid programs altering their fsuid are just too similar to the real user programs to separate them cleanly.

Root programs setting fsuid are relatively rare, most are suid programs originally started from the user (nfsd is an exception).

So yes the check fsuid is not the perfect solution. However let me remind you that neither is the one with private namespace.

Quoted 10 lines

I see a lot of similarities with symlinks -- many programs also need to take extra care of symlinks to be safe. However, symlinks are already senior citizens of Unix systems and programs know how to cope with them since ages.

Maybe this could be taken advantage of by keeping all user mounts in a separate directory like /mnt/usr (and /mnt is very likely to be avoided by all programs traversing directory structure automatically) and symlinking from the requested mount points there (with symlinks naturally not followed by automatic traversals).

Maybe. It would be trivial to add a config option to fuse.conf to limit user mounts to some directory.

Thanks,
Miklos

#55 lore raw

Hello!

Quoted 2 lines

So yes the check fsuid is not the perfect solution. However let me remind you that neither is the one with private namespace.

What I'm arguing about is that the fsuid check is obscure (it breaks traditional semantics of file permissions [*], it doesn't allow an user to grant access to his user mount to other users, even if the permissions allow that and so on) and it doesn't fully solve the problem anyway.

For similar reasons, I don't advocate for private namespaces either.

The cure more likely lies in simple policy rules like the "all user mounts belong to /mnt/usr" one, instead of putting dubious policy to the kernel.

Have a nice fortnight

Signature · 3 lines
Martin `MJ' Mares   <[email protected]>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
Mr. Worf, scan that ship."  "Aye, Captain... 600 DPI?
#56 lore raw
Quoted 5 lines
Quoted 2 lines

So yes the check fsuid is not the perfect solution. However let me remind you that neither is the one with private namespace.

What I'm arguing about is that the fsuid check is obscure (it breaks traditional semantics of file permissions [*],

No, the permissions are not visible to any other user. So there are no semantics to break.

Quoted 2 lines

it doesn't allow an user to grant access to his user mount to other users,

Yes, but that granting must be explicitly acknowledget by the grantee, to avoid the problems previously discussed. It's probably something possible to do with the private namespaces (sending mounts to other user's namespaces, etc)

Quoted 2 lines

even if the permissions allow that and so on) and it doesn't fully solve the problem anyway.

I think I know how to fully solve the problem. If the user has permission to ptrace the process in question then he can already do whatever he likes with that process, so userspace filesystem operation can unconditionally be allowed. Otherwise it's no-no by default.

This thread is proving to be ever more useful :) Thanks everyone!

Quoted 4 lines

For similar reasons, I don't advocate for private namespaces either.

The cure more likely lies in simple policy rules like the "all user mounts belong to /mnt/usr" one, instead of putting dubious policy to the kernel.

I'm keeping policy out of the kernel by making the check optional. Then the userspace daemon can enforce such policies as /mnt/usr.

I'll prefer the checking one, since, I'm all alone on my machine, don't want to share anything, but _do_ want to have mounts under my home directory. You prefer the /mnt/usr, since you want to share it with others. A combination is also possible: the user choses for each mount which is preferable.

Agreed?

Miklos

#57 lore raw
In reply to Miklos Szeredi

Hi!

Quoted 13 lines
Quoted 5 lines
Quoted 4 lines

Is it possible to limit all these from kernelspace? Probably yes, although a timeout for operations is something that cuts either way. And the compexity of these checks would probably be orders of magnitude higher then the check we are currently discussing.

Quoted 7 lines

Yes ... but does the check we are discussing really solve the problem?

Let's say that you attempt to export home directories of users by a user-space NFS daemon. This daemon probably changes its fsuid to match the remote user, so the check happily accepts the access and the user is able to lock up the daemon.

Quoted 6 lines

Valid point. The only defense is that when a program set's fsuid, it's performing the operation "on behalf of the user". So the user is actually doing DoS against himself.

Of course this is not strictly true. E.g. in the userspace NFS case it's probably a DoS against all users of the mount.

Exactly. So can we simply merge root-only fuse, and then worry how to make it safe with user-mounted fuse. See your own unfsd example why user-mounting is bad.

One possible solution would be to have root-owned fused that talks to user-owned fused-s and checks they are behaving correctly?

Second is somehow improving those two lines this long thread is all about...

Pavel

Signature · 1 line
64 bytes from 195.113.31.123: icmp_seq=28 ttl=51 time=448769.1 ms         
#58 lore raw
Quoted 6 lines

Exactly. So can we simply merge root-only fuse, and then worry how to make it safe with user-mounted fuse. See your own unfsd example why user-mounting is bad.

One possible solution would be to have root-owned fused that talks to user-owned fused-s and checks they are behaving correctly?

It's very hard to do that. What should be the timeout for requests, so that valid filesystems don't break, yet it's not possible to do a fairly ugly DoS? It's almost impossible I'd say.

Quoted 1 line

Second is somehow improving those two lines this long thread is all about...

That's what I did. See the recent documentation and code patches (cc-d to -fsdevel). I'm pretty convinced it's the right thing to do. OK, I was with the previous solution too, but anyway ;)

Thanks,
Miklos

#59 lore raw

Hi!

Quoted 10 lines
Quoted 6 lines

Exactly. So can we simply merge root-only fuse, and then worry how to make it safe with user-mounted fuse. See your own unfsd example why user-mounting is bad.

One possible solution would be to have root-owned fused that talks to user-owned fused-s and checks they are behaving correctly?

It's very hard to do that. What should be the timeout for requests, so that valid filesystems don't break, yet it's not possible to do a fairly ugly DoS? It's almost impossible I'd say.

You can still put those two lines into root-owned fused, where people are less likely to notice them ;-).
Pavel

Signature · 1 line
Boycott Kodak -- for their patent abuse against Java.
#60 lore raw
In reply to Lars Marowsky-Bree
Quoted 5 lines

It is certainly an information leak not otherwise available. And with the ability to change the layout underneath, you might trigger bugs in root programs: Are they really capable of seeing the same filename twice, or can you throw them into a deep recursion by simulating infinitely deep directories/circular hardlinks...?

Circular or otherwise hardlinked directories are not allowed since it would not only confuse applications but the VFS as well.

Hmm, looking at the code it seems that for some reason I removed this check from the 2.6 version of FUSE. Stupid me!

Thanks for the reminder :)

Quoted 4 lines

Certainly a useful tool for hardening applications, but I can see the point of not wanting to let unwary applications run into a namespace controlled by a user. Of course, this is sort-of similar to "find -xdev", but I'm not sure whether it is not indeed new behaviour.

A trivial DoS against any process entering the userspace filesystem is just not to answer the filesystem request.

So it's not just information leak, but also a fine way to _control_ certain behavior of applications.

Thanks,
Miklos

#61 lore raw
Quoted 19 lines · Miklos Szeredi
Quoted 5 lines

It is certainly an information leak not otherwise available. And with the ability to change the layout underneath, you might trigger bugs in root programs: Are they really capable of seeing the same filename twice, or can you throw them into a deep recursion by simulating infinitely deep directories/circular hardlinks...?

Circular or otherwise hardlinked directories are not allowed since it would not only confuse applications but the VFS as well.

Hmm, looking at the code it seems that for some reason I removed this check from the 2.6 version of FUSE. Stupid me!

Thanks for the reminder :)

Quoted 4 lines

Certainly a useful tool for hardening applications, but I can see the point of not wanting to let unwary applications run into a namespace controlled by a user. Of course, this is sort-of similar to "find -xdev", but I'm not sure whether it is not indeed new behaviour.

Quoted 6 lines

A trivial DoS against any process entering the userspace filesystem is just not to answer the filesystem request.

So it's not just information leak, but also a fine way to _control_ certain behavior of applications.

I think you need to disallow overmounts on invisible mounts by any user other than the owner. If not, some other user (including root) can overmount on your mount and the user will end up with DoS.

RP

Quoted 6 lines

Thanks,
Miklos
-
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#62 lore raw
Quoted 3 lines

I think you need to disallow overmounts on invisible mounts by any user other than the owner. If not, some other user (including root) can overmount on your mount and the user will end up with DoS.

I'm not following you here. How would an overmount cause DoS?

Thanks,
Miklos

#63 lore raw
Quoted 5 lines · Miklos Szeredi
Quoted 3 lines

I think you need to disallow overmounts on invisible mounts by any user other than the owner. If not, some other user (including root) can overmount on your mount and the user will end up with DoS.

I'm not following you here. How would an overmount cause DoS?

eg:

user 1 does a invisible mount on /mnt/mnt1
root does a visible mount on /mnt/mnt1

user 1 will no longer be able to access his /mnt/mnt1

in fact even if root mounts something on /mnt, the problem still exists.

RP

Quoted 3 lines

Thanks,
Miklos

#64 lore raw
Quoted 8 lines

eg:

user 1 does a invisible mount on /mnt/mnt1
root does a visible mount on /mnt/mnt1

user 1 will no longer be able to access his /mnt/mnt1

in fact even if root mounts something on /mnt, the problem still exists.

This is not something specific to FUSE. Root can overmount any of your directories after which you won't be able to access it (unless some of your processes have a CWD there).

Miklos

#65 lore raw
Quoted 5 lines · Miklos Szeredi
Quoted 5 lines

eg:

user 1 does a invisible mount on /mnt/mnt1
root does a visible mount on /mnt/mnt1

Quoted 7 lines
Quoted 3 lines

user 1 will no longer be able to access his /mnt/mnt1

in fact even if root mounts something on /mnt, the problem still exists.

This is not something specific to FUSE. Root can overmount any of your directories after which you won't be able to access it (unless some of your processes have a CWD there).

sorry, I think I have not raised by concern clearly.

I am mostly talking about the semantics of 'invisible/private mount' not FUSE in particular, since the kernel patch brings in new feature to VFS.

My understanding of private mount is:
1. The contents of the private mount is visible only to the mount owner.
2. The vfsmount of the private mount is only accessible to the mount owner, and only the mount owner can mount anything on top of it.

But I dont see (2) is being checked for.

I can overmount something on top of a private mount owned by someother user. I verified that with your patch.

1. do a invisible mount as user 'x' on /mnt
2. do a visible mount as root on /mnt and it *succeeds* and also masks the earlier mount to the user 'x'.

I am not concerned about the masking effect so much. But I am concerned that the private vfsmount at /mnt is accessible to someother user to mount something else on top of it. **The dentry on top of which the new vfsmount is done belongs to the private vfsmount**.

Am I making sense? If I do make sense, than all we need is a patch on top of your patch which disallows non-owner to mount something on top of a private/invisible vfsmount owned by some owner.

If I am not making sense, I keep quite :)
RP

Quoted 2 lines

Miklos

#66 lore raw
Quoted 6 lines

sorry, I think I have not raised by concern clearly.

I am mostly talking about the semantics of 'invisible/private mount' not FUSE in particular, since the kernel patch brings in new feature to VFS.

Quoted 8 lines

My understanding of private mount is:
1. The contents of the private mount is visible only to the mount owner.
2. The vfsmount of the private mount is only accessible to the mount owner, and only the mount owner can mount anything on top of it.

But I dont see (2) is being checked for.

It's automatically enforced, since the mount syscall itself will use the same path lookup mechanism as any other filesystem operation.

Quoted 6 lines

I can overmount something on top of a private mount owned by someother user. I verified that with your patch.

1. do a invisible mount as user 'x' on /mnt
2. do a visible mount as root on /mnt and it *succeeds* and also masks the earlier mount to the user 'x'.

Yes, because a later mount on a _same_ dentry will mask an earlier mount. But that does not mean, that the mount happened on the private mount's root.

You can check where the mount ended up, by having a shell of 'x' cd to the private mount. Then do the overmount. If the shell can still see the private mount, then the overmount did not in fact mount over the private root.

Quoted 3 lines

Am I making sense? If I do make sense, than all we need is a patch on top of your patch which disallows non-owner to mount something on top of a private/invisible vfsmount owned by some owner.

Yes it makes sense, but I think what you want is already the case.

Thanks,
Miklos

#67 lore raw
Quoted 25 lines · Miklos Szeredi
Quoted 6 lines

sorry, I think I have not raised by concern clearly.

I am mostly talking about the semantics of 'invisible/private mount' not FUSE in particular, since the kernel patch brings in new feature to VFS.

Quoted 8 lines

My understanding of private mount is:
1. The contents of the private mount is visible only to the mount owner.
2. The vfsmount of the private mount is only accessible to the mount owner, and only the mount owner can mount anything on top of it.

But I dont see (2) is being checked for.

It's automatically enforced, since the mount syscall itself will use the same path lookup mechanism as any other filesystem operation.

Quoted 6 lines

I can overmount something on top of a private mount owned by someother user. I verified that with your patch.

1. do a invisible mount as user 'x' on /mnt
2. do a visible mount as root on /mnt and it *succeeds* and also masks the earlier mount to the user 'x'.

Quoted 8 lines

Yes, because a later mount on a _same_ dentry will mask an earlier mount. But that does not mean, that the mount happened on the private mount's root.

You can check where the mount ended up, by having a shell of 'x' cd to the private mount. Then do the overmount. If the shell can still see the private mount, then the overmount did not in fact mount over the private root.

ok. Generally overmounts are done on the root dentry of the topmost vfsmount. But in this case, your patch mounts it on the same dentry as that of the private mount.

Essentially I was always under the assertion that 'a dentry can hold only one vfsmount'. But invisible mount seem to invalidate that assertion. Don't see any bad effects of that. Probably some VFS experts may. (or probably my assertion is wrong to begin with)

RP

#68 lore raw
Quoted 7 lines

ok. Generally overmounts are done on the root dentry of the topmost vfsmount. But in this case, your patch mounts it on the same dentry as that of the private mount.

Essentially I was always under the assertion that 'a dentry can hold only one vfsmount'. But invisible mount seem to invalidate that assertion.

You can do that without an invisible mount:

mkdir /tmp/mnt
mkdir /tmp/dir1
mkdir /tmp/dir1/subdir1
mkdir /tmp/dir2
mkdir /tmp/dir2/subdir2

cd /tmp/mnt
mount --bind /tmp/dir1 .
mount --bind /tmp/dir2 .

Now you have both /tmp/dir1 and /tmp/dir2 rooted at the same dentry.

To test this, in another shell do this just after the first bind mount:

cd /tmp/mnt

Then after the second mount do

ls -l subdir1/..

Now unmount everything and repeat the experiment, but do the mounts this way:

mount --bind /tmp/dir1 /tmp/mnt
mount --bind /tmp/dir2 /tmp/mnt

Now the second mount is an overmount of the first, and you will actually get different result from the "ls".

Playing with mounts is fun :)

Miklos

#69 lore raw
Quoted 16 lines · Miklos Szeredi
Quoted 7 lines

ok. Generally overmounts are done on the root dentry of the topmost vfsmount. But in this case, your patch mounts it on the same dentry as that of the private mount.

Essentially I was always under the assertion that 'a dentry can hold only one vfsmount'. But invisible mount seem to invalidate that assertion.

You can do that without an invisible mount:

mkdir /tmp/mnt
mkdir /tmp/dir1
mkdir /tmp/dir1/subdir1
mkdir /tmp/dir2
mkdir /tmp/dir2/subdir2

Quoted 5 lines

cd /tmp/mnt
mount --bind /tmp/dir1 .
mount --bind /tmp/dir2 .

Now you have both /tmp/dir1 and /tmp/dir2 rooted at the same dentry.

Ok. got it!. Agreed. great example!

Thanks,
RP

#70 lore raw
In reply to Ram
Quoted 43 lines · Ram
Quoted 5 lines · Miklos Szeredi
Quoted 5 lines

eg:

user 1 does a invisible mount on /mnt/mnt1
root does a visible mount on /mnt/mnt1

Quoted 7 lines
Quoted 3 lines

user 1 will no longer be able to access his /mnt/mnt1

in fact even if root mounts something on /mnt, the problem still exists.

This is not something specific to FUSE. Root can overmount any of your directories after which you won't be able to access it (unless some of your processes have a CWD there).

sorry, I think I have not raised by concern clearly.

I am mostly talking about the semantics of 'invisible/private mount' not FUSE in particular, since the kernel patch brings in new feature to VFS.

My understanding of private mount is:
1. The contents of the private mount is visible only to the mount owner.
2. The vfsmount of the private mount is only accessible to the mount owner, and only the mount owner can mount anything on top of it.

But I dont see (2) is being checked for.

I can overmount something on top of a private mount owned by someother user. I verified that with your patch.

1. do a invisible mount as user 'x' on /mnt
2. do a visible mount as root on /mnt and it *succeeds* and also masks the earlier mount to the user 'x'.

I am not concerned about the masking effect so much. But I am concerned
that the private vfsmount at /mnt is accessible to someother user to mount something else on top of it. **The dentry on top of which the new vfsmount is done belongs to the private vfsmount**.

Quoted 5 lines

Am I making sense? If I do make sense, than all we need is a patch on top of your patch which disallows non-owner to mount something on top of a private/invisible vfsmount owned by some owner.

If I am not making sense, I keep quite :)

I think you point out a solution could be worse that what it cures. There are clearly problems with mount over, but imagine that a user does an invisible mount over /mnt, doesn't that prevent other mounts which are usually made, like /mnt/cdrom, /mnt/loopN, etc?

Every time someone suggests a solution it seems to open a new path to possible abuse. And features which only work with a monotonic kernel rather than modules would seem to indicate that the feature is nice but the implementation might benefit from more thinking time.

Frankly the whole statement that the controversial code MUST go in now and could be removed later sounds like a salesman telling me I MUST sign the contract today, but he will let me out of it if I decide it was a mistake.

I'm not against the feature, but a lot of people I consider competent seem to find the implementation controversial, which argues for waiting until more eyes are on the code. If the rest of the code is useless without the controversial part, maybe it should all stay a patch to use or not as people decide.

Signature · 3 lines
   -bill davidsen ([email protected])
"The secret to procrastination is to put things off until the
 last possible moment - but no longer"  -me
#71 lore raw
Quoted 4 lines

I think you point out a solution could be worse that what it cures. There are clearly problems with mount over, but imagine that a user does an invisible mount over /mnt, doesn't that prevent other mounts which are usually made, like /mnt/cdrom, /mnt/loopN, etc?

As previously explained, user mounts are only allowed on directories for which the user has full write access. Exactly for this reason.

Quoted 4 lines

Every time someone suggests a solution it seems to open a new path to possible abuse. And features which only work with a monotonic kernel rather than modules would seem to indicate that the feature is nice but the implementation might benefit from more thinking time.

Huh? Where did modularitly come into this?

Quoted 4 lines

Frankly the whole statement that the controversial code MUST go in now and could be removed later sounds like a salesman telling me I MUST sign the contract today, but he will let me out of it if I decide it was a mistake.

The point of this thread is to find a solution to a problem. The discussion is turning up very interesting viewpoints and I'm understanding the problem better and better, and I think other people are too.

While I disagree with the view taken by Christoph H., I'm now also thankful to him for stiring up the mud, because it ended up with a lot of useful ideas.

In the end I'd like a solution that everybody is happy with. That means I'm not going to give up searching because someone said, that the current solution is crappy.

Do you understand my position?

Quoted 3 lines

I'm not against the feature, but a lot of people I consider competent seem to find the implementation controversial, which argues for waiting until more eyes are on the code.

Yes. I'm not going to ask Andrew to merge the code until I feel that everybody concerned is happy with it. No matter how many release cycles it takes.

Quoted 2 lines

If the rest of the code is useless without the controversial part, maybe it should all stay a patch to use or not as people decide.

It has been distributed separately from the kernel for 3 years now. So people _can_ try it out.

Thanks,
Miklos

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

#73 lore raw
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines

the ability to change the layout underneath, you might trigger bugs in root programs: Are they really capable of seeing the same filename twice, or can you throw them into a deep recursion by simulating infinitely deep directories/circular hardlinks...?

Circular or otherwise hardlinked directories are not allowed since it would not only confuse applications but the VFS as well.

Right, that you can catch. But can you prevent a user fs module from creating an infinitely deep directory structure out of thin air? Do you limit the maximum path length / depth?

No.

Quoted 2 lines

(Sending this privately and not to LKML, because I first wanted to check the facts ;-)

OK, CC restored. You shouldn't be afraid to send to LKML. It's the ultimate spam list ;)

Quoted 8 lines
Quoted 8 lines
Quoted 4 lines

Certainly a useful tool for hardening applications, but I can see the point of not wanting to let unwary applications run into a namespace controlled by a user. Of course, this is sort-of similar to "find -xdev", but I'm not sure whether it is not indeed new behaviour.

A trivial DoS against any process entering the userspace filesystem is just not to answer the filesystem request.

Quoted 8 lines
Quoted 2 lines

So it's not just information leak, but also a fine way to _control_ certain behavior of applications.

Yes. I first thought the check was superfluous, because hey, why shouldn't root be able to access everything... But then it struck me that that might actually be a good idea for all those reasons. root's tools don't expect that the namespace they are traversing is _completely_ controlled by a user.

Exactly.

Thanks,
Miklos

#74 lore raw
In reply to Miklos Szeredi
Quoted 11 lines · Miklos Szeredi
Quoted 9 lines
Quoted 6 lines
Quoted 3 lines

define "mount owner". Right now mount requires CAP_SYS_ADMIN which means fairly privilegued.

FUSE uses a suid root helper (as explained below). Please read the whole mail.

In that case you're totally out of luck. This is not a setup we want to account for.

Christoph, you are being thickheaded,

Not as thick as mine! Could someone please explain in small words what's wrong with an suid mount helper?

#75 lore raw
Quoted 2 lines · Andrew Morton

Not as thick as mine! Could someone please explain in small words what's wrong with an suid mount helper?

Nothing per-se. What makes it bad is the contect of a userland filesystem where the actual filesystem operations in the mounted filesystem happen in contect of a non-privilegued user.

#76 lore raw
Quoted 8 lines · Christoph Hellwig
Quoted 2 lines · Andrew Morton

Not as thick as mine! Could someone please explain in small words what's wrong with an suid mount helper?

Nothing per-se. What makes it bad is the contect of a userland filesystem where the actual filesystem operations in the mounted filesystem happen in contect of a non-privilegued user.

That's one of the major points of FUSE, isn't it? So that unprivileged users can do interesting things.

Or are you saying that that's a desirable objective, but it should be implemented differently?

#77 lore raw
Quoted 5 lines · Andrew Morton

That's one of the major points of FUSE, isn't it? So that unprivileged users can do interesting things.

Or are you saying that that's a desirable objective, but it should be implemented differently?

It's a desirable objective, but the implementation is wrong. If we have a user mount that must be known to the VFS so that the VFS can enforce the right restrictions instead of leaving various crude hacks in lowlevel filesystem drivers. Especially as fuse isn't the only filesystem for which this makes sense - smbfs or v9fs want the same features aswell

#78 lore raw
Quoted 4 lines · Christoph Hellwig
Quoted 3 lines · Andrew Morton

That's one of the major points of FUSE, isn't it? So that unprivileged users can do interesting things.

Quoted 9 lines
Quoted 2 lines

Or are you saying that that's a desirable objective, but it should be implemented differently?

It's a desirable objective, but the implementation is wrong. If we have a user mount that must be known to the VFS so that the VFS can enforce the right restrictions instead of leaving various crude hacks in lowlevel filesystem drivers. Especially as fuse isn't the only filesystem for which this makes sense - smbfs or v9fs want the same features aswell

As far as I can see, there are (at least) two distinct discussions going on. For the sake of clarity I'd like to get the security concerns/requirements laid out for each:

TYPE A) general purpose user-mountable file systems

This seems to be the feature that would be useful to many of the different file systems
(fuse, v9fs, smbfs, etc). What security restrictions need to be in place if we were to take the SYS_CAP_ADMIN check out of sys_mount?

Quoted 1 line

From what I've gleaned from the discussion so far they would include:

1) Restricting where the user could mount
- the suggestion so far is that a user could only mount/bind to a directory he could write to and without the sticky bit
2) Restricting what the user could mount
- mounting arbitrary file systems could expose a vulnerability
3) Restricting how the user can mount (nosuid, nogid enforced)
4) Restricting user mount visibility (in private namespaces) so as not to pollute the global namespace
5) Restricting how much the user can mount (restricting number of mounts and/or number of namespaces with a ulimit)

(1), (3), (4), and (5) seem straightforward to me. (2) seems a little less-so. I understand a little bit of the vulnerability (specifically when mounting physical devices with file systems that may or may not be tolerant to malicious formats), but I hate restricting the user. I guess perhaps we could have something in the file system type information which describes whether or not it should be user mountable.

Implementation wise, (3), (4), and (5) seem pretty straightforward to implement in the kernel. (1) and (2) wouldn't be that bad if the policy were kept simple, but any sort of an advanced policy would seem to require a user-space application to assist -- but that seems to require an suid mount app. Is it better to come up with a simple universal policy and implement it within VFS, or allow for a more complex policy that would require user-space application assistance?

Have I missed something from the security angle?

TYPE B) per-user namespace / attachable namespace / etc.

This argument seems to come mostly from the FUSE camp, but the goal seems noble enough: given enforcement of requiring private namespaces for user mounts in (A), how can we create a user-environment similar to what the user would expect without private mounts (ie. a global namespace per user).

The main security concern here has been stated in detail before, so I'll only summarize: only the user who mounted the file system should be granted access to it. Private namespaces in (A) seem to grant that security, however, the (B) requirement of a global user namespace invalidates that as a new login (or su) woud attatch to the private namespace (and if I'm not mistaken a root su'ing to the user would also get around the currently implemented permission scheme). I don't think anyone has come up with a good solution here.

My hack at a solution for this (even though I don't see this as a big requirement):
Proper namespace inheritance (meaning changes to the parent are propagated to the child as references not copies -- I believe the shared subtree RFC covers the right semantics) along with establishing a new private namespace for each login session. As far as accessing already mounted FUSE file systems between different login sessions -- I see this as a really obscure requirement that complicates things a great deal, however -- if you split the concept of "srv points" from file system mounts and remount the file system (perhaps automatically as part of initiating the session) for every new login -- then you can revalidate security at each of these mounts. This sounds somewhat extreme, but with a proper keyring style authentication management system it could be made fairly transparent to the user. I believe others in this thread have proposed something similar, I'm just weighing in that if this must be a requirement (and I don't think it should), this is how I think it should be done.

In general (TYPE A) and (TYPE B) are related but separate implementation efforts, I think we should focus on getting (TYPE A) right (due to the system security implications) and evolve a solution to (TYPE B) based on use.

-eric

#79 lore raw
Quoted 26 lines

TYPE A) general purpose user-mountable file systems

This seems to be the feature that would be useful to many of the different file systems
(fuse, v9fs, smbfs, etc). What security restrictions need to be in place if we were to take the SYS_CAP_ADMIN check out of sys_mount?

Quoted 1 line

From what I've gleaned from the discussion so far they would include:

1) Restricting where the user could mount
- the suggestion so far is that a user could only mount/bind to a directory he could write to and without the sticky bit
2) Restricting what the user could mount
- mounting arbitrary file systems could expose a vulnerability
3) Restricting how the user can mount (nosuid, nogid enforced)
4) Restricting user mount visibility (in private namespaces) so as not to pollute the global namespace
5) Restricting how much the user can mount (restricting number of mounts and/or number of namespaces with a ulimit)

(1), (3), (4), and (5) seem straightforward to me. (2) seems a little less-so. I understand a little bit of the vulnerability (specifically when mounting physical devices with file systems that may or may not be tolerant to malicious formats), but I hate restricting the user. I guess perhaps we could have something in the file system type information which describes whether or not it should be user mountable.

Quoted 2 lines

Implementation wise, (3), (4), and (5) seem pretty straightforward to implement in the kernel.

Umm, yes. Here's one I prepared earlier:

http://marc.theaimsgroup.com/?l=linux-fsdevel&m=107701207710525&w=2

I stopped maintaining it, because as you can see getting something accepted to mainline is not as easy as it first sounds :)

Quoted 6 lines

(1) and (2) wouldn't be that bad if the policy were kept simple, but any sort of an advanced policy would seem to require a user-space application to assist -- but that seems to require an suid mount app. Is it better to come up with a simple universal policy and implement it within VFS, or allow for a more complex policy that would require user-space application assistance?

Good question. I'm undecided on the suid/nosuid mount issue. It sure would be nicer not to need a mount helper...

Quoted 10 lines

Have I missed something from the security angle?

TYPE B) per-user namespace / attachable namespace / etc.

This argument seems to come mostly from the FUSE camp, but the goal seems noble enough: given enforcement of requiring private namespaces for user mounts in (A), how can we create a user-environment similar to what the user would expect without private mounts (ie. a global namespace per user).

Quoted 7 lines

The main security concern here has been stated in detail before, so I'll only summarize: only the user who mounted the file system should be granted access to it. Private namespaces in (A) seem to grant that security, however, the (B) requirement of a global user namespace invalidates that as a new login (or su) woud attatch to the private namespace (and if I'm not mistaken a root su'ing to the user would also get around the currently implemented permission scheme).

Note: I'm mostly concerned with system security not user security. Protecting user data from root is a treacherous thing to attempt.

Quoted 10 lines

I don't think anyone has come up with a good solution here.

My hack at a solution for this (even though I don't see this as a big requirement):
Proper namespace inheritance (meaning changes to the parent are propagated to the child as references not copies -- I believe the shared subtree RFC covers the right semantics) along with establishing a new private namespace for each login session. As far as accessing already mounted FUSE file systems between different login sessions -- I see this as a really obscure requirement

It's not that obscure. Scp, sftp each will be a separate session, and you can't set up mounts within an scp.

Quoted 5 lines

that complicates things a great deal, however -- if you split the concept of "srv points" from file system mounts and remount the file system (perhaps automatically as part of initiating the session) for every new login -- then you can revalidate security at each of these mounts.

Why would you have to revalidate? A simple bind mount would suffice. However, joining another sessions namespace makes more sense, than copying the mounts individually.

Miklos

#80 lore raw
Quoted 10 lines · Miklos Szeredi
Quoted 5 lines

that complicates things a great deal, however -- if you split the concept of "srv points" from file system mounts and remount the file system (perhaps automatically as part of initiating the session) for every new login -- then you can revalidate security at each of these mounts.

Why would you have to revalidate? A simple bind mount would suffice. However, joining another sessions namespace makes more sense, than copying the mounts individually.

Well, the forced revalidation was an attempt to protect "user-data" from root, which, as you pointed out in your reply, is a somewhat sketchy thing. It may also be useful if you wish to share a filesystem/namespace with a subset of users with a permissions model outside of the normal user/groups model (which the user doesn't really have any control over).

Anyways, just an additional idea for consideration -- as I said, I don't really feel a strong need for this, so perhaps its best forgotten for now.

-eric

#81 lore raw
In reply to Christoph Hellwig
Quoted 2 lines · Andrew Morton
Quoted 1 line

Not as thick as mine! Could someone please explain in small words

what's

Quoted 3 lines
Quoted 1 line

wrong with an suid mount helper?

Nothing per-se. What makes it bad is the context of a userland

filesystem

Quoted 2 lines

where the actual filesystem operations in the mounted filesystem happen in context of a non-privileged user.

How did the fact that the file access system calls involve user-controlled code come into this? I thought the FUSE kernel code already shielded the system from said code to everyone's satisfaction.

We've been talking, rather, about the namespace changes. The exact same issue exists with a non-userspace filesystem where the user controls the filesystem contents. For example, a filesystem on a user-supplied CD. A system administrator -- personally or through his setuid proxy -- might want to mount this CD for the benefit of some users/processes/whatever but not add it to the global namespace.

The issue of private mounts (mount = namespace change) would be good to resolve separately from any problem with bringing user space code into the kernel.

BTW, since Miklos said "mount helper" and others have said "mount wrapper," I think some of us may not be familiar with mount helpers. It's irrelevant to this discussion, but: util-linux 'mount' has a little-known feature wherein it can run a filesystem-type-specific program in a child process to do some of the mount function. A "mount wrapper" would be the opposite -- a filesystem-type-specific program that runs the generic 'mount' program in a child process.

--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems

#82 lore raw
In reply to Miklos Szeredi

Hello!

Quoted 2 lines

- mount owner should not get illegitimate access to information from other users' and the super user's processes

[...]

Quoted 2 lines

3) any process running with fsuid different from the owner is denied all access to the filesystem

This smells. Denying access to root doesn't make any sense. I agree that it could help in some corner cases (like avoiding automated backup from backing up user filesystems), but in the end it's going to be an annoyance.

Per-user namespaces (set up by PAM) look as a very reasonable solution.

Have a nice fortnight

Signature · 3 lines
Martin `MJ' Mares   <[email protected]>   http://atrey.karlin.mff.cuni.cz/~mj/
Faculty of Math and Physics, Charles University, Prague, Czech Rep., Earth
"A semicolon. Another line ends in the dance of camel." -- Kabir Ahuja
#84 lore raw
Quoted 6 lines · Bryan Henderson
Quoted 2 lines

mknamespace -p users/$UID # (like mkdir -p)
setnamespace users/$UID # (like cd)

       ^^^^^^^^

You realize that 'cd' is a shell command, and has to be, I hope. That little fact has thrown a wrench into many of the ideas in this thread.

You don't want to have such command, really! What you want is a PAM module, that looks whether there is already a session for that user and switches to it's namespace, if it does. Remember that it's namespace
- it can be first created, then attached and then populated with mounts.

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

#85 lore raw
In reply to Bryan Henderson
Quoted 6 lines · Bryan Henderson
Quoted 2 lines

mknamespace -p users/$UID # (like mkdir -p)
setnamespace users/$UID # (like cd)

       ^^^^^^^^

You realize that 'cd' is a shell command, and has to be, I hope. That little fact has thrown a wrench into many of the ideas in this thread.

I suppose it will be called by the login process or by wrappers like 'nice'.

Signature · 2 lines
Never stand when you can sit, never sit when you can lie down, never stay
awake when you can sleep.
#86 lore raw
Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

mknamespace -p users/$UID # (like mkdir -p)
setnamespace users/$UID # (like cd)

                              ^^^^^^^^

You realize that 'cd' is a shell command, and has to be, I hope. That little fact has thrown a wrench into many of the ideas in this thread.

I suppose it will be called by the login process or by wrappers like 'nice'.

Just to be clear, then: this idea is fundamentally different from the mkdir/cd analogy the thread starts with above. And it misses one rather important requirement compared to mkdir/cd: You can't add a new mount to an existing shell.

Several more complicated schemes that may achieve that are being discussed in this thread.

--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems

author NAK
#87 lore raw
Quoted 4 lines · Bryan Henderson
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

mknamespace -p users/$UID # (like mkdir -p)
setnamespace users/$UID # (like cd)

                              ^^^^^^^^
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

You realize that 'cd' is a shell command, and has to be, I hope. That little fact has thrown a wrench into many of the ideas in this thread.

I suppose it will be called by the login process or by wrappers like 'nice'.

Just to be clear, then: this idea is fundamentally different from the mkdir/cd analogy the thread starts with above.

NACK, it's very similar to the cd "$HOME" (or ulimit calls) done by the login mechanism, except for the fact that no shell does implement a setnamespace command and therefore can't leave that namespace. If the shell were actually modified to implement setnamespace, that command would be exactly like the cd command.

The wrapper I mentioned will usurally not be needed for normal operation, but if users want additional private namespaces, they'll need this seperate wrapper (or to modify the application or the shell) in order to switch into them.

Quoted 3 lines

And it misses one rather
important requirement compared to mkdir/cd: You can't add a new mount to an existing shell.

The mount would be a part of the current namespace, which is shared across all current user processes unless they are started without login (e.g. procmail[0]) or running in a different namespace (the user called setnamespace).

[0] If you want procmail in a user namespace, use a wrapper like ---/usr/bin/procmail---
#!/bin/sh
exec /usr/bin/setnamespace /users/"$UID" -- /usr/bin/procmail.bin "$@"
---

BTW: I think the namespaces will need the normal file permissions.

Signature · 3 lines
Fun things to slip into your budget
Paradigm pro-activator (a whole pack)
	(you mean beer?)
#88 lore raw
Quoted 5 lines
Quoted 2 lines

Just to be clear, then: this idea is fundamentally different from the mkdir/cd analogy the thread starts with above.

NACK, it's very similar to the cd "$HOME" (or ulimit calls) done by the login mechanism,

That's not a NACK. The cd "$HOME" and ulimit calls done by the login process (more precisely, by a shell profile) are quite different from the mkdir/cd the thread started with. Who creates a new directory in his shell profile? I assume the mkdir/cd analogy is a case of a person doing a mkdir and cd in a running shell. (That is indeed analogous to what one would like to do with a private mount).

When you said "by the login process or by wrappers like nice," in response to my pointing out that setnamespace would need to be a shell builtin command, I assumed you were talking about putting it in the code that execs the shell as opposed to in the shell profile, thus eliminating the need for a shell builtin.

But the important thing is just to recognize, as you say explicitly now, that setnamespace has to be shell builtin command for setnamespace/mknamespace to be analogous to mkdir/cd. That was my original statement, if somewhat indirect:

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 2 lines

mknamespace -p users/$UID # (like mkdir -p)
setnamespace users/$UID # (like cd)

                              ^^^^^^^^

You realize that 'cd' is a shell command, and has to be, I hope.

That

Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

little fact has thrown a wrench into many of the ideas in this

thread.

--
Bryan Henderson IBM Almaden Research Center
San Jose CA Filesystems

#89 lore raw
Quoted 10 lines · Bryan Henderson
Quoted 5 lines
Quoted 2 lines

Just to be clear, then: this idea is fundamentally different from the mkdir/cd analogy the thread starts with above.

NACK, it's very similar to the cd "$HOME" (or ulimit calls) done by the login mechanism,

That's not a NACK. The cd "$HOME" and ulimit calls done by the login process (more precisely, by a shell profile) are quite different from the mkdir/cd the thread started with. Who creates a new directory in his shell profile?

I create a directory in /tmp and set $TMP to that directory, because I can't just mount a private tmpfs. But that's another topic.

Quoted 3 lines

I assume the mkdir/cd analogy is a case of a person doing
a mkdir and cd in a running shell. (That is indeed analogous to what one would like to do with a private mount).

ACK, with respect to lifetime and processes affected, it will be exactly like creating/using a directory in a tmpfs. But as you noticed, you'd need the shell builtin command to make this analogy complete. That's not going to happen, but it's not needed for operation.

Quoted 5 lines

When you said "by the login process or by wrappers like nice," in response to my pointing out that setnamespace would need to be a shell builtin command, I assumed you were talking about putting it in the code that execs the shell as opposed to in the shell profile, thus eliminating the need for a shell builtin.

Exactly. You can't patch all login daemons, so you'll need pam to do the initial setup.

After that, the users may decide to ignore having a private namespace (it will just DTRT), or they can decide to use that feature to lock in some of their programs. Obviously pam won't allow private sub-namespaces at random times, while the general system call would support this, and their shell won't do that, too. In the same way you'll need a wrapper like "#!/bin/sh cd $dir&&exec $prog" for doing the initial chdir on behalf of chdir-ignorant programs, you'll need a wrapper for setnamespace-ignorant programs. The only difference is that chdir-ignorant programs are rare.

Quoted 4 lines

But the important thing is just to recognize, as you say explicitly now, that setnamespace has to be shell builtin command for setnamespace/mknamespace to be analogous to mkdir/cd. That was my original statement, if somewhat indirect:

For the analogy yes, for usage no.

Signature · 1 line
The secret of the universe is #@*%! NO CARRIER 
#90 lore raw
In reply to Bodo Eggert <[email protected]>
Quoted 1 line · Bodo Eggert

Use a daemon to keep an additional reference to the namespace? That's UGLY.

Why not? There's a daemon already: the FUSE daemon. It's an ideal candidate for passing out the information about the mounts it's involved in.

-- Jamie

#91 lore raw
In reply to Bodo Eggert <[email protected]>
Quoted 3 lines · Bodo Eggert
Quoted 1 line · Jan Hudec

On Mon, Apr 25, 2005 at 11:58:50 +0200, Miklos Szeredi wrote:

Use a daemon to keep an additional reference to the namespace? That's UGLY.

It's as ugly as ssh-agent.

But I have to say, that I really like attachable namespaces bettern than descriptor mount bind. It's a hell lot simpler to work with.

Quoted 4 lines

With attachable namespaces, the whole thing should be as simple as (pseudocode)
mknamespace -p users/$UID # (like mkdir -p)
setnamespace users/$UID # (like cd)

Well, yes and no. We should probably just have a syscall int join_namespace(pid_t pid)
which would join the namespace process pid uses. And then have a PAM session module, that would attach the namespace of the first user's session (creating new namespace if this is the first session).

Quoted 3 lines

Optionally, the namespaces and their private mounts might be scheduled to be removed if the last user is gone, or they need to be persistent, depending on the applicaton (e.g. ssh used as rexec or shared mounts).

I'd have them garbage-collected. When last process using them goes away, so does the namespace. If that's not what you want, start a persistent process for the user.

-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <[email protected]>

#92 lore raw
Quoted 7 lines · Jan Hudec
Quoted 4 lines · Bodo Eggert

With attachable namespaces, the whole thing should be as simple as (pseudocode)
mknamespace -p users/$UID # (like mkdir -p)
setnamespace users/$UID # (like cd)

Quoted 5 lines

Well, yes and no. We should probably just have a syscall int join_namespace(pid_t pid)
which would join the namespace process pid uses. And then have a PAM session module, that would attach the namespace of the first user's session (creating new namespace if this is the first session).

This will help for the fuse case, but since namespaces are hierarchical (as I understand them), you can as well make the structure visible and thereby turn a feature for one user into a feature for general use.

Signature · 1 line
Programming is an art form that fights back.