diff options
author | Patrick Mooney <pmooney@pfmooney.com> | 2015-10-28 19:36:29 +0000 |
---|---|---|
committer | Patrick Mooney <pmooney@pfmooney.com> | 2015-10-28 20:46:28 +0000 |
commit | 48ce43499ce953b232ae9c96e4362a122610f87d (patch) | |
tree | 3db440635021206528cdbed28bac78cae49e117e /usr/src | |
parent | f82cc727aca1af2ec9d2d8f142398b35e8769df0 (diff) | |
download | illumos-joyent-48ce43499ce953b232ae9c96e4362a122610f87d.tar.gz |
OS-4899 lxbrand signal ignorance impossible in former ptracees
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/uts/common/brand/lx/os/lx_ptrace.c | 29 | ||||
-rw-r--r-- | usr/src/uts/common/brand/lx/sys/lx_brand.h | 2 |
2 files changed, 22 insertions, 9 deletions
diff --git a/usr/src/uts/common/brand/lx/os/lx_ptrace.c b/usr/src/uts/common/brand/lx/os/lx_ptrace.c index 5728ea2736..ae697c33d4 100644 --- a/usr/src/uts/common/brand/lx/os/lx_ptrace.c +++ b/usr/src/uts/common/brand/lx/os/lx_ptrace.c @@ -898,9 +898,7 @@ static int lx_ptrace_detach(lx_ptrace_accord_t *accord, lx_lwp_data_t *remote, int signo, boolean_t *release_hold) { - klwp_t *rlwp; - - rlwp = remote->br_lwp; + klwp_t *rlwp = remote->br_lwp; /* * The tracee LWP was in "ptrace-stop" and we now hold its p_lock. @@ -918,6 +916,11 @@ lx_ptrace_detach(lx_ptrace_accord_t *accord, lx_lwp_data_t *remote, int signo, *release_hold = B_TRUE; /* + * Decrement traced-lwp count for the process. + */ + VERIFY(ptolxproc(rlwp->lwp_procp)->l_ptrace-- >= 1); + + /* * The tracer may, as described in lx_ptrace_cont(), choose to suppress * or modify the delivered signal. */ @@ -1054,10 +1057,10 @@ lx_ptrace_attach(pid_t lx_pid) sigtoproc(rproc, rthr, SIGSTOP); /* - * Set the in-kernel process-wide ptrace(2) enable flag. + * Bump traced-lwp count for the remote process. */ rprocd = ttolxproc(rthr); - rprocd->l_ptrace = 1; + rprocd->l_ptrace++; error = 0; } @@ -1326,10 +1329,9 @@ lx_ptrace_traceme(void) lx_ptrace_accord_exit(accord); /* - * Set the in-kernel process-wide ptrace(2) enable - * flag. + * Bump traced-lwp count for the process. */ - procd->l_ptrace = 1; + procd->l_ptrace++; return (0); } @@ -1788,6 +1790,11 @@ lx_ptrace_exit_tracer(proc_t *p, lx_lwp_data_t *lwpd, mutex_exit(&accord->lxpa_tracees_lock); /* + * Decrement traced-lwp count for the remote process. + */ + VERIFY(ptolxproc(rproc)->l_ptrace-- >= 1); + + /* * Ensure that the LWP is not stopped on our account. */ lx_ptrace_restart_lwp(rlwp); @@ -1857,6 +1864,12 @@ lx_ptrace_exit_tracee(proc_t *p, lx_lwp_data_t *lwpd, * Wake up any tracers waiting for us to detach from the accord. */ cv_broadcast(&lx_ptrace_busy_cv); + + /* + * Decrement traced-lwp count for the process. + */ + VERIFY(ptolxproc(p)->l_ptrace-- >= 1); + mutex_exit(&p->p_lock); mutex_exit(&accord->lxpa_tracees_lock); diff --git a/usr/src/uts/common/brand/lx/sys/lx_brand.h b/usr/src/uts/common/brand/lx/sys/lx_brand.h index 1b00691ba5..a7c4ee9320 100644 --- a/usr/src/uts/common/brand/lx/sys/lx_brand.h +++ b/usr/src/uts/common/brand/lx/sys/lx_brand.h @@ -282,7 +282,7 @@ typedef struct { typedef struct lx_proc_data { uintptr_t l_handler; /* address of user-space handler */ pid_t l_ppid; /* pid of originating parent proc */ - uint64_t l_ptrace; /* process being observed with ptrace */ + int64_t l_ptrace; /* count of process lwps observed by ptrace */ lx_elf_data_t l_elf_data; /* ELF data for linux executable */ /* signal to deliver to parent when this thread group dies */ int l_signal; |