two proposed linuxulator fixes + ptrace
Konstantin Belousov
kostikbel at gmail.com
Thu Jun 14 14:16:16 UTC 2018
On Thu, Jun 14, 2018 at 04:11:52PM +0300, Yanko Yankulov wrote:
> > > > For the patch 1, TracePid, can you explain what is the meaning of the
> > > > pid reported ?
> > > >
> > > > The TracerPid is the PID of the process currently ptrace-ing the
> > process.
> > > TracerPid 0 means no active tracer. So the patch is not semantically
> > > correct as it always reports no tracer, but it got the program running.
> > Ok, but what is the tracer ? Is it ptrace(2) debugger, or something
> > else ?
> >
>
> Yes, any ptrace(2) debugger/truss/strace/whatever. The Linux code is:
>
> tracer = ptrace_parent(p);
> if (tracer)
> tpid = task_pid_nr_ns(tracer, ns);
I think this should be like
PROC_LOCK(p);
tpid = (p->p_flag & P_TRACED) != 0 ? p->p_ppid : 0;
PROC_UNLOCK(p);
sx_slock(&proctree_lock);
parent_pid = proc_realparent(p)->p_pid;
sx_sunlock(&proctree_lock);
More information about the freebsd-emulation
mailing list