mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
pstree: improve id intersection detection in prepare_pstree_for_shell_job
First, let's move lookup_create_item-s to the end so that on pgid replacement we don't have false positive pstree_pid_by_virt check founding item created by sid replacement. (note: we need those lookup_create_item-s for the sake of free pid selection mechanism) Second, let's add checks for sid/pgid in images intersecting with current_sid/pgid, as this would also bring problems on restore. Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
parent
66fd45d51d
commit
bd0f209c2b
1 changed files with 20 additions and 7 deletions
|
|
@ -381,20 +381,26 @@ static int prepare_pstree_for_shell_job(pid_t pid)
|
|||
}
|
||||
|
||||
for_each_pstree_item(pi) {
|
||||
if (pi->sid == current_sid) {
|
||||
pr_err("Current sid %d intersects with sid of (%d) in images\n", current_sid, vpid(pi));
|
||||
return -1;
|
||||
}
|
||||
if (pi->sid == old_sid)
|
||||
pi->sid = current_sid;
|
||||
|
||||
if (pi->pgid == current_sid) {
|
||||
pr_err("Current sid %d intersects with pgid of (%d) in images\n", current_sid,
|
||||
vpid(pi));
|
||||
return -1;
|
||||
}
|
||||
if (pi->pgid == old_sid)
|
||||
pi->pgid = current_sid;
|
||||
}
|
||||
|
||||
if (lookup_create_item(current_sid) == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* root_item is a group leader */
|
||||
if (root_item->pgid == vpid(root_item))
|
||||
return 0;
|
||||
goto add_fake_session_leader;
|
||||
|
||||
old_gid = root_item->pgid;
|
||||
if (old_gid != current_gid) {
|
||||
|
|
@ -407,14 +413,21 @@ static int prepare_pstree_for_shell_job(pid_t pid)
|
|||
}
|
||||
|
||||
for_each_pstree_item(pi) {
|
||||
if (current_gid != current_sid && pi->pgid == current_gid) {
|
||||
pr_err("Current gid %d intersects with pgid of (%d) in images\n", current_gid,
|
||||
vpid(pi));
|
||||
return -1;
|
||||
}
|
||||
if (pi->pgid == old_gid)
|
||||
pi->pgid = current_gid;
|
||||
}
|
||||
|
||||
if (lookup_create_item(current_gid) == NULL)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (old_gid != current_gid && !lookup_create_item(current_gid))
|
||||
return -1;
|
||||
add_fake_session_leader:
|
||||
if (old_sid != current_sid && !lookup_create_item(current_sid))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue