public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [2.6 patch] crypto/aes.c: array overrun
@ 2006-03-11  1:03 Adrian Bunk
  2006-03-11  2:41 ` Herbert Xu
  0 siblings, 1 reply; 8+ messages in thread
From: Adrian Bunk @ 2006-03-11  1:03 UTC (permalink / raw)
  To: herbert, davem; +Cc: linux-crypto, linux-kernel

The Coverity checker spotted the following in crypto/aes.c:

<--  snip  -->

...
struct aes_ctx {
        int key_length;
        u32 E[60];
        u32 D[60];
};

#define E_KEY ctx->E
...
#define loop8(i)                                    \
{   t = ror32(t,  8); ; t = ls_box(t) ^ rco_tab[i];  \
    t ^= E_KEY[8 * i];     E_KEY[8 * i + 8] = t;    \
    t ^= E_KEY[8 * i + 1]; E_KEY[8 * i + 9] = t;    \
    t ^= E_KEY[8 * i + 2]; E_KEY[8 * i + 10] = t;   \
    t ^= E_KEY[8 * i + 3]; E_KEY[8 * i + 11] = t;   \
    t  = E_KEY[8 * i + 4] ^ ls_box(t);    \
    E_KEY[8 * i + 12] = t;                \
    t ^= E_KEY[8 * i + 5]; E_KEY[8 * i + 13] = t;   \
    t ^= E_KEY[8 * i + 6]; E_KEY[8 * i + 14] = t;   \
    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);
...

<--  snip  -->


The problem is:

  8 * 6 + 15 = 63  >  59


cu
Adrian

-- 

       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-03-15 10:13 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox