From 9fdbafa2fe06cfff465241ce76c5395269982396 Mon Sep 17 00:00:00 2001 From: tegge Date: Tue, 19 May 1998 00:00:14 +0000 Subject: Disallow reading the current kernel stack. Only the user structure and the current registers should be accessible. Reviewed by: David Greenman --- sys/amd64/amd64/vm_machdep.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'sys/amd64/amd64/vm_machdep.c') diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 7e3b32a..9c8b1f5 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -38,7 +38,7 @@ * * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ - * $Id: vm_machdep.c,v 1.106 1998/05/16 14:44:11 kato Exp $ + * $Id: vm_machdep.c,v 1.107 1998/05/17 22:12:11 tegge Exp $ */ #include "npx.h" @@ -742,10 +742,27 @@ cpu_coredump(p, vp, cred) struct vnode *vp; struct ucred *cred; { - - return (vn_rdwr(UIO_WRITE, vp, (caddr_t) p->p_addr, ctob(UPAGES), - (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, cred, (int *)NULL, - p)); + int error; + caddr_t tempuser; + + tempuser = malloc(ctob(UPAGES), M_TEMP, M_WAITOK); + if (!tempuser) + return EINVAL; + + bzero(tempuser, ctob(UPAGES)); + bcopy(p->p_addr, tempuser, sizeof(struct user)); + bcopy(p->p_md.md_regs, + tempuser + ((caddr_t) p->p_md.md_regs - (caddr_t) p->p_addr), + sizeof(struct trapframe)); + + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, + ctob(UPAGES), + (off_t)0, UIO_SYSSPACE, IO_NODELOCKED|IO_UNIT, + cred, (int *)NULL, p); + + free(tempuser, M_TEMP); + + return error; } #ifdef notyet -- cgit v1.1