cr-restore/shstk: Make arch_shstk_unlock use correct pid

In a simple case where the parent process and the child one are in one
pid namespace we can safely use vpid(item) to prace the child. But, for
the cases where the child is a pid namespace init, or the child is put
into external pid namespace, the parent and the child have different pid
namespaces and using pid vpid(item) (which e.g. for init will always be
1 here) to ptrace the child process is inorrect.

Let's use the pid reported to us from clone as it's always the right pid
of the child from the parent's point of view.

Fixes: 7dd583002 ("restore: add infrastructure to enable shadow stack")
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
This commit is contained in:
Pavel Tikhomirov 2026-01-16 12:33:10 +08:00 committed by Radostin Stoyanov
parent 07af3304fd
commit 21a6758268

View file

@ -1238,7 +1238,7 @@ static inline int fork_with_pid(struct pstree_item *item)
pr_debug("PID: real %d virt %d\n", item->pid->real, vpid(item));
}
arch_shstk_unlock(item, ca.core, pid);
arch_shstk_unlock(item, ca.core, ret);
err_unlock:
if (!(ca.clone_flags & CLONE_NEWPID))