[CRIU] [RFC PATCH 3/5] cr-restore: restore root sid before mount namespace
Stanislav Kinsburskiу
skinsbursky at odin.com
Mon Nov 23 12:37:31 PST 2015
23 нояб. 2015 г. 20:22 пользователь Pavel Emelyanov <xemul at parallels.com> написал:
>
> On 11/23/2015 08:22 PM, Stanislav Kinsburskiy wrote:
> > This is a precursor patch for AutoFS mount restore.
> > To restore AutoFS-nested mount points, we have to created target dentries.
> > To be able to do so, the process have to be process group leader before AutoFS
> > mount is called.
>
> Where does this requirement come from?
>
It's a way, how kernel restricts autofs management. Kernel doesn't mount anything. It passes request via pipe to user space process instead. Only process, which pgrp is set as a mount property, can create dentries on AutoFS mount.
> > Note: there is another way, how to set process as a group leader. We can fork
> > a child with CLONE_VM, and use it to mount all the mount points.
> >
> > Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
> > ---
> > cr-restore.c | 8 +++++++-
> > 1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/cr-restore.c b/cr-restore.c
> > index 06fceb6..9aec077 100644
> > --- a/cr-restore.c
> > +++ b/cr-restore.c
> > @@ -1441,7 +1441,10 @@ static int create_children_and_session(void)
> > return ret;
> > }
> >
> > - restore_sid();
> > + if (getpid() == 1)
> > + pr_info("Skipping restore_sid() for init\n");
> > + else
> > + restore_sid();
> >
> > pr_info("Restoring children in our session:\n");
> > list_for_each_entry(child, ¤t->children, sibling) {
> > @@ -1524,6 +1527,9 @@ static int restore_task_with_children(void *_arg)
> > if (restore_finish_stage(CR_STATE_RESTORE_NS) < 0)
> > goto err;
> >
> > + pr_info("Calling restore_sid() for init\n");
> > + restore_sid();
>
> In the patch comment you say that process has to be group leader, but
> make it session leader instead. Why?
>
I'll check for the proper explanation tommorow. Setting it as a group leader before setting as a session leader doesn't. While setting as a session leader is enough.
> > +
> > /*
> > * We need non /proc proc mount for restoring pid and mount
> > * namespaces and do not care for the rest of the cases.
> >
> > _______________________________________________
> > CRIU mailing list
> > CRIU at openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu
> > .
> >
>
More information about the CRIU
mailing list