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 Mmh, restore %cs and %ss on Xen. Otherw...



details:   https://anonhg.NetBSD.org/src/rev/d2eda66c87f4
branches:  trunk
changeset: 355763:d2eda66c87f4
user:      maxv <maxv%NetBSD.org@localhost>
date:      Sun Aug 13 08:07:52 2017 +0000

description:
Mmh, restore %cs and %ss on Xen. Otherwise (unpriv) userland could set a
non-three ring, causing the hypervisor to send a fatal interrupt to the
kernel.

diffstat:

 sys/arch/amd64/amd64/process_machdep.c |  11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diffs (33 lines):

diff -r cc2150092f5a -r d2eda66c87f4 sys/arch/amd64/amd64/process_machdep.c
--- a/sys/arch/amd64/amd64/process_machdep.c    Sun Aug 13 07:16:44 2017 +0000
+++ b/sys/arch/amd64/amd64/process_machdep.c    Sun Aug 13 08:07:52 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: process_machdep.c,v 1.34 2017/08/13 07:16:44 maxv Exp $        */
+/*     $NetBSD: process_machdep.c,v 1.35 2017/08/13 08:07:52 maxv Exp $        */
 
 /*
  * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc.
@@ -74,8 +74,9 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.34 2017/08/13 07:16:44 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: process_machdep.c,v 1.35 2017/08/13 08:07:52 maxv Exp $");
 
+#include "opt_xen.h"
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/time.h>
@@ -155,6 +156,12 @@
        tf->tf_err = err;
        tf->tf_trapno = trapno;
 
+#ifdef XEN
+       /* see comment in cpu_setmcontext */
+       tf->tf_ss = GSEL(GUDATA_SEL, SEL_UPL);
+       tf->tf_cs = GSEL(GUCODE_SEL, SEL_UPL);
+#endif
+
        return 0;
 }
 



Home | Main Index | Thread Index | Old Index