aboutsummaryrefslogtreecommitdiffstats
path: root/fs/binfmt_em86.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-04-29 03:59:24 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:04 -0400
commit3a2e7f47d71e1df86acc1dda6826890b6546a4e1 (patch)
tree3c5856f67af25a80a4d934e754f437936c7b1bbf /fs/binfmt_em86.c
parentcbd9b67bd3883dff0ef4b8ec9229d315a9ba38f0 (diff)
binfmt_misc.c: avoid potential kernel stack overflow
This can be triggered with root help only, but... Register the ":text:E::txt::/root/cat.txt:' rule in binfmt_misc (by root) and try launching the cat.txt file (by anyone) :) The result is - the endless recursion in the load_misc_binary -> open_exec -> load_misc_binary chain and stack overflow. There's a similar problem with binfmt_script, and there's a sh_bang memner on linux_binprm structure to handle this, but simply raising this in binfmt_misc may break some setups when the interpreter of some misc binaries is a script. So the proposal is to turn sh_bang into a bit, add a new one (the misc_bang) and raise it in load_misc_binary. After this, even if we set up the misc -> script -> misc loop for binfmts one of them will step on its own bang and exit. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/binfmt_em86.c')
-rw-r--r--fs/binfmt_em86.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/fs/binfmt_em86.c b/fs/binfmt_em86.c
index f95ae9789c91..f9c88d0c8ced 100644
--- a/fs/binfmt_em86.c
+++ b/fs/binfmt_em86.c
@@ -43,7 +43,7 @@ static int load_em86(struct linux_binprm *bprm,struct pt_regs *regs)
43 return -ENOEXEC; 43 return -ENOEXEC;
44 } 44 }
45 45
46 bprm->sh_bang++; /* Well, the bang-shell is implicit... */ 46 bprm->sh_bang = 1; /* Well, the bang-shell is implicit... */
47 allow_write_access(bprm->file); 47 allow_write_access(bprm->file);
48 fput(bprm->file); 48 fput(bprm->file);
49 bprm->file = NULL; 49 bprm->file = NULL;