Bug 459462 - kernel: binfmt_misc.c: avoid potential kernel stack overflow [mrg-1]
Summary: kernel: binfmt_misc.c: avoid potential kernel stack overflow [mrg-1]
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: realtime-kernel
Version: 1.1
Hardware: All
OS: Linux
medium
medium
Target Milestone: 1.0.3
: ---
Assignee: Red Hat Real Time Maintenance
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks: 459463 459464 459466 459467 459468 459470 459471
TreeView+ depends on / blocked
 
Reported: 2008-08-19 07:11 UTC by Eugene Teo (Security Response)
Modified: 2008-10-07 19:21 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-10-07 19:21:00 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2008:0857 0 normal SHIPPED_LIVE Important: kernel security and bug fix update 2008-10-07 19:18:59 UTC

Description Eugene Teo (Security Response) 2008-08-19 07:11:45 UTC
Description of problem:
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.

Note that this can be triggered with root help only.

http://lkml.org/lkml/2008/3/13/245

Comment 2 Eugene Teo (Security Response) 2008-08-19 07:17:35 UTC
(In reply to comment #1)
> Proposed upstream patch:
> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=3a2e7f47d71e1df86acc1dda6826890b6546a4e1

Note that there is a regression. See http://lkml.org/lkml/2008/8/18/544. The patch is not in upstream yet AFAIK.

Comment 3 Eugene Teo (Security Response) 2008-08-19 07:46:16 UTC
Steps to Reproduce:
1. as root user, run echo ":text:E::txt::/cat.txt:" > /proc/sys/fs/binfmt_misc/register; touch /cat.txt; chmod +x /cat.txt
2) as normal user, run /cat.txt

Comment 4 Eugene Teo (Security Response) 2008-08-21 02:38:34 UTC
(In reply to comment #2)
> (In reply to comment #1)
> > Proposed upstream patch:
> > http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=3a2e7f47d71e1df86acc1dda6826890b6546a4e1
> 
> Note that there is a regression. See http://lkml.org/lkml/2008/8/18/544. The
> patch is not in upstream yet AFAIK.

This is ff9bc512f198eb47204f55b24c6fe3d36ed89592

Comment 5 Luis Claudio R. Goncalves 2008-08-21 19:03:27 UTC
Added the commits below to the patch queue of -78 (MRG):

3a2e7f47d71e1df86acc1dda6826890b6546a4e1
ff9bc512f198eb47204f55b24c6fe3d36ed89592

Comment 7 David Sommerseth 2008-09-30 17:29:14 UTC
Verified.  Reproducing on 2.6.24.7-74rt causes hang, while 2.6.24.7-81rt behaves properly.

Upstream commit 3a2e7f47d71e1df86acc1dda6826890b6546a4e1 found as mrg-rt.git commit eccddc7dc8f3b0ff2cbc52acf17e4984e8f646e2

Upstream commit ff9bc512f198eb47204f55b24c6fe3d36ed89592 found as mrg-rt.git commit f43e371df762e53413e7a87d6b686ff66982e3ae.

Both commits found in mrg-rt-2.6.24.7-81.

Comment 9 errata-xmlrpc 2008-10-07 19:21:00 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2008-0857.html


Note You need to log in before you can comment on or make changes to this bug.