[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jLjffRB6FcgPvg=gvsOk8cX-+nMgzFGmndm_PLMxdWk=Q@mail.gmail.com>
Date: Tue, 30 Oct 2012 18:06:48 -0700
From: Kees Cook <keescook@...omium.org>
To: David Howells <dhowells@...hat.com>
Cc: rusty@...tcorp.com.au, pjones@...hat.com, jwboyer@...hat.com,
mjg@...hat.com, dmitry.kasatkin@...el.com,
zohar@...ux.vnet.ibm.com, keyrings@...ux-nfs.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 16/23] pefile: Parse a PE binary to find a key and a
signature contained therein
On Tue, Oct 30, 2012 at 5:59 PM, David Howells <dhowells@...hat.com> wrote:
> Kees Cook <keescook@...omium.org> wrote:
>
>> This multiplication can push the cursor out of bounds. (n_data_dirents
>> is unverified).
>> ...
>> Both of these cases of n_sections multiplications can wrap.
>> Ultimately, you can end up with cursor close to zero, but n_sections
>> being giant.
>
> Good points. I wonder if I should limit these to some low number, or just
> check that they don't exceed header_size, which also needs checking as you
> said.
I think header_size can be bounded by datalen? I didn't investigate
that one very deeply. For the multiplications, I think you can just do
a check before chkaddr:
ctx->n_sections = pe->sections;
if (datalen / ctx->n_sections > sizeof(*sec))
return -ELIBBAD;
chkaddr(0, cursor, sizeof(*sec) * ctx->n_sections);
Or extend chkaddr to do the check for you:
chkaddr(0, cursor, sizeof(*sec), ctx->n_sections);
with other callers just using "1" for the final argument.
Either way, you won't have to choose arbitrary limits.
-Kees
--
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists