From: Pavel Emelyanov <xemul@openvz.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: kirill@shutemov.name, linux-kernel@vger.kernel.org,
torvalds@linux-foundation.org
Subject: Re: [PATCH] binfmt_misc.c: avoid potential kernel stack overflow
Date: Tue, 19 Aug 2008 14:08:22 +0400 [thread overview]
Message-ID: <48AA9B96.7000905@openvz.org> (raw)
In-Reply-To: <20080818162046.f6c41e84.akpm@linux-foundation.org>
Andrew Morton wrote:
> On Mon, 18 Aug 2008 18:09:23 +0400
> Pavel Emelyanov <xemul@openvz.org> wrote:
>
>> (Put lkml in Cc. The original message is beyond)
>>
>> Oops! My fault. The problem is that in case of modularized binfmt,
>> the appropriate binary handler gets registered _before_ the script
>> one and sets the misc_bang flag even too early.
>>
>> Thus when we launch a script the load_misc_binary sets this bang,
>> then returns error, since the binary is actually a script, then the
>> load_script_binary successfully loads the script, then it loads the
>> misc binary again, which exits with the -ENOEXEC error due to bang
>> set.
>>
>> This patch helped my box, what about yours?
>>
>> diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
>> index 7562053..8d7e88e 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)
>> if (bprm->misc_bang)
>> goto _ret;
>>
>> - bprm->misc_bang = 1;
>> -
>> /* to keep locking time low, we copy the interpreter string */
>> read_lock(&entries_lock);
>> fmt = check_file(bprm);
>> @@ -199,6 +197,8 @@ static int load_misc_binary(struct linux_binprm *bprm, struct pt_regs *regs)
>> if (retval < 0)
>> goto _error;
>>
>> + bprm->misc_bang = 1;
>> +
>> retval = search_binary_handler (bprm, regs);
>> if (retval < 0)
>> goto _error;
>
> <scrabble, hunt>
>
> I put together the below description. It has no signed-off-by: (yet).
Well, sorry for that, I just wanted to get the Kirill's approval of the
fix, while testing other things myself. I sent the properly formatted
patch later. So can you, please, pick the comment and/or subject from
that one (which is a bit less messy, I think)?
> Has this been sufficiently well tested and checked to be in a merge-ready
> state?
I have checked different combinations, so I believe it has.
> Thanks.
Thanks,
Pavel
prev parent reply other threads:[~2008-08-19 10:09 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080818112849.GA4951@localhost.localdomain>
2008-08-18 14:09 ` [PATCH] binfmt_misc.c: avoid potential kernel stack overflow Pavel Emelyanov
2008-08-18 14:44 ` Kirill A. Shutemov
2008-08-18 14:51 ` Kirill A. Shutemov
2008-08-18 23:20 ` Andrew Morton
2008-08-19 10:08 ` Pavel Emelyanov [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48AA9B96.7000905@openvz.org \
--to=xemul@openvz.org \
--cc=akpm@linux-foundation.org \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox