summaryrefslogtreecommitdiffstats
path: root/sys/kern/sys_process.c
diff options
context:
space:
mode:
authorbde <bde@FreeBSD.org>1995-01-14 13:20:26 +0000
committerbde <bde@FreeBSD.org>1995-01-14 13:20:26 +0000
commitf864467045725c1b346794033bd11f45dd6feec5 (patch)
tree06320399d13e4e9ccf2164186d37e0145ea521a6 /sys/kern/sys_process.c
parent92ea353442d70bec0252efcdaa5cf07ad5d32571 (diff)
downloadFreeBSD-src-f864467045725c1b346794033bd11f45dd6feec5.zip
FreeBSD-src-f864467045725c1b346794033bd11f45dd6feec5.tar.gz
Fix security holes in sigreturn(), ptrace() and procfs. sigreturn()
attempted to check for insecure and fatal eflags and segment selectors, but missed many cases and got the IOPL check back to front. The other syscalls didn't check at all. sys_process.c, machdep.c: Only allow PT_WRITE_U to write to the registers (ordinary and FP). psl.h, locore.s, machdep.c: Eliminate PSL_MBZ, PSL_MBO and PSL_USERCLR. We are not supposed to assume anything about the reserved bits. Use PSL_USERCHANGE and PSL_KERNEL instead. Rename PSL_USERSET to PSL_USER. exception.s: Define a private label for use by doreti when returning to user mode fails. machdep.c: In syscalls, allow changing only the eflags that can be changed on 486's in user mode (no longer attempt to allow benign IOPL changes; allow changing the nasty PSL_NT; don't allow changing the i586 bits). Don't attempt to check all the cases involving invalid selectors and %eip's. Just check for privilege violations and let the invalid things cause a trap. procfs_machdep.c: Call the ptrace register functions to do all the work for reading and writing ordinary registers and for single stepping. trap.c: Ignore traps caused by PSL_NT being set. Previously, users could cause a fatal trap in user mode by setting PSL_NT and executing an iret, and a fatal trap in kernel mode by setting PSL_NT and making a syscall. PSL_NT was cleared too late and not in enough modes to fix the problem. Make all traps in user mode (except T_NMI) nonfatal. Recover from traps caused by attempting to load invalid user registers in doreti by restarting the traps so that they appear to occur in user mode. --- Fix bogons that I noticed while fixing the above: psl.h: Fix some comments. Uniformize idempotency ifdef. exception.s, machdep.c: Remove rsvd[0-14]. rsvd0 hasn't been reserved since the 486 came out. Replace rsvd0 by `align'. rsvd[0-11] used wrong (magic non-unique) trap numbers. Replace rsvd[1-14] by rsvd. locore.s: Enable alignment check flag on 486's and 586's. machdep.c: Use a better type for kstack[]. Use TFREGP() to find the registers. Reformat ptrace functions from SEF to something closer to KNF. procfs_machdep.c: The wrong pointer to the registers got fixed as a side effect. Implement reading and writing of FP registers. /proc/*/*regs now work (only) for processes that are in memory. Clean up comments. trap.c, trap.h: Remove unused trap types.
Diffstat (limited to 'sys/kern/sys_process.c')
-rw-r--r--sys/kern/sys_process.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/sys/kern/sys_process.c b/sys/kern/sys_process.c
index 63537bd..692f2c5 100644
--- a/sys/kern/sys_process.c
+++ b/sys/kern/sys_process.c
@@ -28,7 +28,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: sys_process.c,v 1.6 1994/08/18 22:35:05 wollman Exp $
+ * $Id: sys_process.c,v 1.7 1994/09/25 19:33:49 phk Exp $
*/
#include <sys/param.h>
@@ -326,13 +326,9 @@ ptrace(curp, uap, retval)
*retval = *(int*)((u_int)p->p_addr + (u_int)uap->addr);
return 0;
case PT_WRITE_U:
- if ((u_int)uap->addr > (UPAGES * NBPG - sizeof(int))) {
- return EFAULT;
- }
p->p_addr->u_kproc.kp_proc = *p;
fill_eproc (p, &p->p_addr->u_kproc.kp_eproc);
- *(int*)((u_int)p->p_addr + (u_int)uap->addr) = uap->data;
- return 0;
+ return ptrace_write_u(p, (vm_offset_t)uap->addr, uap->data);
case PT_KILL:
p->p_xstat = SIGKILL;
setrunnable(p);
OpenPOWER on IntegriCloud