[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGXu5jJrbM+wocY3bA59JDqkKwpptb3PGWFq-RiXrD2cfig2uQ@mail.gmail.com>
Date:   Sun, 17 Feb 2019 09:41:24 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     Andrew Morton <akpm@...ux-foundation.org>,
        Oleg Nesterov <oleg@...hat.com>,
        Samuel Dionne-Riel <samuel@...nne-riel.com>,
        Richard Weinberger <richard.weinberger@...il.com>,
        Graham Christensen <graham@...hamc.com>,
        Michal Hocko <mhocko@...e.com>,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v4] exec: load_script: Do not exec truncated interpreter path
On Sun, Feb 17, 2019 at 9:30 AM Linus Torvalds
<torvalds@...ux-foundation.org> wrote:
>
> On Sun, Feb 17, 2019 at 1:09 AM Kees Cook <keescook@...omium.org> wrote:
> >
> > +static inline char *next_spacetab(char *first, const char *last)
> > +{
> > +       for (; first <= last; first++)
> > +               if (spacetab(*first))
> > +                       return first;
> > +       return NULL;
> > +}
>
> I think this should be "next_terminator()" and also stop at NUL.
>
> You do check for the NUL case here:
>
> > +               if (!next_spacetab(cp, buf_end) && *buf_end)
> > +                       return -ENOEXEC;
>
> but it means that if there's no space ot tab and it's a short file,
> you pointlessly walk to the end. No?
Yeah, that works. I'll send v5.
-- 
Kees Cook
Powered by blists - more mailing lists
 
