Skip to contentSkip to conversation

RFC [patch 00/34] PID Virtualization Overview

DISCUSSION Serge Hallyn 16 participants 136 messages Jan 17, 2006 – Feb 6, 2006 2 messages not in the archive Page 2 of 2

Subsystems (70)
lore
Share & tools
lore
#123 lore raw
In reply to Alan Cox
Quoted 9 lines · Alan Cox
Quoted 4 lines · Dave Hansen

But, it seems that many drivers like to print out pids as a unique identifier for the task. Should we just let them print those potentially non-unique identifiers, deprecate and kill them, or provide a replacement with something else which is truly unique?

Pick a format for container number + pid and document/stick with it - something like container::pid (eg 0::114) or 114[0] whatever so long as it is consistent

having a pid_to_string(<task struct>) or maybe task_to_string() thing for convenient printing of pids/tasks.. I'm all for that. Means you can even configure how verbose you want it to be (include ->comm or not, ->state maybe etc)

#124 lore raw
Quoted 7 lines · Arjan van de Ven
Quoted 6 lines · Alan Cox
Quoted 4 lines · Dave Hansen

But, it seems that many drivers like to print out pids as a unique identifier for the task. Should we just let them print those potentially non-unique identifiers, deprecate and kill them, or provide a replacement with something else which is truly unique?

Quoted 8 lines
Quoted 3 lines

Pick a format for container number + pid and document/stick with it - something like container::pid (eg 0::114) or 114[0] whatever so long as it is consistent

having a pid_to_string(<task struct>) or maybe task_to_string() thing for convenient printing of pids/tasks.. I'm all for that. Means you can even configure how verbose you want it to be (include ->comm or not, ->state maybe etc)

The only way I can see to sanely do this is to pass it the temporary buffer it writes it's contents into.
Something like:
printk(KERN_XXX "%s\n", task_to_string(buf, tsk)); ?

Eric

#125 lore raw
Quoted 18 lines · Eric W. Biederman
Quoted 7 lines · Arjan van de Ven
Quoted 6 lines · Alan Cox
Quoted 4 lines · Dave Hansen

But, it seems that many drivers like to print out pids as a unique identifier for the task. Should we just let them print those potentially non-unique identifiers, deprecate and kill them, or provide a replacement with something else which is truly unique?

Quoted 8 lines
Quoted 3 lines

Pick a format for container number + pid and document/stick with it - something like container::pid (eg 0::114) or 114[0] whatever so long as it is consistent

having a pid_to_string(<task struct>) or maybe task_to_string() thing for convenient printing of pids/tasks.. I'm all for that. Means you can even configure how verbose you want it to be (include ->comm or not, ->state maybe etc)

Quoted 4 lines

The only way I can see to sanely do this is to pass it the temporary buffer it writes it's contents into.
Something like:
printk(KERN_XXX "%s\n", task_to_string(buf, tsk)); ?

That's kind of neat :)

The only other thing I can think of is to do something like

#define task_str(tsk) tsk->container_id, tsk->pid or
#define task_str(tsk) tsk->container_id, ":", tsk->pid

and have it be used as

printk(KERN_XXX "%s::%s\n", task_str(tsk));
or
printk(KERN_XXX "%s%s%s\n", task_str(tsk));

The only reason I point it out is that we don't risk memory corruption if the printk caller forgets to give the extra '%s's, like we do if the caller forgets they need char buf[PID_CONTAINER_MAXLENGTH] instead of 'char *buf;' or 'char buf;'.

-serge

#126 lore raw
Quoted 43 lines · Serge E. Hallyn
Quoted 21 lines · Eric W. Biederman
Quoted 9 lines · Arjan van de Ven
Quoted 7 lines · Alan Cox
Quoted 4 lines · Dave Hansen

But, it seems that many drivers like to print out pids as a unique identifier for the task. Should we just let them print those potentially non-unique identifiers, deprecate and kill them, or provide a replacement with something else which is truly unique?

Quoted 8 lines
Quoted 3 lines

Pick a format for container number + pid and document/stick with it - something like container::pid (eg 0::114) or 114[0] whatever so long as it is consistent

