Date: Fri, 1 Aug 2003 17:02:16 -0700 (PDT) From: Julian Elischer <julian@elischer.org> To: deischen@freebsd.org Cc: Marcel Moolenaar <marcel@xcllnt.net> Subject: Re: NVidia glx stuff dies in sysarch(I386_SET_LDT, ...) Message-ID: <Pine.BSF.4.21.0308011659270.46065-100000@InterJet.elischer.org> In-Reply-To: <Pine.GSO.4.10.10308011947500.6535-100000@pcnet5.pcnet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 1 Aug 2003, Daniel Eischen wrote:
> On Fri, 1 Aug 2003, Marcel Moolenaar wrote:
>
> OpenGL is the example that I was thinking about.
>
> > Having a way to disallow using the static allocation should be easy
> > if we use compiler magic to test that the LDT entry is constant and
> > 0. If it is, all is ok (assuming that I'm not mistaken that we use a
> > 0 entry to indicate dynamic allocation -- I haven't actually paid
> > that close attention to it). If the LDT entry is non-constant, it
> > can still be 0 of course but I expect that to be a weird border case.
>
> This is all good :-)
Here's my first patch..
I'd suggest this (along with man page change) to go in first
for a while before we break people's code.
cvs server: Diffing .
Index: sys_machdep.c
===================================================================
RCS file: /home/ncvs/src/sys/i386/i386/sys_machdep.c,v
retrieving revision 1.86
diff -u -r1.86 sys_machdep.c
--- sys_machdep.c 31 Jul 2003 08:20:24 -0000 1.86
+++ sys_machdep.c 1 Aug 2003 23:58:29 -0000
@@ -410,6 +410,9 @@
return(error);
}
+static int ldt_warnings;
+#define NUM_LDT_WARNINGS 10
+
static int
i386_set_ldt(td, args)
struct thread *td;
@@ -441,7 +444,7 @@
uap->start = NLDT;
uap->num = MAX_LD - NLDT;
}
- if (uap->start < NLDT || uap->num <= 0)
+ if (uap->start <= LUDATA_SEL || uap->num <= 0)
return (EINVAL);
mtx_lock_spin(&sched_lock);
pldt = mdp->md_ldt;
@@ -460,10 +463,16 @@
}
if (!(uap->start == 0 && uap->num == 1)) {
+ /* complain a for a while if using old methods */
+ if (ldt_warnings++ < NUM_LDT_WARNINGS) {
+ printf("Warning: pid %d used static ldt
allocation.\n",
+ td->td_proc->p_pid);
+ printf("See the i386_set_ldt man page for more
info\n");
+ }
/* verify range of descriptors to modify */
largest_ld = uap->start + uap->num;
- if (uap->start < NLDT || uap->start >= MAX_LD ||
uap->num < 0 ||
- largest_ld > MAX_LD) {
+ if (uap->start <= LUDATA_SEL || uap->start >= MAX_LD ||
+ uap->num < 0 || largest_ld > MAX_LD) {
return (EINVAL);
}
}
@@ -562,7 +571,7 @@
again:
mtx_lock_spin(&sched_lock);
dp = &((union descriptor *)(pldt->ldt_base))[NLDT];
- for (i = NLDT; i < pldt->ldt_len; ++i) {
+ for (i = LUDATA_SEL + 1; i < pldt->ldt_len; ++i) {
if (dp->sd.sd_type == SDT_SYSNULL)
break;
dp++;
(beware white space munging.. (copy&paste))
I'd follow this with actual breakage oafer say 3 months.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0308011659270.46065-100000>
