Re: a question on i386 copy_thread()

Ingo Molnar (mingo@pc5829.hil.siemens.at)
Sun, 6 Apr 1997 20:53:21 +0200 (MET DST)


On Sun, 6 Apr 1997, Ray Lehtiniemi wrote:

> 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?

it looks like we should do a return(-ENOMEM) if vmalloc() fails. It looks
like a bug?

> 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?

the LDT is unused except in DOSEMU vm86 tasks or in wine, but if it's used
it doesnt seem correct to silently use the default LDT when vmalloc()
fails.

-- mingo