All of lore.kernel.org
 help / color / mirror / Atom feed
* Mapping between host & container PIDs ?
@ 2012-11-27 10:15 Daniel P. Berrange
       [not found] ` <20121127101555.GE24370-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel P. Berrange @ 2012-11-27 10:15 UTC (permalink / raw)
  To: Linux Containers

I'm trying to find out if there is a way to map between host and container
PIDs, at minimum in the host -> container direction. My use case is to be
able to kill processes associated with a container, based on the host PID,
in a race free manner.

Given a host PID, I can read the 'tasks' file for the container's cgroup
to verify that the PID is associated with the container in question. Then
I can kill the PID with a signal. There is a small race condition in there,
where the PID could die & a new process could be born using the original
PID. Now this might not be very likely but I was thinking that if it is
possible to map from a host PID to a container PID, you can do it more
safely. eg Lookup the container PID associted with the host PID, then
setns() into the container and kill the container PID. Now although there
is still a race condition, you are guaranteed that if the race hits you'll
only kill a process within the same container, not the host at large,
which is good when the user invoking the API is unprivileged.

Daniel
-- 
|: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org              -o-             http://virt-manager.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

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

end of thread, other threads:[~2012-11-30  0:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-27 10:15 Mapping between host & container PIDs ? Daniel P. Berrange
     [not found] ` <20121127101555.GE24370-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-11-27 13:36   ` Serge Hallyn
2012-11-27 13:47     ` Daniel P. Berrange
     [not found]       ` <20121127134759.GL24370-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-11-27 21:49         ` Eric W. Biederman
2012-11-27 13:50     ` Eric W. Biederman
     [not found]       ` <87vccrm9xw.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2012-11-30  0:43         ` Matt Helsley

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.