[CRIU] [RFC PATCH 3/5] cr-restore: restore root sid before mount namespace
Stanislav Kinsburskiy
skinsbursky at odin.com
Thu Nov 26 03:16:09 PST 2015
23.11.2015 20:22, Pavel Emelyanov пишет:
>
>> 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?
Making process a session leader makes it a group leader.
While restoring process group leader before session leads to session
restore failure, because of the following hunk:
SYSCALL_DEFINE0(setsid)
{
struct task_struct *group_leader = current->group_leader;
struct pid *sid = task_pid(group_leader);
pid_t session = pid_vnr(sid);
int err = -EPERM;
<snip>
/* Fail if a process group id already exists that equals the
* proposed session id.
*/
if (pid_task(sid, PIDTYPE_PGID))
goto out;
<snip>
out:
<snip>
return err;
}
More information about the CRIU
mailing list