Fix several panics that can be caused by applications using
bad segment register values with setcontext() or sigreturn().
This commit is contained in:
parent
5520795ab6
commit
0c9fb0464e
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: netbsd32_machdep.c,v 1.64 2010/07/07 01:14:52 chs Exp $ */
|
||||
/* $NetBSD: netbsd32_machdep.c,v 1.65 2010/08/08 18:13:54 chs Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001 Wasabi Systems, Inc.
|
||||
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.64 2010/07/07 01:14:52 chs Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.65 2010/08/08 18:13:54 chs Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_compat_netbsd.h"
|
||||
|
@ -961,7 +961,8 @@ check_sigcontext32(struct lwp *l, const struct netbsd32_sigcontext *scp)
|
|||
tf = l->l_md.md_regs;
|
||||
pcb = lwp_getpcb(curlwp);
|
||||
|
||||
if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0)
|
||||
if (((scp->sc_eflags ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 ||
|
||||
scp->sc_cs != GSEL(GUCODE32_SEL, SEL_UPL))
|
||||
return EINVAL;
|
||||
if (scp->sc_fs != 0 && !VALID_USER_DSEL32(scp->sc_fs) &&
|
||||
!(scp->sc_fs == GSEL(GUFS_SEL, SEL_UPL) && pcb->pcb_fs != 0))
|
||||
|
@ -989,7 +990,8 @@ check_mcontext32(struct lwp *l, const mcontext32_t *mcp)
|
|||
tf = l->l_md.md_regs;
|
||||
pcb = lwp_getpcb(l);
|
||||
|
||||
if (((gr[_REG32_EFL] ^ tf->tf_rflags) & PSL_USERSTATIC) != 0)
|
||||
if (((gr[_REG32_EFL] ^ tf->tf_rflags) & PSL_USERSTATIC) != 0 ||
|
||||
gr[_REG32_CS] != GSEL(GUCODE32_SEL, SEL_UPL))
|
||||
return EINVAL;
|
||||
if (gr[_REG32_FS] != 0 && !VALID_USER_DSEL32(gr[_REG32_FS]) &&
|
||||
!(gr[_REG32_FS] == GSEL(GUFS_SEL, SEL_UPL) && pcb->pcb_fs != 0))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: trap.c,v 1.258 2010/07/25 19:19:06 christos Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.259 2010/08/08 18:13:54 chs Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1998, 2000, 2005, 2006, 2007, 2008 The NetBSD Foundation, Inc.
|
||||
|
@ -68,7 +68,7 @@
|
|||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.258 2010/07/25 19:19:06 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.259 2010/08/08 18:13:54 chs Exp $");
|
||||
|
||||
#include "opt_ddb.h"
|
||||
#include "opt_kgdb.h"
|
||||
|
@ -442,6 +442,7 @@ copyfault:
|
|||
* returning from a trap, syscall, or interrupt.
|
||||
*/
|
||||
|
||||
kernelfault:
|
||||
KSI_INIT_TRAP(&ksi);
|
||||
ksi.ksi_signo = SIGSEGV;
|
||||
ksi.ksi_code = SEGV_ACCERR;
|
||||
|
@ -759,7 +760,7 @@ faultcommon:
|
|||
goto copyfault;
|
||||
printf("uvm_fault(%p, %#lx, %d) -> %#x\n",
|
||||
map, va, ftype, error);
|
||||
goto we_re_toast;
|
||||
goto kernelfault;
|
||||
}
|
||||
if (error == ENOMEM) {
|
||||
ksi.ksi_signo = SIGKILL;
|
||||
|
|
Loading…
Reference in New Issue