a question on i386 copy_thread()

Ray Lehtiniemi (rayl@crosskeys.com)
Sun, 6 Apr 1997 00:17:58 -0500 (EST)


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);
}

i assume the fact we're overwriting p->ldt is because the pointer was
copied from our parent earlier in the fork, and we're now creating our own
ldt instead of pointing to the parents ldt.

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?

---------------------------------------------------------------------------
Ray Lehtiniemi <rayl@crosskeys.com>