having a pid_to_string(<task struct>) or maybe task_to_string() thing for convenient printing of pids/tasks.. I'm all for that. Means you can even configure how verbose you want it to be (include ->comm or not, ->state maybe etc)

Quoted 4 lines

The only way I can see to sanely do this is to pass it the temporary buffer it writes it's contents into.
Something like:
printk(KERN_XXX "%s\n", task_to_string(buf, tsk)); ?

That's kind of neat :)

The only other thing I can think of is to do something like

#define task_str(tsk) tsk->container_id, tsk->pid or
#define task_str(tsk) tsk->container_id, ":", tsk->pid

and have it be used as

printk(KERN_XXX "%s::%s\n", task_str(tsk));
or
printk(KERN_XXX "%s%s%s\n", task_str(tsk));

Quoted 7 lines

The only reason I point it out is that we don't risk memory corruption if the printk caller forgets to give the extra '%s's, like we do if the caller forgets they need char buf[PID_CONTAINER_MAXLENGTH] instead of 'char *buf;' or 'char buf;'.

-serge

As odd as this looks .. it does have the benefits and anything that avoids potential problems.

On the other hand you might run into problems with the following.

		char *str = task_str(tsk);

Eitherway .. I don't think these are the big fish to fry now :-)

-- Hubertus

#127 lore raw
Quoted 8 lines · Hubertus Franke

As odd as this looks .. it does have the benefits and anything that avoids potential problems.

On the other hand you might run into problems with the following.

		char *str = task_str(tsk);

Eitherway .. I don't think these are the big fish to fry now :-)

Except there are really no small fish :)

This solves the one really ugly part of my current patch, that I had simply not thought through.

There is already something similar for paths in the fs namespace.

char * d_path(struct dentry *dentry, struct vfsmount *vfsmnt,

				char *buf, int buflen);

Which does exactly this.

Now frequently it is passed in a page sized buffer so it's not quite the same but close enough.

Eric

#128 lore raw

RFC: Multiple instances of kernel namespaces.

In reply to Alan Cox

At this point I have to confess I have been working on something similar, to IBM's pid virtualization work. But I have what is at least for me a unifying concept, that makes things easier to think about.

The idea is to think about things in terms of namespaces. Currently in the kernel we have the fs/mount namespace already implemented.

Partly this helps on what the interface for creating a new namespace instance should be. 'clone(CLONE_NEW<NAMESPACE_TYPE>)', and how it should be managed from the kernel data structures.

Partly thinking of things as namespaces helps me scope the problem.

Does this sound like a sane approach?

Eric

#129 lore raw

Re: RFC: Multiple instances of kernel namespaces.

Quoted 9 lines · Eric W. Biederman

At this point I have to confess I have been working on something similar, to IBM's pid virtualization work. But I have what is at least for me a unifying concept, that makes things easier to think about.

The idea is to think about things in terms of namespaces. Currently in the kernel we have the fs/mount namespace already implemented.

Quoted 7 lines

Partly this helps on what the interface for creating a new namespace instance should be. 'clone(CLONE_NEW<NAMESPACE_TYPE>)', and how it should be managed from the kernel data structures.

Partly thinking of things as namespaces helps me scope the problem.

Does this sound like a sane approach?

And a bonus of this is that for security and vserver-type applications, the CLONE_NEWPID and CLONE_NEWFS will often happen at the same time.

How do you (or do you?) address naming namespaces? This would be necessary for transitioning into an existing namespace, performing actions on existing namespaces (i.e. checkpoint, migrate to another machine, enter the namespace and kill pid 521), and would just be useful for accounting purposes, i.e. how else do you have a "ps --all-namespaces" specify a process' namespace?

Doubt we want to add an argument to clone(), so do we just add a new proc, sysfs, or syscall for setting a pid-namespace name?

Do we need a new syscall for transitioning into an existing namespace?

thanks,
-serge

#130 lore raw

Re: RFC: Multiple instances of kernel namespaces.

Quoted 29 lines · Serge E. Hallyn
Quoted 8 lines · Eric W. Biederman

