To: linux-m68k@lists.linux-m68k.org
Subject: L68K: Bug in mmap in 2.1.106
X-Yow: What UNIVERSE is this, please??
From: Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
Date: 19 Jun 1998 11:22:17 +0200
Sender: owner-linux-m68k@phil.uni-sb.de

This patch fixes a deadlock in the mmap syscall that happens if the
argument address faults (the fault handler tries to grap the mmap
semaphore again).  The i386 has the same bug.

Andreas.

----------------------------------------------------------------------
--- linux/arch/m68k/kernel/sys_m68k.c.~1~	Fri Jun 19 11:15:13 1998
+++ linux/arch/m68k/kernel/sys_m68k.c	Fri Jun 19 11:21:06 1998
@@ -66,7 +66,6 @@
 	struct file * file = NULL;
 	struct mmap_arg_struct a;
 
-	down(&current->mm->mmap_sem);
 	lock_kernel();
 	error = -EFAULT;
 	if (copy_from_user(&a, arg, sizeof(a)))
@@ -80,12 +79,13 @@
 	}
 	a.flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE);
 
+	down(&current->mm->mmap_sem);
 	error = do_mmap(file, a.addr, a.len, a.prot, a.flags, a.offset);
+	up(&current->mm->mmap_sem);
 	if (file)
 		fput(file);
 out:
 	unlock_kernel();
-	up(&current->mm->mmap_sem);
 	return error;
 }
 
