public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Adrian Bunk <bunk@stusta.de>,
	davem@davemloft.net, linux-crypto@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [2.6 patch] crypto/aes.c: array overrun
Date: Mon, 13 Mar 2006 11:30:06 +0100	[thread overview]
Message-ID: <20060313103006.GA3812@elf.ucw.cz> (raw)
In-Reply-To: <20060311024116.GA21856@gondor.apana.org.au>

On So 11-03-06 13:41:16, Herbert Xu wrote:
> On Sat, Mar 11, 2006 at 02:03:39AM +0100, Adrian Bunk wrote:
> >
> > ...
> > #define loop8(i)                                    \
> 
> ...
> 
> >     t ^= E_KEY[8 * i + 7]; E_KEY[8 * i + 15] = t;   \
> > }
> > 
> > static int
> > aes_set_key(void *ctx_arg, const u8 *in_key, unsigned int key_len, u32 *flags)
> > {
> > ...
> >         case 32:
> > ...
> >                 for (i = 0; i < 7; ++i)
> >                         loop8 (i);
> 
> OK this is not pretty but it is actually correct.  Notice how we only
                                  ~~~~~~~~~~~~~~~~~
> overstep the mark for E_KEY but never for D_KEY.  Since D_KEY is only
> initialised after this, it is OK for us to trash the start of D_KEY.
> 
> It's just a trick that makes the code slightly nicer (and no I didn't
> write this nor am I necessarily condoning it :)

Overstepping array is not correct C. Even if gcc lays it out in order
where array-to-be-thrashed is after it, so it works in practice, it is
not okay. [Some kind of security-hardened-gcc may stop this as buffer
overflow, for example]
								Pavel
-- 
161:    {

  reply	other threads:[~2006-03-13 10:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-03-11  1:03 [2.6 patch] crypto/aes.c: array overrun Adrian Bunk
2006-03-11  2:41 ` Herbert Xu
2006-03-13 10:30   ` Pavel Machek [this message]
2006-03-14 20:25   ` Valdis.Kletnieks
2006-03-14 22:54     ` David McCullough
2006-03-15  0:32       ` Herbert Xu
2006-03-15  1:11         ` David McCullough
2006-03-15 10:13           ` Herbert Xu

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=20060313103006.GA3812@elf.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=bunk@stusta.de \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.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