diff options
| author | Konstantin Belousov <kib@FreeBSD.org> | 2010-11-03 21:24:21 +0000 |
|---|---|---|
| committer | Konstantin Belousov <kib@FreeBSD.org> | 2010-11-03 21:24:21 +0000 |
| commit | 362adfbff31a15aff19ced6011e8a6e290f79c95 (patch) | |
| tree | 3520a7ff2ab8c072c832f150c71cec7d312221a3 /sys/kern | |
| parent | e974cac769ba6803e6d1a39345cb27e3b5e836be (diff) | |
Notes
Diffstat (limited to 'sys/kern')
| -rw-r--r-- | sys/kern/kern_sig.c | 17 | ||||
| -rw-r--r-- | sys/kern/sys_process.c | 65 |
2 files changed, 70 insertions, 12 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index 76b17eaed5be..18fef0010ddd 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -2517,7 +2517,6 @@ issignal(struct thread *td, int stop_allowed) struct sigacts *ps; struct sigqueue *queue; sigset_t sigpending; - ksiginfo_t ksi; int sig, prop, newsig; p = td->td_proc; @@ -2560,10 +2559,10 @@ issignal(struct thread *td, int stop_allowed) * be thrown away. */ queue = &td->td_sigqueue; - ksi.ksi_signo = 0; - if (sigqueue_get(queue, sig, &ksi) == 0) { + td->td_dbgksi.ksi_signo = 0; + if (sigqueue_get(queue, sig, &td->td_dbgksi) == 0) { queue = &p->p_sigqueue; - sigqueue_get(queue, sig, &ksi); + sigqueue_get(queue, sig, &td->td_dbgksi); } mtx_unlock(&ps->ps_mtx); @@ -2590,13 +2589,13 @@ issignal(struct thread *td, int stop_allowed) continue; signotify(td); } else { - if (ksi.ksi_signo != 0) { - ksi.ksi_flags |= KSI_HEAD; + if (td->td_dbgksi.ksi_signo != 0) { + td->td_dbgksi.ksi_flags |= KSI_HEAD; if (sigqueue_add(&td->td_sigqueue, sig, - &ksi) != 0) - ksi.ksi_signo = 0; + &td->td_dbgksi) != 0) + td->td_dbgksi.ksi_signo = 0; } - if (ksi.ksi_signo == 0) + if (td->td_dbgksi.ksi_signo == 0) sigqueue_add(&td->td_sigqueue, sig, NULL); } diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c index 18fdd9e790d8..d306d73c5d27 100644 --- a/sys/kern/sys_process.c +++ b/sys/kern/sys_process.c @@ -63,6 +63,7 @@ __FBSDID("$FreeBSD$"); #ifdef COMPAT_FREEBSD32 #include <sys/procfs.h> +#include <compat/freebsd32/freebsd32_signal.h> struct ptrace_io_desc32 { int piod_op; @@ -84,6 +85,15 @@ struct ptrace_vm_entry32 { uint32_t pve_path; }; +struct ptrace_lwpinfo32 { + lwpid_t pl_lwpid; /* LWP described. */ + int pl_event; /* Event that stopped the LWP. */ + int pl_flags; /* LWP flags. */ + sigset_t pl_sigmask; /* LWP signal mask */ + sigset_t pl_siglist; /* LWP pending signal */ + struct siginfo32 pl_siginfo; /* siginfo for signal */ +}; + #endif /* @@ -495,6 +505,19 @@ ptrace_vm_entry32(struct thread *td, struct proc *p, pve32->pve_pathlen = pve.pve_pathlen; return (error); } + +static void +ptrace_lwpinfo_to32(const struct ptrace_lwpinfo *pl, + struct ptrace_lwpinfo32 *pl32) +{ + + pl32->pl_lwpid = pl->pl_lwpid; + pl32->pl_event = pl->pl_event; + pl32->pl_flags = pl->pl_flags; + pl32->pl_sigmask = pl->pl_sigmask; + pl32->pl_siglist = pl->pl_siglist; + siginfo_to_siginfo32(&pl->pl_siginfo, &pl32->pl_siginfo); +} #endif /* COMPAT_FREEBSD32 */ /* @@ -549,6 +572,7 @@ ptrace(struct thread *td, struct ptrace_args *uap) struct fpreg32 fpreg32; struct reg32 reg32; struct ptrace_io_desc32 piod32; + struct ptrace_lwpinfo32 pl32; struct ptrace_vm_entry32 pve32; #endif } r; @@ -659,6 +683,8 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) #ifdef COMPAT_FREEBSD32 int wrap32 = 0, safe = 0; struct ptrace_io_desc32 *piod32 = NULL; + struct ptrace_lwpinfo32 *pl32 = NULL; + struct ptrace_lwpinfo plr; #endif curp = td->td_proc; @@ -1100,15 +1126,44 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) break; case PT_LWPINFO: - if (data <= 0 || data > sizeof(*pl)) { + if (data <= 0 || +#ifdef COMPAT_FREEBSD32 + (!wrap32 && data > sizeof(*pl)) || + (wrap32 && data > sizeof(*pl32))) { +#else + data > sizeof(*pl)) { +#endif error = EINVAL; break; } +#ifdef COMPAT_FREEBSD32 + if (wrap32) { + pl = &plr; + pl32 = addr; + } else +#endif pl = addr; pl->pl_lwpid = td2->td_tid; - if (td2->td_dbgflags & TDB_XSIG) - pl->pl_event = PL_EVENT_SIGNAL; pl->pl_flags = 0; + if (td2->td_dbgflags & TDB_XSIG) { + pl->pl_event = PL_EVENT_SIGNAL; + if (td2->td_dbgksi.ksi_signo != 0 && +#ifdef COMPAT_FREEBSD32 + ((!wrap32 && data >= offsetof(struct ptrace_lwpinfo, + pl_siginfo) + sizeof(pl->pl_siginfo)) || + (wrap32 && data >= offsetof(struct ptrace_lwpinfo32, + pl_siginfo) + sizeof(struct siginfo32))) +#else + data >= offsetof(struct ptrace_lwpinfo, pl_siginfo) + + sizeof(pl->pl_siginfo) +#endif + ){ + pl->pl_flags |= PL_FLAG_SI; + pl->pl_siginfo = td2->td_dbgksi.ksi_info; + } + } + if ((pl->pl_flags & PL_FLAG_SI) == 0) + bzero(&pl->pl_siginfo, sizeof(pl->pl_siginfo)); if (td2->td_dbgflags & TDB_SCE) pl->pl_flags |= PL_FLAG_SCE; else if (td2->td_dbgflags & TDB_SCX) @@ -1117,6 +1172,10 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data) pl->pl_flags |= PL_FLAG_EXEC; pl->pl_sigmask = td2->td_sigmask; pl->pl_siglist = td2->td_siglist; +#ifdef COMPAT_FREEBSD32 + if (wrap32) + ptrace_lwpinfo_to32(pl, pl32); +#endif break; case PT_GETNUMLWPS: |