At this point I have to confess I have been working on something similar, to IBM's pid virtualization work. But I have what is at least for me a unifying concept, that makes things easier to think about.

The idea is to think about things in terms of namespaces. Currently in the kernel we have the fs/mount namespace already implemented.

Quoted 7 lines

Partly this helps on what the interface for creating a new namespace instance should be. 'clone(CLONE_NEW<NAMESPACE_TYPE>)', and how it should be managed from the kernel data structures.

Partly thinking of things as namespaces helps me scope the problem.

Does this sound like a sane approach?

And a bonus of this is that for security and vserver-type applications, the CLONE_NEWPID and CLONE_NEWFS will often happen at the same time.

How do you (or do you?) address naming namespaces? This would be necessary for transitioning into an existing namespace, performing actions on existing namespaces (i.e. checkpoint, migrate to another machine, enter the namespace and kill pid 521), and would just be useful for accounting purposes, i.e. how else do you have a "ps --all-namespaces" specify a process' namespace?

Quoted 8 lines

Doubt we want to add an argument to clone(), so do we just add a new proc, sysfs, or syscall for setting a pid-namespace name?

Do we need a new syscall for transitioning into an existing namespace?

thanks,
-serge

Just addressed a few of this in my previous reply to the other thread.

However, question here is whether the container (as we used it) provides the "binding" object for these clones. One question for me then is whether cloning of namespaces is always done in tandem.
As you are bringing the migration up, we can only clone fully contained namespaces ! One could make that a condition of the migration or build it right into the initial structure. Any thoughts on that ?

-- Hubertus

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

#132 lore raw

Re: RFC: Multiple instances of kernel namespaces.

Quoted 8 lines · Serge E. Hallyn
Quoted 3 lines · Hubertus Franke

However, question here is whether the container (as we used it) provides the "binding" object for these clones. One question for me then is whether cloning of namespaces is always done in tandem.

No.

Thought so..

Quoted 7 lines
Quoted 3 lines

As you are bringing the migration up, we can only clone fully contained

By clone do you actually mean clone(), or did you mean restart from checkpoint?

clone_<namespace> , so its neither nor ...
Essentially creating a new namespace ! That's what Eric was suggesting.

Quoted 10 lines

If clone, then I don't understand the problem.

If restart from checkpoint/migrate, then I think the answer has to be that that is a special case which we have to handle. Note that to clone a fs namespace, you need CAP_SYS_ADMIN. We could add another check in there to deny CLONE_NEWNS when CLONE_NEWPID is not specified IF and ONLY IF we are already no longer in container_id==0. Or even better, when a pid-namespace has been designated as migrateable.

Quoted 2 lines

Anything other than that would be too limiting. Note that fs namespaces are going to be used for multi-level directories, for instance.

That's a reasonable approach. Give the general capability (since C/R + migration is an additional capability that might not be utilized by many) and leave it to the sys_admin to specify what is allowed or not

Quoted 4 lines
Quoted 3 lines

namespaces ! One could make that a condition of the migration or build it right into the initial structure. Any thoughts on that ?

Quoted 10 lines

So in other words I'm saying that this is the admin/user's problem to keep straight. Dealing with fs-namespaces in this sense could perhaps be dealt with later by hand in checkpoint/migrate/restore code by
a) at checkpoint:
i) checking the fs-namespace of each process or thread ii) storing /proc/mounts for each fs-namespace
b) at restore, do CLONE_NEWNS for each process which needs it, and using the stored /proc/mounts to rebuild the namespace.

Something like it .. yes...

Quoted 5 lines

Of course /proc mounts is itself relative to a namespace in the case of bind mounts, so I'm actually not sure this is feasible.

-serge

#133 lore raw

Re: RFC: Multiple instances of kernel namespaces.

In reply to Serge E. Hallyn
Quoted 21 lines · Serge E. Hallyn
Quoted 9 lines · Eric W. Biederman

At this point I have to confess I have been working on something similar, to IBM's pid virtualization work. But I have what is at least for me a unifying concept, that makes things easier to think about.

The idea is to think about things in terms of namespaces. Currently in the kernel we have the fs/mount namespace already implemented.

