From 7e7bd03bf9be3c80e1e6f6aa5312a4cb76af5b85 Mon Sep 17 00:00:00 2001 From: Pavel Tikhomirov Date: Fri, 16 Jan 2026 12:33:10 +0800 Subject: [PATCH] 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 --- criu/cr-restore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/criu/cr-restore.c b/criu/cr-restore.c index a5eda8d60..b92b92715 100644 --- a/criu/cr-restore.c +++ b/criu/cr-restore.c @@ -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))