patch for 2.1.115 wabi problem

Bill Hawes (whawes@transmeta.com)
Sat, 08 Aug 1998 10:18:55 -0700


This is a multi-part message in MIME format.
--------------9EB99FAE50317BB8B2008AC5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi Dave,

After some further analysis of the wabi problem you reported, I've found the
apparent problem and have attached a patch that should fix it.

The problem arose whenever kmod was launched from the wabi task. The kmod
process is created with CLONE_VM set, so it shares the mm struct and ldt with
the original wabi process. But when kmod does an exec to run the modprobe
process, exec_mmap() allocates a new mm structure, but failed to create a new
private ldt. Then when the modprobe exited, the ldt was released even though
it was still in use by wabi.

The patch fixes this by changing exec_mmap to create a private ldt for the new
mm struct, and to restore the old ldt if there's a failure.

I haven't actually tested the patch with wabi, but it passes the Torvalds-test
and should work OK.

Regards,
Bill

--------------9EB99FAE50317BB8B2008AC5
Content-Type: text/plain; charset=us-ascii; name="fs_exec115-patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="fs_exec115-patch"

--- linux-2.1.115/fs/exec.c.old Thu May 21 14:21:31 1998
+++ linux-2.1.115/fs/exec.c Sat Aug 8 09:48:58 1998
@@ -392,7 +392,7 @@
static int exec_mmap(void)
{
struct mm_struct * mm, * old_mm;
- int retval;
+ int retval, nr;

if (current->mm->count == 1) {
flush_cache_mm(current->mm);
@@ -411,9 +411,16 @@
mm = mm_alloc();
if (!mm)
goto fail_nomem;
+
mm->cpu_vm_mask = (1UL << smp_processor_id());
mm->total_vm = 0;
mm->rss = 0;
+ /*
+ * Make sure we have a private ldt if needed ...
+ */
+ nr = current->tarray_ptr - &task[0];
+ copy_segments(nr, current, mm);
+
old_mm = current->mm;
current->mm = mm;
retval = new_page_tables(current);
@@ -431,6 +438,8 @@
/* The pgd belongs to the parent ... don't free it! */
mm->pgd = NULL;
current->mm = old_mm;
+ /* restore the ldt for this task */
+ copy_segments(nr, current, NULL);
mmput(mm);

fail_nomem:

--------------9EB99FAE50317BB8B2008AC5--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html