public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [CRYPTO] padlock: Fix alignment after aes_ctx rearrange
@ 2006-07-14  2:08 Michal Ludvig
  2006-07-14  2:14 ` Michal Ludvig
  2006-07-15  1:25 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Michal Ludvig @ 2006-07-14  2:08 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Linux Crypto Mailing List, Linux Kernel Mailing List

Hi Herbert,

I just recently discovered that your patch that rearranges struct
aes_ctx in padlock-aes.c breaks the alignment rules for xcrypt leading
to GPF Oopses.

Note that *all* addresses passed to xcrypt must be 16-Bytes aligned for
VIA C3 (including IV and Key - the latter one was not aligned and
triggered this Oops).

As the rearrange patch made it to 2.6.18-rc1 it must be fixed before
2.6.18 is out. Attached is a patch.

Michal



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

* Re: [CRYPTO] padlock: Fix alignment after aes_ctx rearrange
  2006-07-14  2:08 [CRYPTO] padlock: Fix alignment after aes_ctx rearrange Michal Ludvig
@ 2006-07-14  2:14 ` Michal Ludvig
  2006-07-15  1:25 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Michal Ludvig @ 2006-07-14  2:14 UTC (permalink / raw)
  To: Herbert Xu; +Cc: Linux Crypto Mailing List, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 519 bytes --]

Michal Ludvig wrote:
> Hi Herbert,
> 
> I just recently discovered that your patch that rearranges struct
> aes_ctx in padlock-aes.c breaks the alignment rules for xcrypt leading
> to GPF Oopses.
> 
> Note that *all* addresses passed to xcrypt must be 16-Bytes aligned for
> VIA C3 (including IV and Key - the latter one was not aligned and
> triggered this Oops).
> 
> As the rearrange patch made it to 2.6.18-rc1 it must be fixed before
> 2.6.18 is out. Attached is a patch.

Ehrm, ... now it is attached ;-)

Michal

[-- Attachment #2: fix-alignment-of-aes_ctx.diff --]
[-- Type: text/x-patch, Size: 1269 bytes --]

Subject: padlock: Fix alignment after aes_ctx rearrange

Herbert's patch 82062c72cd643c99a9e1c231270acbab986fd23f 
in cryptodev-2.6 tree breaks alignment rules for PadLock 
xcrypt instruction leading to General protection Oopses.

This patch fixes the problem.

Signed-off-by: Michal Ludvig <michal@logix.cz>

Index: linux-2.6.16.13-xenU/drivers/crypto/padlock-aes.c
===================================================================
--- linux-2.6.16.13-xenU.orig/drivers/crypto/padlock-aes.c
+++ linux-2.6.16.13-xenU/drivers/crypto/padlock-aes.c
@@ -59,6 +59,9 @@
 #define AES_EXTENDED_KEY_SIZE	64	/* in uint32_t units */
 #define AES_EXTENDED_KEY_SIZE_B	(AES_EXTENDED_KEY_SIZE * sizeof(uint32_t))
 
+/* Whenever making any changes to the following
+ * structure *make sure* you keep E, d_data
+ * and cword aligned on 16 Bytes boundaries!!! */
 struct aes_ctx {
 	struct {
 		struct cword encrypt;
@@ -66,8 +69,10 @@ struct aes_ctx {
 	} cword;
 	u32 *D;
 	int key_length;
-	u32 E[AES_EXTENDED_KEY_SIZE];
-	u32 d_data[AES_EXTENDED_KEY_SIZE];
+	u32 E[AES_EXTENDED_KEY_SIZE]
+		__attribute__ ((__aligned__(PADLOCK_ALIGNMENT)));
+	u32 d_data[AES_EXTENDED_KEY_SIZE]
+		__attribute__ ((__aligned__(PADLOCK_ALIGNMENT)));
 };
 
 /* ====== Key management routines ====== */

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

* Re: [CRYPTO] padlock: Fix alignment after aes_ctx rearrange
  2006-07-14  2:08 [CRYPTO] padlock: Fix alignment after aes_ctx rearrange Michal Ludvig
  2006-07-14  2:14 ` Michal Ludvig
@ 2006-07-15  1:25 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2006-07-15  1:25 UTC (permalink / raw)
  To: Michal Ludvig; +Cc: Linux Crypto Mailing List, Linux Kernel Mailing List

On Fri, Jul 14, 2006 at 02:08:16PM +1200, Michal Ludvig wrote:
> 
> I just recently discovered that your patch that rearranges struct
> aes_ctx in padlock-aes.c breaks the alignment rules for xcrypt leading
> to GPF Oopses.

Thanks a lot for catching this.

I've pushed the bug fix along.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

end of thread, other threads:[~2006-07-15  1:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-14  2:08 [CRYPTO] padlock: Fix alignment after aes_ctx rearrange Michal Ludvig
2006-07-14  2:14 ` Michal Ludvig
2006-07-15  1:25 ` Herbert Xu

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