summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-08-15 05:25:06 +0000
committermarcel <marcel@FreeBSD.org>2003-08-15 05:25:06 +0000
commit77c3cd3d303099ad2d819725741f948ad5ff37d8 (patch)
tree6290146a54abb5f571d622ed83197b37076b3bc8
parent5f9e1c9d2c9abe81bdafc8d2a4a2ce5ef5f487fb (diff)
downloadFreeBSD-src-77c3cd3d303099ad2d819725741f948ad5ff37d8.zip
FreeBSD-src-77c3cd3d303099ad2d819725741f948ad5ff37d8.tar.gz
Add or finish support for machine dependent ptrace requests. When we
check for permissions, do it for all requests, not the known requests. Later when we actually service the request we deal with the invalid requests we previously caught earlier. This commit changes the behaviour of the ptrace(2) interface for boundary cases such as an unknown request without proper permissions. Previously we would return EINVAL. Now we return EBUSY or EPERM. Platforms need to define __HAVE_PTRACE_MACHDEP when they have MD requests. This makes the prototype of cpu_ptrace() visible and introduces a call to this function for all requests greater or equal to PT_FIRSTMACH. Silence on: audit
-rw-r--r--sys/kern/sys_process.c35
-rw-r--r--sys/sys/ptrace.h4
2 files changed, 17 insertions, 22 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index bdecbf3..51bbdcd 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -336,6 +336,7 @@ ptrace(struct thread *td, struct ptrace_args *uap)
break;
default:
addr = uap->addr;
+ break;
}
if (error)
return (error);
@@ -449,21 +450,7 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
/* OK */
break;
- case PT_READ_I:
- case PT_READ_D:
- case PT_WRITE_I:
- case PT_WRITE_D:
- case PT_IO:
- case PT_CONTINUE:
- case PT_KILL:
- case PT_STEP:
- case PT_DETACH:
- case PT_GETREGS:
- case PT_SETREGS:
- case PT_GETFPREGS:
- case PT_SETFPREGS:
- case PT_GETDBREGS:
- case PT_SETDBREGS:
+ default:
/* not being traced... */
if ((p->p_flag & P_TRACED) == 0) {
error = EPERM;
@@ -484,10 +471,6 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
/* OK */
break;
-
- default:
- error = EINVAL;
- goto fail;
}
td2 = FIRST_THREAD_IN_PROC(p);
@@ -702,12 +685,20 @@ kern_ptrace(struct thread *td, int req, pid_t pid, void *addr, int data)
return (error);
default:
- KASSERT(0, ("unreachable code\n"));
+#ifdef __HAVE_PTRACE_MACHDEP
+ if (req >= PT_FIRSTMACH) {
+ _PHOLD(p);
+ error = cpu_ptrace(td2, req, addr, data);
+ _PRELE(p);
+ PROC_UNLOCK(p);
+ return (error);
+ }
+#endif
break;
}
- KASSERT(0, ("unreachable code\n"));
- return (0);
+ /* Unknown request. */
+ error = EINVAL;
fail:
PROC_UNLOCK(p);
diff --git a/sys/sys/ptrace.h b/sys/sys/ptrace.h
index 09d8742..ef7262a 100644
--- a/sys/sys/ptrace.h
+++ b/sys/sys/ptrace.h
@@ -81,6 +81,10 @@ struct ptrace_io_desc {
int ptrace_set_pc(struct thread *_td, unsigned long _addr);
int ptrace_single_step(struct thread *_td);
+#ifdef __HAVE_PTRACE_MACHDEP
+int cpu_ptrace(struct thread *_td, int _req, void *_addr, int _data);
+#endif
+
/*
* These are prototypes for functions that implement some of the
* debugging functionality exported by procfs / linprocfs and by the
OpenPOWER on IntegriCloud