Quoted 7 lines

Partly this helps on what the interface for creating a new namespace instance should be. 'clone(CLONE_NEW<NAMESPACE_TYPE>)', and how it should be managed from the kernel data structures.

Partly thinking of things as namespaces helps me scope the problem.

Does this sound like a sane approach?

And a bonus of this is that for security and vserver-type applications, the CLONE_NEWPID and CLONE_NEWFS will often happen at the same time.

Quoted 6 lines

How do you (or do you?) address naming namespaces? This would be necessary for transitioning into an existing namespace, performing actions on existing namespaces (i.e. checkpoint, migrate to another machine, enter the namespace and kill pid 521), and would just be useful for accounting purposes, i.e. how else do you have a "ps --all-namespaces" specify a process' namespace?

So I address naming indirectly. The last thing I want to have is to add yet another namespace to the kernel for naming namespaces. We have enough namespaces already.

In any sane context for a pid-namespace we need a pid that we can call waitpid on, so we don't break the process tree. Which means at least the init process has 2 pids, one that it's parent sees, and another (1) that it and it's children see.

So I name pidspaces like we do sessions of process groups and sessions by the pid of the leader.

So in the simple case I have names like:
1178/1632

Quoted 2 lines

Doubt we want to add an argument to clone(), so do we just add a new proc, sysfs, or syscall for setting a pid-namespace name?

That shouldn't be necessary.

Quoted 1 line

Do we need a new syscall for transitioning into an existing namespace?

That is a good question. The FS namespaces that we already have has much the same problem. A completely different solution to this problem seems to have been implemented but I don't grasp it yet.

Inherently transitioning to an existing namespace is something that is straight forward to implement, so it is worth thinking about.

If I want a guest that can keep secrets from the host sysadmin I don't want transitioning into a guest namespace to come too easily.

Currently I can always just create an extra child of pid 1 that I will be my slave. The problem is that this is an extra process laying around.

Eric

#134 lore raw

Re: RFC: Multiple instances of kernel namespaces.

Quoted 40 lines · Eric W. Biederman
Quoted 21 lines · Serge E. Hallyn
Quoted 9 lines · Eric W. Biederman

At this point I have to confess I have been working on something similar, to IBM's pid virtualization work. But I have what is at least for me a unifying concept, that makes things easier to think about.

The idea is to think about things in terms of namespaces. Currently in the kernel we have the fs/mount namespace already implemented.

Quoted 7 lines

Partly this helps on what the interface for creating a new namespace instance should be. 'clone(CLONE_NEW<NAMESPACE_TYPE>)', and how it should be managed from the kernel data structures.

Partly thinking of things as namespaces helps me scope the problem.

Does this sound like a sane approach?

And a bonus of this is that for security and vserver-type applications, the CLONE_NEWPID and CLONE_NEWFS will often happen at the same time.

Quoted 6 lines

How do you (or do you?) address naming namespaces? This would be necessary for transitioning into an existing namespace, performing actions on existing namespaces (i.e. checkpoint, migrate to another machine, enter the namespace and kill pid 521), and would just be useful for accounting purposes, i.e. how else do you have a "ps --all-namespaces" specify a process' namespace?

So I address naming indirectly. The last thing I want to have is to add yet another namespace to the kernel for naming namespaces. We have enough namespaces already.

In any sane context for a pid-namespace we need a pid that we can call waitpid on, so we don't break the process tree. Which means at least the init process has 2 pids, one that it's parent sees, and another (1) that it and it's children see.

Quoted 5 lines

So I name pidspaces like we do sessions of process groups and sessions by the pid of the leader.

So in the simple case I have names like:
1178/1632

which is a new namespace in itself, but it doesn't matter as long as it uniquely and persistently identifies the namespace for the time it exists ... just leaves the question how to retrieve a list of all namespaces :)

Quoted 12 lines
Quoted 2 lines

Doubt we want to add an argument to clone(), so do we just add a new proc, sysfs, or syscall for setting a pid-namespace name?

That shouldn't be necessary.

Quoted 1 line

Do we need a new syscall for transitioning into an existing namespace?

