patch-2.1.23 linux/fs/exec.c

Next file: linux/fs/ext2/dir.c
Previous file: linux/fs/dquot.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.22/linux/fs/exec.c linux/fs/exec.c
@@ -26,6 +26,7 @@
 #include <linux/sched.h>
 #include <linux/kernel.h>
 #include <linux/mm.h>
+#include <linux/slab.h>
 #include <linux/mman.h>
 #include <linux/a.out.h>
 #include <linux/errno.h>
@@ -38,6 +39,8 @@
 #include <linux/malloc.h>
 #include <linux/binfmts.h>
 #include <linux/personality.h>
+#include <linux/smp.h>
+#include <linux/smp_lock.h>
 
 #include <asm/system.h>
 #include <asm/uaccess.h>
@@ -158,9 +161,11 @@
 	struct file * file;
 	struct linux_binfmt * fmt;
 
+	lock_kernel();
 	fd = sys_open(library, 0, 0);
+	retval = fd;
 	if (fd < 0)
-		return fd;
+		goto out;
 	file = current->files->fd[fd];
 	retval = -ENOEXEC;
 	if (file && file->f_inode && file->f_op && file->f_op->read) {
@@ -174,6 +179,8 @@
 		}
 	}
 	sys_close(fd);
+out:
+	unlock_kernel();
   	return retval;
 }
 
@@ -286,7 +293,7 @@
 		bprm->loader += stack_base;
 	bprm->exec += stack_base;
 
-	mpnt = (struct vm_area_struct *)kmalloc(sizeof(*mpnt), GFP_KERNEL);
+	mpnt = kmem_cache_alloc(vm_area_cachep, SLAB_KERNEL);
 	if (mpnt) {
 		mpnt->vm_mm = current->mm;
 		mpnt->vm_start = PAGE_MASK & (unsigned long) p;
@@ -607,7 +614,7 @@
 			    printable(bprm->buf[2]) &&
 			    printable(bprm->buf[3]))
 				break; /* -ENOEXEC */
-			sprintf(modname, "binfmt-%hd", *(short*)(&bprm->buf));
+			sprintf(modname, "binfmt-%04x", *(unsigned short *)(&bprm->buf[2]));
 			request_module(modname);
 #endif
 		}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov