Skip to content
This repository has been archived by the owner on Jan 8, 2024. It is now read-only.

Commit

Permalink
TracerPid is pid_max for parent namespace tracer
Browse files Browse the repository at this point in the history
For the Stadia debugger flow to work, the game process needs to be able
to detect when it is being traced by a process in its parent PID
namespace, which TracerPid in /proc/[pid]/status won't show. This change
will make TracerPid return pid_max instead of 0 for this case. This will
enable checks that look to see if they are being traced to return true,
even though they can't see the actual process.

Change-Id: I828da9bd59eb3b283ad06587c7dae442169d1064
  • Loading branch information
Cody Hansen committed Apr 18, 2022
1 parent 97ad7a1 commit ece8b1b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion fs/proc/array.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#include <linux/string_helpers.h>
#include <linux/user_namespace.h>
#include <linux/fs_struct.h>
#include <linux/pid.h>

#include <asm/processor.h>
#include "internal.h"
Expand Down Expand Up @@ -164,8 +165,15 @@ static inline void task_state(struct seq_file *m, struct pid_namespace *ns,
task_tgid_nr_ns(rcu_dereference(p->real_parent), ns) : 0;

tracer = ptrace_parent(p);
if (tracer)
if (tracer) {
tpid = task_pid_nr_ns(tracer, ns);
if (tpid == 0) {
// Set the pid to a valid number, but not an actual valid pid
// so that anything checking if it is being traced will see
// that it is traced, even though it can't see the process.
tpid = pid_max;
}
}

tgid = task_tgid_nr_ns(p, ns);
ngid = task_numa_group_id(p);
Expand Down

0 comments on commit ece8b1b

Please sign in to comment.