diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-08-20 17:09:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-08-20 18:40:31 -0400 |
commit | ff9bc512f198eb47204f55b24c6fe3d36ed89592 (patch) | |
tree | e55d1639a5a3f8c0ef1827fae4ff8529d4ffef04 /fs/binfmt_misc.c | |
parent | c82f2966015a2c9708fb8f20694ef7ba8567d2e1 (diff) |
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>
Diffstat (limited to 'fs/binfmt_misc.c')
-rw-r--r-- | fs/binfmt_misc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c index 756205314c2..8d7e88e02e0 100644 --- a/fs/binfmt_misc.c +++ b/fs/binfmt_misc.c | |||
@@ -120,8 +120,6 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
120 | if (bprm->misc_bang) | 120 | if (bprm->misc_bang) |
121 | goto _ret; | 121 | goto _ret; |
122 | 122 | ||
123 | bprm->misc_bang = 1; | ||
124 | |||
125 | /* to keep locking time low, we copy the interpreter string */ | 123 | /* to keep locking time low, we copy the interpreter string */ |
126 | read_lock(&entries_lock); | 124 | read_lock(&entries_lock); |
127 | fmt = check_file(bprm); | 125 | fmt = check_file(bprm); |
@@ -199,6 +197,8 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs) | |||
199 | if (retval < 0) | 197 | if (retval < 0) |
200 | goto _error; | 198 | goto _error; |
201 | 199 | ||
200 | bprm->misc_bang = 1; | ||
201 | |||
202 | retval = search_binary_handler (bprm, regs); | 202 | retval = search_binary_handler (bprm, regs); |
203 | if (retval < 0) | 203 | if (retval < 0) |
204 | goto _error; | 204 | goto _error; |