Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Feb 2019 18:20:42 +0000 (UTC)
From:      Mark Johnston <markj@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r344599 - in head/sys/cddl/contrib/opensolaris/uts: common/dtrace intel/dtrace
Message-ID:  <201902261820.x1QIKgJ4076617@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: markj
Date: Tue Feb 26 18:20:41 2019
New Revision: 344599
URL: https://svnweb.freebsd.org/changeset/base/344599

Log:
  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

Modified:
  head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
  head/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c

Modified: head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c	Tue Feb 26 18:09:04 2019	(r344598)
+++ head/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c	Tue Feb 26 18:20:41 2019	(r344599)
@@ -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

Modified: head/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Tue Feb 26 18:09:04 2019	(r344598)
+++ head/sys/cddl/contrib/opensolaris/uts/intel/dtrace/fasttrap_isa.c	Tue Feb 26 18:20:41 2019	(r344599)
@@ -735,13 +735,15 @@ fasttrap_return_common(struct reg *rp, uintptr_t pc, p
 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201902261820.x1QIKgJ4076617>