Fix fasttrap_sig{trap,segv}().
- Don't leak the ksiginfo structure. - Hold the proc lock when sending a signal in fasttrap_sigsegv(). MFC after: 1 week Sponsored by: The FreeBSD Foundation
This commit is contained in:
parent
146537449b
commit
8e7127fd91
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=344599
@ -291,30 +291,15 @@ fasttrap_hash_str(const char *p)
|
||||
void
|
||||
fasttrap_sigtrap(proc_t *p, kthread_t *t, uintptr_t pc)
|
||||
{
|
||||
#ifdef illumos
|
||||
sigqueue_t *sqp = kmem_zalloc(sizeof (sigqueue_t), KM_SLEEP);
|
||||
ksiginfo_t ksi;
|
||||
|
||||
sqp->sq_info.si_signo = SIGTRAP;
|
||||
sqp->sq_info.si_code = TRAP_DTRACE;
|
||||
sqp->sq_info.si_addr = (caddr_t)pc;
|
||||
|
||||
mutex_enter(&p->p_lock);
|
||||
sigaddqa(p, t, sqp);
|
||||
mutex_exit(&p->p_lock);
|
||||
|
||||
if (t != NULL)
|
||||
aston(t);
|
||||
#else
|
||||
ksiginfo_t *ksi = kmem_zalloc(sizeof (ksiginfo_t), KM_SLEEP);
|
||||
|
||||
ksiginfo_init(ksi);
|
||||
ksi->ksi_signo = SIGTRAP;
|
||||
ksi->ksi_code = TRAP_DTRACE;
|
||||
ksi->ksi_addr = (caddr_t)pc;
|
||||
ksiginfo_init(&ksi);
|
||||
ksi.ksi_signo = SIGTRAP;
|
||||
ksi.ksi_code = TRAP_DTRACE;
|
||||
ksi.ksi_addr = (caddr_t)pc;
|
||||
PROC_LOCK(p);
|
||||
(void) tdsendsignal(p, t, SIGTRAP, ksi);
|
||||
(void)tdsendsignal(p, t, SIGTRAP, &ksi);
|
||||
PROC_UNLOCK(p);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef illumos
|
||||
|
@ -735,13 +735,15 @@ fasttrap_return_common(struct reg *rp, uintptr_t pc, pid_t pid,
|
||||
static void
|
||||
fasttrap_sigsegv(proc_t *p, kthread_t *t, uintptr_t addr)
|
||||
{
|
||||
ksiginfo_t *ksi = kmem_zalloc(sizeof (ksiginfo_t), KM_SLEEP);
|
||||
ksiginfo_t ksi;
|
||||
|
||||
ksiginfo_init(ksi);
|
||||
ksi->ksi_signo = SIGSEGV;
|
||||
ksi->ksi_code = SEGV_MAPERR;
|
||||
ksi->ksi_addr = (caddr_t)addr;
|
||||
(void) tdksignal(t, SIGSEGV, ksi);
|
||||
ksiginfo_init(&ksi);
|
||||
ksi.ksi_signo = SIGSEGV;
|
||||
ksi.ksi_code = SEGV_MAPERR;
|
||||
ksi.ksi_addr = (caddr_t)addr;
|
||||
PROC_LOCK(p);
|
||||
(void)tdksignal(t, SIGSEGV, &ksi);
|
||||
PROC_UNLOCK(p);
|
||||
}
|
||||
|
||||
#ifdef __amd64
|
||||
|
Loading…
Reference in New Issue
Block a user