mirror of
https://github.com/torvalds/linux.git
synced 2024-11-23 20:51:44 +00:00
binfmt_misc: fix false -ENOEXEC when coupled with other binary handlers
In case the binfmt_misc binary handler is registered *before* the e.g.
script one (when for example being compiled as a module) the following
situation may occur:
1. user launches a script, whose interpreter is a misc binary;
2. the load_misc_binary sets the misc_bang and returns -ENOEVEC,
since the binary is a script;
3. the load_script_binary loads one and calls for search_binary_hander
to run the interpreter;
4. the load_misc_binary is called again, but refuses to load the
binary due to misc_bang bit set.
The fix is to move the misc_bang setting lower - prior to the actual
call to the search_binary_handler.
Caused by the commit 3a2e7f47
(binfmt_misc.c: avoid potential kernel
stack overflow)
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Reported-by: Kirill A. Shutemov <kirill@shutemov.name>
Tested-by: Kirill A. Shutemov <kirill@shutemov.name>
Cc: <stable@kernel.org> [2.6.26.x]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
c82f296601
commit
ff9bc512f1
@ -120,8 +120,6 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
|
|||||||
if (bprm->misc_bang)
|
if (bprm->misc_bang)
|
||||||
goto _ret;
|
goto _ret;
|
||||||
|
|
||||||
bprm->misc_bang = 1;
|
|
||||||
|
|
||||||
/* to keep locking time low, we copy the interpreter string */
|
/* to keep locking time low, we copy the interpreter string */
|
||||||
read_lock(&entries_lock);
|
read_lock(&entries_lock);
|
||||||
fmt = check_file(bprm);
|
fmt = check_file(bprm);
|
||||||
@ -199,6 +197,8 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
|
|||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto _error;
|
goto _error;
|
||||||
|
|
||||||
|
bprm->misc_bang = 1;
|
||||||
|
|
||||||
retval = search_binary_handler (bprm, regs);
|
retval = search_binary_handler (bprm, regs);
|
||||||
if (retval < 0)
|
if (retval < 0)
|
||||||
goto _error;
|
goto _error;
|
||||||
|
Loading…
Reference in New Issue
Block a user