Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/amd64/amd64 Do mask the upper 16 bits, when sanity ...
details: https://anonhg.NetBSD.org/src/rev/a8a01271436b
branches: trunk
changeset: 761419:a8a01271436b
user: njoly <njoly%NetBSD.org@localhost>
date: Wed Jan 26 21:44:31 2011 +0000
description:
Do mask the upper 16 bits, when sanity checking fs/gs register values.
Fix my own PR/43842.
diffstat:
sys/arch/amd64/amd64/netbsd32_machdep.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diffs (57 lines):
diff -r 9e4ea89c66f1 -r a8a01271436b sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c Wed Jan 26 21:35:14 2011 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c Wed Jan 26 21:44:31 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: netbsd32_machdep.c,v 1.68 2010/11/17 18:22:17 dholland Exp $ */
+/* $NetBSD: netbsd32_machdep.c,v 1.69 2011/01/26 21:44:31 njoly Exp $ */
/*
* Copyright (c) 2001 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.68 2010/11/17 18:22:17 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.69 2011/01/26 21:44:31 njoly Exp $");
#ifdef _KERNEL_OPT
#include "opt_compat_netbsd.h"
@@ -952,6 +952,12 @@
* and rely on catching invalid user contexts on exit from the kernel.
* These functions perform the needed checks.
*/
+
+#define VALID_FS32(s) \
+ (((s) & 0xffff) == GSEL(GUFS_SEL, SEL_UPL))
+#define VALID_GS32(s) \
+ (((s) & 0xffff) == GSEL(GUGS_SEL, SEL_UPL))
+
static int
check_sigcontext32(struct lwp *l, const struct netbsd32_sigcontext *scp)
{
@@ -965,10 +971,10 @@
!VALID_USER_CSEL32(scp->sc_cs))
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))
+ !(VALID_FS32(scp->sc_fs) && pcb->pcb_fs != 0))
return EINVAL;
if (scp->sc_gs != 0 && !VALID_USER_DSEL32(scp->sc_gs) &&
- !(scp->sc_gs == GSEL(GUGS_SEL, SEL_UPL) && pcb->pcb_gs != 0))
+ !(VALID_GS32(scp->sc_gs) && pcb->pcb_gs != 0))
return EINVAL;
if (scp->sc_es != 0 && !VALID_USER_DSEL32(scp->sc_es))
return EINVAL;
@@ -994,10 +1000,10 @@
!VALID_USER_CSEL32(gr[_REG32_CS]))
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))
+ !(VALID_FS32(gr[_REG32_FS]) && pcb->pcb_fs != 0))
return EINVAL;
if (gr[_REG32_GS] != 0 && !VALID_USER_DSEL32(gr[_REG32_GS]) &&
- !(gr[_REG32_GS] == GSEL(GUGS_SEL, SEL_UPL) && pcb->pcb_gs != 0))
+ !(VALID_GS32(gr[_REG32_GS]) && pcb->pcb_gs != 0))
return EINVAL;
if (gr[_REG32_ES] != 0 && !VALID_USER_DSEL32(gr[_REG32_ES]))
return EINVAL;
Home |
Main Index |
Thread Index |
Old Index