From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, xemul@openvz.org, viro@zeniv.linux.org.uk
Subject: Re: [PATCH] Allow recursion in binfmt_script and binfmt_misc
Date: Tue, 9 Sep 2008 09:45:55 +0300 [thread overview]
Message-ID: <20080909064553.GB4859@localhost.localdomain> (raw)
In-Reply-To: <20080908153921.94780d5c.akpm@linux-foundation.org>
[-- Attachment #1: Type: text/plain, Size: 2059 bytes --]
On Mon, Sep 08, 2008 at 03:39:21PM -0700, Andrew Morton wrote:
> On Sat, 6 Sep 2008 18:09:55 +0300
> "Kirill A. Shutemov" <kirill@shutemov.name> wrote:
>
> > binfmt_script and binfmt_misc disallow recursion to avoid stack overflow
> > using sh_bang and misc_bang. It causes problem in some cases:
> >
> > $ echo '#!/bin/ls' > /tmp/t0
> > $ echo '#!/tmp/t0' > /tmp/t1
> > $ echo '#!/tmp/t1' > /tmp/t2
> > $ chmod +x /tmp/t*
> > $ /tmp/t2
> > zsh: exec format error: /tmp/t2
> >
> > Similar problem with binfmt_misc.
> >
> > This patch introduces field 'recursion_depth' into struct linux_binprm
> > to track recursion level in binfmt_misc and binfmt_script. If recursion
> > level more then BINPRM_MAX_RECURSION it generates -ENOEXEC.
> >
> >
> > ...
> >
> > --- a/include/linux/binfmts.h
> > +++ b/include/linux/binfmts.h
> > @@ -34,8 +34,7 @@ struct linux_binprm{
> > #endif
> > struct mm_struct *mm;
> > unsigned long p; /* current top of mem */
> > - unsigned int sh_bang:1,
> > - misc_bang:1;
> > + unsigned char recursion_depth;
> > #ifdef __alpha__
> > unsigned int taso:1;
> > #endif
>
> That's a strange position in which to add the new field. It will prevent
> the compiler from using the same word for sh_bang, misc_bang and taso.
>
> I fixed that up while fixing linux-next rejects.
Thanks.
> > @@ -61,6 +60,7 @@ struct linux_binprm{
> > #define BINPRM_FLAGS_EXECFD_BIT 1
> > #define BINPRM_FLAGS_EXECFD (1 << BINPRM_FLAGS_EXECFD_BIT)
> >
> > +#define BINPRM_MAX_RECURSION 4
>
> Why "4"?
It's enough for my goals. :)
We can increase it later if any user will need it.
> Why make linux_binprm.recursion_depth a u8? There would be
> practically (or actually) zero cost to making it 32-bit.
> Admittedly a depth >256 would be a bit odd, but did we gain
> anything from this restriction?
No.
Should I repost patch with unsigned int recursion_depth?
--
Regards, Kirill A. Shutemov
+ Belarus, Minsk
+ ALT Linux Team, http://www.altlinux.com/
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
prev parent reply other threads:[~2008-09-09 6:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-02 11:06 [PATCH] [RFC] Allow recursion in binfmt_script and binfmt_misc Kirill A. Shutemov
2008-09-06 15:09 ` [PATCH] Introduce field 'taso' into struct linux_binprm Kirill A. Shutemov
2008-09-06 15:09 ` [PATCH] Allow recursion in binfmt_script and binfmt_misc Kirill A. Shutemov
2008-09-08 22:39 ` Andrew Morton
2008-09-09 6:45 ` Kirill A. Shutemov [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=20080909064553.GB4859@localhost.localdomain \
--to=kirill@shutemov.name \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=xemul@openvz.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