Skip to contentSkip to conversation

error out on execve with no binfmts

PATCH In review Chris Wright 2 participants 3 messages Oct 28, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 error out on execve with no binfmts

Early calls to userspace can invoke an execve() before any binfmt handlers are registered. Properly return an error in this case rather than 0. On at least one arch (x86_64) without this patch, the system will double fault on early attempts to call_usermodehelper. Suggestions on a better error?

===== fs/exec.c 1.142 vs edited =====

fs/exec.c +2 -1
@@ -984,7 +984,7 @@
  */
 int search_binary_handler(struct linux_binprm *bprm,struct pt_regs *regs)
 {
-	int try,retval=0;
+	int try,retval;
 	struct linux_binfmt *fmt;
 #ifdef __alpha__
 	/* handle /sbin/loader.. */
@@ -1028,6 +1028,7 @@
 	/* kernel module loader fixup */
 	/* so we don't try to load run modprobe in kernel space. */
 	set_fs(USER_DS);
+	retval = -ENOENT;
 	for (try=0; try<2; try++) {
 		read_lock(&binfmt_lock);
 		for (fmt = formats ; fmt ; fmt = fmt->next) {
#1 lore raw
Quoted 6 lines · Chris Wright

Early calls to userspace can invoke an execve() before any binfmt handlers are registered. Properly return an error in this case rather than 0. On at least one arch (x86_64) without this patch, the system will double fault on early attempts to call_usermodehelper. Suggestions on a better error?

These handlers are installed at core_initcall() time. Who is calling out to userspace so early?

#2 lore raw
Quoted 10 lines · * Andrew Morton ([email protected]) wrote:
Quoted 6 lines · Chris Wright

Early calls to userspace can invoke an execve() before any binfmt handlers are registered. Properly return an error in this case rather than 0. On at least one arch (x86_64) without this patch, the system will double fault on early attempts to call_usermodehelper. Suggestions on a better error?

These handlers are installed at core_initcall() time. Who is calling out to userspace so early?

kobject_add()->kobject_hotplug() stuff during driver_init(), like platform bus initialization, etc.

thanks,
-chris

Signature · 1 line
Linux Security Modules     http://lsm.immunix.org     http://lsm.bkbits.net