Re: a question on i386 copy_thread()

James Mastros (root@epix.net)
Mon, 7 Apr 1997 16:29:05 -0500 (EST)


On Sun, 6 Apr 1997, Bryn Paul Arnold Jones wrote:

> On Sun, 6 Apr 1997, Ray Lehtiniemi wrote:
>
> >
> > hi all
> >
> > i'm still working my way through sys_fork() here. i have a question about
> > the following code in arch/i386/kernel/process.c:copy_thread().
> >
> > if (p->ldt) {
> > p->ldt = (struct desc_struct*) vmalloc(LDT_ENTRIES*LDT_ENTRY_SIZE);
> > if (p->ldt != NULL)
> > memcpy(p->ldt, current->ldt, LDT_ENTRIES*LDT_ENTRY_SIZE);
> > }
> >
[...]
> > my question is:
> >
> > what happens if the vmalloc fails?
> >
> > the code appears to use &default_ldt if p->ldt is NULL. however, my
> > understanding of LDT is that it tells you the base and size of all your
> > memory segments. if we're a duplicate of our parent, except our ldts are
> > completely different, really bad things will happen, no?
> >
>
> Nope, if the vmalloc fails, p->ldt would be NULL (hence the test that it
> isn't), and the next time we try to do anything with it, we'll have a NULL
> pointer dereferance.
>
> > Ray Lehtiniemi <rayl@crosskeys.com>
> >
> Bryn

...a NULL pointer dereference... also known as a bad thing!

-=- James Mastros