That is a good question. The FS namespaces that we already have has much the same problem. A completely different solution to this problem seems to have been implemented but I don't grasp it yet.

Quoted 6 lines

Inherently transitioning to an existing namespace is something that is straight forward to implement, so it is worth thinking about.

If I want a guest that can keep secrets from the host sysadmin I don't want transitioning into a guest namespace to come too easily.

which can easily be achieved by 'marking' the namespace as private and/or applying certain rules/checks to the 'enter' procedure ...

best,
Herbert

Quoted 10 lines

Currently I can always just create an extra child of pid 1 that I will be my slave. The problem is that this is an extra process laying around.

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#135 lore raw

Re: RFC: Multiple instances of kernel namespaces.

Quoted 8 lines · Herbert Poetzl
Quoted 2 lines · Eric W. Biederman

So in the simple case I have names like:
1178/1632

which is a new namespace in itself, but it doesn't matter as long as it uniquely and persistently identifies the namespace for the time it exists ... just leaves the question how to retrieve a list of all namespaces :)

Yes but the name of the namespace is still in the original pid namespace. And more importantly to me it isn't a new kind of namespace.

Quoted 6 lines
Quoted 2 lines

If I want a guest that can keep secrets from the host sysadmin I don't want transitioning into a guest namespace to come too easily.

which can easily be achieved by 'marking' the namespace as private and/or applying certain rules/checks to the 'enter' procedure ...

Right. The trick here is that you must be able to deny transitioning into a namespace from the inside the namespace. Or else a guest could never trust it. Something one of my coworkers pointed out to me.

Eric

#136 lore raw

Re: RFC: Multiple instances of kernel namespaces.

Quoted 17 lines · Eric W. Biederman
Quoted 8 lines · Herbert Poetzl
Quoted 2 lines · Eric W. Biederman

So in the simple case I have names like:
1178/1632

which is a new namespace in itself, but it doesn't matter as long as it uniquely and persistently identifies the namespace for the time it exists ... just leaves the question how to retrieve a list of all namespaces :)

Yes but the name of the namespace is still in the original pid namespace. And more importantly to me it isn't a new kind of namespace.

Quoted 3 lines
Quoted 2 lines

If I want a guest that can keep secrets from the host sysadmin I don't want transitioning into a guest namespace to come too easily.

Quoted 8 lines
Quoted 3 lines

which can easily be achieved by 'marking' the namespace as private and/or applying certain rules/checks to the 'enter' procedure ...

Right. The trick here is that you must be able to deny transitioning into a namespace from the inside the namespace. Or else a guest could never trust it. Something one of my coworkers pointed out to me.

not necessarily, for example have a 'private' flag, which can only be set once (usually from outside), ensuring that the namespace will not be entered. this flag could be checked from inside ...

best,
Herbert

Quoted 6 lines

Eric
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#137 lore raw
In reply to Dave Hansen
Quoted 19 lines · Dave Hansen
Quoted 11 lines · Alan Cox
Quoted 4 lines · Dave Hansen

You do assign new pids, at least as far as the kernel is concerned. However, any processes that continue to run would get confused if their pid changed. You have to make sure that the tasks have a _consistent_ view of which process is which pid.

Don't reassign the pid at all. Keep task->container and do the job explicitly. Most task searches for a pid are abstracted already and most users of ->pid who try and use it for comparing two tasks for equality or for keeping a task reference are already terminally racey and want fixing anyway.

Other than searches, there appear to be quite a number of drivers an subsystems that like to print out pids. I can't find any cases yet where these are integral to functionality, but I wonder what approach we should take. Should we deprecate printk'ing of pids? Make a special function or % modifier to turn a task_struct into something printable?

Quoted 4 lines

A function would run into issues of having buffers in which to print the output. But, we'd be able to do things like:

	sprintf(buffer, "%d:%d", tsk->container, tsk->pid);

What about first fixing all the driver to print_task() or something like that, where print_task would print name too (for example). That way, we get more useful data *now* and you can fix it any way you want in future.

char *print_task() doing pretty-printing should be enough.
Pavel

Signature · 1 line
Thanks, Sharp!