Skip to contentSkip to conversation

Bug in binfmt_misc?

PATCH New Rusty Russell 1 participant 1 message Feb 11, 2003

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

PATCH 1/1 Bug in binfmt_misc?

As far as I can tell, this should never cause a problem, but someone pointed this out:

fs/binfmt_misc.c +2 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.4.21-pre4/fs/binfmt_misc.c working-2.4.21-pre4-rest-non_drivers/fs/binfmt_misc.c
@@ -128,6 +128,8 @@ static int load_misc_binary(struct linux
 	retval = copy_strings_kernel(1, &iname_addr, bprm);
 	if (retval < 0) goto _ret; 
 	bprm->argc++;
+	/* BUG: iname is a local variable and given to an outside struct.
+	 * 	this will cause problems when function scope ends */
 	bprm->filename = iname;	/* for binfmt_script */
 
 	file = open_exec(iname);

Now, if this isn't a problem, the following should at least catch any future misuses:

fs/binfmt_misc.c +1 -0
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal linux-2.4.21-pre4/fs/binfmt_misc.c working-2.4.21-pre4-rest-non_drivers/fs/binfmt_misc.c
@@ -139,6 +139,7 @@ static int load_misc_binary(struct linux
 	retval = prepare_binprm(bprm);
 	if (retval >= 0)
 		retval = search_binary_handler(bprm, regs);
+	bprm->filename = NULL;
 _ret:
 	return retval;
 }

--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.