diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-04-29 03:59:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-29 11:06:04 -0400 |
commit | 3a2e7f47d71e1df86acc1dda6826890b6546a4e1 (patch) | |
tree | 3c5856f67af25a80a4d934e754f437936c7b1bbf /include/linux/binfmts.h | |
parent | cbd9b67bd3883dff0ef4b8ec9229d315a9ba38f0 (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 'include/linux/binfmts.h')
-rw-r--r-- | include/linux/binfmts.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h index 1dd756731c95..b512e48f6d8e 100644 --- a/include/linux/binfmts.h +++ b/include/linux/binfmts.h | |||
@@ -34,7 +34,8 @@ struct linux_binprm{ | |||
34 | #endif | 34 | #endif |
35 | struct mm_struct *mm; | 35 | struct mm_struct *mm; |
36 | unsigned long p; /* current top of mem */ | 36 | unsigned long p; /* current top of mem */ |
37 | int sh_bang; | 37 | unsigned int sh_bang:1, |
38 | misc_bang:1; | ||
38 | struct file * file; | 39 | struct file * file; |
39 | int e_uid, e_gid; | 40 | int e_uid, e_gid; |
40 | kernel_cap_t cap_inheritable, cap_permitted; | 41 | kernel_cap_t cap_inheritable, cap_permitted; |