Re: DTrace panic while probing syscall::open (and possibly many others)

From: Andriy Gapon <avg_at_freebsd.org>
Date: Wed, 24 Jun 2009 17:16:00 +0300
Please review and/or test the following patch.
I think that i386 dtrace code could also benefit from the similar changes and from
the fact that we now have stack.h for this arch too.

diff --git a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
index 8cd2a0f..c58e88e 100644
--- a/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
+++ b/sys/cddl/dev/dtrace/amd64/dtrace_isa.c
_at__at_ -42,8 +42,6 _at__at_
 #include <vm/vm_param.h>
 #include <vm/pmap.h>

-extern uintptr_t kernbase;
-uintptr_t kernelbase = (uintptr_t) &kernbase;

 uint8_t dtrace_fuword8_nocheck(void *);
 uint16_t dtrace_fuword16_nocheck(void *);
_at__at_ -524,9 +522,9 _at__at_ dtrace_getreg(struct regs *rp, uint_t reg)
 static int
 dtrace_copycheck(uintptr_t uaddr, uintptr_t kaddr, size_t size)
 {
-	ASSERT(kaddr >= kernelbase && kaddr + size >= kaddr);
+	ASSERT(INKERNEL(kaddr) && kaddr + size >= kaddr);

-	if (uaddr + size >= kernelbase || uaddr + size < uaddr) {
+	if (uaddr + size > VM_MAXUSER_ADDRESS || uaddr + size < uaddr) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
 		cpu_core[curcpu].cpuc_dtrace_illval = uaddr;
 		return (0);
_at__at_ -570,7 +568,7 _at__at_ dtrace_copyoutstr(uintptr_t kaddr, uintptr_t uaddr, size_t size,
 uint8_t
 dtrace_fuword8(void *uaddr)
 {
-	if ((uintptr_t)uaddr >= kernelbase) {
+	if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
 		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
_at__at_ -581,7 +579,7 _at__at_ dtrace_fuword8(void *uaddr)
 uint16_t
 dtrace_fuword16(void *uaddr)
 {
-	if ((uintptr_t)uaddr >= kernelbase) {
+	if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
 		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
_at__at_ -592,7 +590,7 _at__at_ dtrace_fuword16(void *uaddr)
 uint32_t
 dtrace_fuword32(void *uaddr)
 {
-	if ((uintptr_t)uaddr >= kernelbase) {
+	if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
 		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
_at__at_ -603,7 +601,7 _at__at_ dtrace_fuword32(void *uaddr)
 uint64_t
 dtrace_fuword64(void *uaddr)
 {
-	if ((uintptr_t)uaddr >= kernelbase) {
+	if ((uintptr_t)uaddr > VM_MAXUSER_ADDRESS) {
 		DTRACE_CPUFLAG_SET(CPU_DTRACE_BADADDR);
 		cpu_core[curcpu].cpuc_dtrace_illval = (uintptr_t)uaddr;
 		return (0);
diff --git a/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
b/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
index 4bf0f03..260b99b 100644
--- a/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
+++ b/sys/cddl/dev/dtrace/amd64/dtrace_subr.c
_at__at_ -40,7 +40,6 _at__at_
 #include <machine/frame.h>
 #include <vm/pmap.h>

-extern uintptr_t 	kernelbase;
 extern uintptr_t 	dtrace_in_probe_addr;
 extern int		dtrace_in_probe;



-- 
Andriy Gapon
Received on Wed Jun 24 2009 - 12:16:04 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:50 UTC