From 2dc8401e2377e3ce7bee5c57bfd504f71c406cd9 Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Tue, 20 May 1997 00:00:00 +0000 Subject: [PATCH] Plan 9 from Bell Labs 1997-05-20 --- pc/mem.h | 4 ++-- pc/trap.c | 16 ++++++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/pc/mem.h b/pc/mem.h index a7dc3e85e77cb28ab9061f0349b4edef4bd99594..76f4c6e2f499bac0e29c5ae0bfd4e6231a061ed1 100644 --- a/pc/mem.h +++ b/pc/mem.h @@ -73,8 +73,8 @@ #define UESEG 4 /* user executable */ #define TSSSEG 5 /* task segment */ -#define SELGDT (0<<3) /* selector is in gdt */ -#define SELLDT (1<<3) /* selector is in ldt */ +#define SELGDT (0<<2) /* selector is in gdt */ +#define SELLDT (1<<2) /* selector is in ldt */ #define SELECTOR(i, t, p) (((i)<<3) | (t) | (p)) diff --git a/pc/trap.c b/pc/trap.c index 8c399e957e3692d1792c757b2df475a9b6c49110..8a2950f3d35df091be686473905b08a74c0c406b 100644 --- a/pc/trap.c +++ b/pc/trap.c @@ -483,14 +483,22 @@ noted(Ureg* ureg, ulong arg0) /* sanity clause */ oureg = (ulong)nureg; if(!okaddr((ulong)oureg-BY2WD, BY2WD+sizeof(Ureg), 0)){ - pprint("bad ureg in noted or call to noted() when not notified\n"); + pprint("bad ureg in noted or call to noted when not notified\n"); qunlock(&up->debug); pexit("Suicide", 0); } - /* don't let user change text or stack segments */ - nureg->cs = ureg->cs; - nureg->ss = ureg->ss; + /* + * Check the segment selectors are all valid, otherwise + * a fault will be taken on attempting to return to the + * user process. + */ + if(nureg->cs != UESEL || nureg->ss != UDSEL || nureg->ds != UDSEL + || nureg->es != UDSEL || nureg->fs != UDSEL || nureg->gs != UDSEL){ + pprint("bad segement selector in noted\n"); + qunlock(&up->debug); + pexit("Suicide", 0); + } /* don't let user change system flags */ nureg->flags = (ureg->flags & ~0xCD5) | (nureg->flags & 0xCD5);