Index: alpha/alpha/vm_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/alpha/alpha/vm_machdep.c,v retrieving revision 1.70 diff -u -2 -r1.70 vm_machdep.c --- alpha/alpha/vm_machdep.c 15 Aug 2002 20:55:00 -0000 1.70 +++ alpha/alpha/vm_machdep.c 6 Sep 2002 07:42:06 -0000 @@ -396,27 +396,4 @@ /* - * Dump the machine specific header information at the start of a core dump. - */ -int -cpu_coredump(td, vp, cred) - struct thread *td; - struct vnode *vp; - struct ucred *cred; -{ - int error; - - /* XXXKSE this is totally bogus! (and insecure) */ - error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_proc->p_uarea, - ctob(UAREA_PAGES), (off_t)0, - UIO_SYSSPACE, IO_UNIT, cred, NOCRED, (int *)NULL, td); - if (error) - return error; - error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_kstack, - ctob(KSTACK_PAGES), (off_t)ctob(UAREA_PAGES), - UIO_SYSSPACE, IO_UNIT, cred, NOCRED, (int *)NULL, td); - return error; -} - -/* * Map an IO request into kernel virtual address space. * Index: compat/pecoff/imgact_pecoff.c =================================================================== RCS file: /home/ncvs/src/sys/compat/pecoff/imgact_pecoff.c,v retrieving revision 1.21 diff -u -2 -r1.21 imgact_pecoff.c --- compat/pecoff/imgact_pecoff.c 1 Sep 2002 21:41:22 -0000 1.21 +++ compat/pecoff/imgact_pecoff.c 6 Sep 2002 07:45:31 -0000 @@ -44,4 +44,5 @@ */ +#include "opt_kstack_pages.h" #include @@ -174,4 +175,5 @@ struct proc *p = td->td_proc; register struct vmspace *vm = p->p_vmspace; + caddr_t tempuser; int error; #ifdef PECOFF_DEBUG @@ -183,4 +185,10 @@ if (ctob((UAREA_PAGES+KSTACK_PAGES) + vm->vm_dsize + vm->vm_ssize) >= limit) return (EFAULT); + tempuser = malloc(ctob(UAREA_PAGES + KSTACK_PAGES), M_TEMP, + M_WAITOK | M_ZERO); + bcopy(p->p_uarea, tempuser, sizeof(struct user)); + tempuser + ctob(UAREA_PAGES) + + ((caddr_t) td->td_frame - (caddr_t) td->td_kstack), + sizeof(struct trapframe)); PROC_LOCK(p); fill_kinfo_proc(p, &p->p_uarea->u_kproc); @@ -196,5 +204,9 @@ printf("%p %p %p\n", ent, ent->prev, ent->next); #endif - error = cpu_coredump(td, vp, cred); + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, + ctob(UAREA_PAGES + KSTACK_PAGES), + (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, NOCRED, + (int *)NULL, td); + free(tempuser, M_TEMP); if (error == 0) error = vn_rdwr_inchunks(UIO_WRITE, vp, vm->vm_daddr, Index: conf/files.i386 =================================================================== RCS file: /home/ncvs/src/sys/conf/files.i386,v retrieving revision 1.416 diff -u -2 -r1.416 files.i386 --- conf/files.i386 4 Sep 2002 19:43:18 -0000 1.416 +++ conf/files.i386 6 Sep 2002 07:52:13 -0000 @@ -396,5 +396,5 @@ isa/syscons_isa.c optional sc isa/vga_isa.c optional vga -kern/imgact_aout.c standard +kern/imgact_aout.c optional compat_aout kern/imgact_gzip.c optional gzip kern/md4c.c optional netsmb Index: i386/i386/vm_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/i386/i386/vm_machdep.c,v retrieving revision 1.190 diff -u -2 -r1.190 vm_machdep.c --- i386/i386/vm_machdep.c 15 Aug 2002 20:55:02 -0000 1.190 +++ i386/i386/vm_machdep.c 6 Sep 2002 07:41:14 -0000 @@ -446,38 +446,4 @@ /* - * Dump the machine specific header information at the start of a core dump. - */ -int -cpu_coredump(td, vp, cred) - struct thread *td; - struct vnode *vp; - struct ucred *cred; -{ - struct proc *p = td->td_proc; - int error; - caddr_t tempuser; - - tempuser = malloc(ctob(UAREA_PAGES + KSTACK_PAGES), M_TEMP, M_WAITOK | M_ZERO); - if (!tempuser) - return EINVAL; - - bcopy(p->p_uarea, tempuser, sizeof(struct user)); -#if 0 /* XXXKSE - broken, fixme!!!!! td_frame is in kstack! */ - bcopy(td->td_frame, - tempuser + ((caddr_t) td->td_frame - (caddr_t) p->p_uarea), - sizeof(struct trapframe)); -#endif - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, - ctob(UAREA_PAGES + KSTACK_PAGES), - (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, NOCRED, - (int *)NULL, td); - - free(tempuser, M_TEMP); - - return error; -} - -/* * Convert kernel VA to physical address */ Index: i386/linux/linux_sysvec.c =================================================================== RCS file: /home/ncvs/src/sys/i386/linux/linux_sysvec.c,v retrieving revision 1.103 diff -u -2 -r1.103 linux_sysvec.c --- i386/linux/linux_sysvec.c 1 Sep 2002 22:30:27 -0000 1.103 +++ i386/linux/linux_sysvec.c 6 Sep 2002 08:10:39 -0000 @@ -31,4 +31,5 @@ /* XXX we use functions that might not exist. */ #include "opt_compat.h" +#include "opt_kstack_pages.h" #ifndef COMPAT_43 @@ -49,4 +50,6 @@ #include #include +#include +#include #include @@ -58,6 +61,13 @@ #include #include +#include #include +#include +#include +#include +#include +#include + #include #include @@ -707,7 +717,57 @@ args[3] = tf->tf_esi; args[4] = tf->tf_edi; + args[5] = tf->tf_ebp; *params = NULL; /* no copyin */ } + + +/* + * Dump core, into a file named as described in the comments for + * expand_name(), unless the process was setuid/setgid. + */ +static int +linux_aout_coredump(struct thread *td, struct vnode *vp, off_t limit) +{ + struct proc *p = td->td_proc; + struct ucred *cred = td->td_ucred; + struct vmspace *vm = p->p_vmspace; + caddr_t tempuser; + int error; + + if (ctob((UAREA_PAGES + KSTACK_PAGES) + + vm->vm_dsize + vm->vm_ssize) >= limit) + return (EFAULT); + tempuser = malloc(ctob(UAREA_PAGES + KSTACK_PAGES), M_TEMP, + M_WAITOK | M_ZERO); + if (tempuser == NULL) + return ENOMEM; + bcopy(p->p_uarea, tempuser, sizeof(struct user)); + bcopy(td->td_frame, + tempuser + ctob(UAREA_PAGES) + + ((caddr_t) td->td_frame - (caddr_t) td->td_kstack), + sizeof(struct trapframe)); + PROC_LOCK(p); + fill_kinfo_proc(p, &p->p_uarea->u_kproc); + PROC_UNLOCK(p); + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, + ctob(UAREA_PAGES + KSTACK_PAGES), + (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, NOCRED, + (int *)NULL, td); + free(tempuser, M_TEMP); + if (error == 0) + error = vn_rdwr(UIO_WRITE, vp, vm->vm_daddr, + (int)ctob(vm->vm_dsize), + (off_t)ctob(UAREA_PAGES + KSTACK_PAGES), UIO_USERSPACE, + IO_UNIT | IO_DIRECT, cred, NOCRED, (int *) NULL, td); + if (error == 0) + error = vn_rdwr_inchunks(UIO_WRITE, vp, + (caddr_t) trunc_page(USRSTACK - ctob(vm->vm_ssize)), + round_page(ctob(vm->vm_ssize)), + (off_t)ctob(UAREA_PAGES + KSTACK_PAGES) + + ctob(vm->vm_dsize), UIO_USERSPACE, + IO_UNIT | IO_DIRECT, cred, NOCRED, (int *) NULL, td); + return (error); +} /* * If a linux binary is exec'ing something, try this image activator @@ -769,5 +829,5 @@ linux_prepsyscall, "Linux a.out", - aout_coredump, + linux_aout_coredump, exec_linux_imgact_try, LINUX_MINSIGSTKSZ, Index: ia64/ia64/vm_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/ia64/ia64/vm_machdep.c,v retrieving revision 1.45 diff -u -2 -r1.45 vm_machdep.c --- ia64/ia64/vm_machdep.c 20 Aug 2002 02:21:38 -0000 1.45 +++ ia64/ia64/vm_machdep.c 6 Sep 2002 07:42:18 -0000 @@ -364,26 +364,4 @@ /* - * Dump the machine specific header information at the start of a core dump. - */ -int -cpu_coredump(td, vp, cred) - struct thread *td; - struct vnode *vp; - struct ucred *cred; -{ - int error; - - error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_proc->p_uarea, - ctob(UAREA_PAGES), (off_t)0, - UIO_SYSSPACE, IO_UNIT, cred, NOCRED, (int *)NULL, td); - if (error) - return error; - error = vn_rdwr(UIO_WRITE, vp, (caddr_t) td->td_kstack, - ctob(KSTACK_PAGES), (off_t)0, - UIO_SYSSPACE, IO_UNIT, cred, NOCRED, (int *)NULL, td); - return error; -} - -/* * Map an IO request into kernel virtual address space. * Index: kern/imgact_aout.c =================================================================== RCS file: /home/ncvs/src/sys/kern/imgact_aout.c,v retrieving revision 1.83 diff -u -2 -r1.83 imgact_aout.c --- kern/imgact_aout.c 1 Sep 2002 21:41:23 -0000 1.83 +++ kern/imgact_aout.c 6 Sep 2002 07:41:41 -0000 @@ -50,4 +50,5 @@ #include +#include #include @@ -274,13 +275,27 @@ register struct ucred *cred = td->td_ucred; register struct vmspace *vm = p->p_vmspace; + caddr_t tempuser; int error; - if (ctob((UAREA_PAGES + KSTACK_PAGES) - + vm->vm_dsize + vm->vm_ssize) >= limit) + if (ctob((UAREA_PAGES + KSTACK_PAGES) + + vm->vm_dsize + vm->vm_ssize) >= limit) return (EFAULT); + tempuser = malloc(ctob(UAREA_PAGES + KSTACK_PAGES), M_TEMP, + M_WAITOK | M_ZERO); + if (tempuser == NULL) + return ENOMEM; + bcopy(p->p_uarea, tempuser, sizeof(struct user)); + bcopy(td->td_frame, + tempuser + ctob(UAREA_PAGES) + + ((caddr_t) td->td_frame - (caddr_t) td->td_kstack), + sizeof(struct trapframe)); PROC_LOCK(p); fill_kinfo_proc(p, &p->p_uarea->u_kproc); PROC_UNLOCK(p); - error = cpu_coredump(td, vp, cred); + error = vn_rdwr(UIO_WRITE, vp, (caddr_t) tempuser, + ctob(UAREA_PAGES + KSTACK_PAGES), + (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, NOCRED, + (int *)NULL, td); + free(tempuser, M_TEMP); if (error == 0) error = vn_rdwr(UIO_WRITE, vp, vm->vm_daddr, Index: modules/Makefile =================================================================== RCS file: /home/ncvs/src/sys/modules/Makefile,v retrieving revision 1.253 diff -u -2 -r1.253 Makefile --- modules/Makefile 6 Sep 2002 17:18:53 -0000 1.253 +++ modules/Makefile 6 Sep 2002 20:58:38 -0000 @@ -130,4 +130,5 @@ acpi \ aic \ + aout \ ar \ arcnet \ Index: powerpc/powerpc/vm_machdep.c =================================================================== RCS file: /home/ncvs/src/sys/powerpc/powerpc/vm_machdep.c,v retrieving revision 1.74 diff -u -2 -r1.74 vm_machdep.c --- powerpc/powerpc/vm_machdep.c 15 Aug 2002 20:55:06 -0000 1.74 +++ powerpc/powerpc/vm_machdep.c 6 Sep 2002 07:42:25 -0000 @@ -231,19 +231,4 @@ /* - * Dump the machine specific header information at the start of a core dump. - */ -int -cpu_coredump(td, vp, cred) - struct thread *td; - struct vnode *vp; - struct ucred *cred; -{ - - return (vn_rdwr(UIO_WRITE, vp, (caddr_t)td->td_proc->p_uarea, - ctob(UAREA_PAGES), (off_t)0, UIO_SYSSPACE, IO_UNIT, cred, NOCRED, - (int *)NULL, td)); -} - -/* * Map an IO request into kernel virtual address space. * Index: sys/proc.h =================================================================== RCS file: /home/ncvs/src/sys/sys/proc.h,v retrieving revision 1.242 diff -u -2 -r1.242 proc.h --- sys/proc.h 6 Sep 2002 07:00:36 -0000 1.242 +++ sys/proc.h 6 Sep 2002 07:42:36 -0000 @@ -846,5 +846,4 @@ void cpu_set_fork_handler(struct thread *, void (*)(void *), void *); void cpu_wait(struct proc *); -int cpu_coredump(struct thread *, struct vnode *, struct ucred *); /* New in KSE. */ ? modules/aout/obj Index: modules/aout/Makefile =================================================================== RCS file: modules/aout/Makefile diff -N modules/aout/Makefile --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/aout/Makefile 6 Sep 2002 21:00:17 -0000 @@ -0,0 +1,11 @@ +# $FreeBSD$ + +.PATH: ${.CURDIR}/../../kern + +KMOD= aout +SRCS= imgact_aout.c \ + opt_kstack_pages.h vnode_if.h + +EXPORT_SYMS= + +.include