* [PATCH] crypto: padlock-aes: Use the correct mask when checking whether copying is required
@ 2009-10-27 23:25 Chuck Ebbert
2009-10-28 7:25 ` Herbert Xu
0 siblings, 1 reply; 4+ messages in thread
From: Chuck Ebbert @ 2009-10-27 23:25 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-kernel, linux-crypto
crypto: padlock-aes: Use the correct mask when checking whether copying is required
Masking with PAGE_SIZE is just wrong... and there's no need for the braces and return
statement either.
Signed-off-by: Chuck Ebbert <cebbert@redhat.com>
---
Can we get this in 2.6.32 and -stable? It fixes a fatal oops in the driver.
--- a/drivers/crypto/padlock-aes.c
+++ b/drivers/crypto/padlock-aes.c
@@ -236,19 +236,17 @@ static inline void ecb_crypt(const u8 *i
/* Padlock in ECB mode fetches at least ecb_fetch_bytes of data.
* We could avoid some copying here but it's probably not worth it.
*/
- if (unlikely(((unsigned long)in & PAGE_SIZE) + ecb_fetch_bytes > PAGE_SIZE)) {
+ if (unlikely(((unsigned long)in & ~PAGE_MASK) + ecb_fetch_bytes > PAGE_SIZE))
ecb_crypt_copy(in, out, key, cword, count);
- return;
- }
-
- rep_xcrypt_ecb(in, out, key, cword, count);
+ else
+ rep_xcrypt_ecb(in, out, key, cword, count);
}
static inline u8 *cbc_crypt(const u8 *in, u8 *out, u32 *key,
u8 *iv, struct cword *cword, int count)
{
/* Padlock in CBC mode fetches at least cbc_fetch_bytes of data. */
- if (unlikely(((unsigned long)in & PAGE_SIZE) + cbc_fetch_bytes > PAGE_SIZE))
+ if (unlikely(((unsigned long)in & ~PAGE_MASK) + cbc_fetch_bytes > PAGE_SIZE))
return cbc_crypt_copy(in, out, key, iv, cword, count);
return rep_xcrypt_cbc(in, out, key, iv, cword, count);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] crypto: padlock-aes: Use the correct mask when checking whether copying is required
2009-10-27 23:25 [PATCH] crypto: padlock-aes: Use the correct mask when checking whether copying is required Chuck Ebbert
@ 2009-10-28 7:25 ` Herbert Xu
2009-11-02 22:26 ` Chuck Ebbert
0 siblings, 1 reply; 4+ messages in thread
From: Herbert Xu @ 2009-10-28 7:25 UTC (permalink / raw)
To: Chuck Ebbert; +Cc: linux-kernel, linux-crypto
On Tue, Oct 27, 2009 at 07:25:33PM -0400, Chuck Ebbert wrote:
> crypto: padlock-aes: Use the correct mask when checking whether copying is required
>
> Masking with PAGE_SIZE is just wrong... and there's no need for the braces and return
Thanks for the patch, that does indeed look wrong.
> statement either.
But can we please keep unrelated stylistic changes in a separate
patch? In this case I'm not even sure that it is better than the
original.
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] 4+ messages in thread
* Re: [PATCH] crypto: padlock-aes: Use the correct mask when checking whether copying is required
2009-10-28 7:25 ` Herbert Xu
@ 2009-11-02 22:26 ` Chuck Ebbert
2009-11-03 15:32 ` Herbert Xu
0 siblings, 1 reply; 4+ messages in thread
From: Chuck Ebbert @ 2009-11-02 22:26 UTC (permalink / raw)
To: Herbert Xu; +Cc: linux-kernel, linux-crypto
crypto: padlock-aes: Use the correct mask when checking whether copying is required
Masking with PAGE_SIZE is just wrong...
Signed-off-by: Chuck Ebbert <cebbert@redhat.com>
--- vanilla-2.6.31.orig/drivers/crypto/padlock-aes.c
+++ vanilla-2.6.31/drivers/crypto/padlock-aes.c
@@ -236,7 +236,7 @@ static inline void ecb_crypt(const u8 *i
/* Padlock in ECB mode fetches at least ecb_fetch_bytes of data.
* We could avoid some copying here but it's probably not worth it.
*/
- if (unlikely(((unsigned long)in & PAGE_SIZE) + ecb_fetch_bytes > PAGE_SIZE)) {
+ if (unlikely(((unsigned long)in & ~PAGE_MASK) + ecb_fetch_bytes > PAGE_SIZE)) {
ecb_crypt_copy(in, out, key, cword, count);
return;
}
@@ -248,7 +248,7 @@ static inline u8 *cbc_crypt(const u8 *in
u8 *iv, struct cword *cword, int count)
{
/* Padlock in CBC mode fetches at least cbc_fetch_bytes of data. */
- if (unlikely(((unsigned long)in & PAGE_SIZE) + cbc_fetch_bytes > PAGE_SIZE))
+ if (unlikely(((unsigned long)in & ~PAGE_MASK) + cbc_fetch_bytes > PAGE_SIZE))
return cbc_crypt_copy(in, out, key, iv, cword, count);
return rep_xcrypt_cbc(in, out, key, iv, cword, count);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] crypto: padlock-aes: Use the correct mask when checking whether copying is required
2009-11-02 22:26 ` Chuck Ebbert
@ 2009-11-03 15:32 ` Herbert Xu
0 siblings, 0 replies; 4+ messages in thread
From: Herbert Xu @ 2009-11-03 15:32 UTC (permalink / raw)
To: Chuck Ebbert; +Cc: linux-kernel, linux-crypto
On Mon, Nov 02, 2009 at 05:26:50PM -0500, Chuck Ebbert wrote:
> crypto: padlock-aes: Use the correct mask when checking whether copying is required
>
> Masking with PAGE_SIZE is just wrong...
>
> Signed-off-by: Chuck Ebbert <cebbert@redhat.com>
Applied to crypto-2.6. Thanks Chuck!
--
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] 4+ messages in thread
end of thread, other threads:[~2009-11-03 15:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-10-27 23:25 [PATCH] crypto: padlock-aes: Use the correct mask when checking whether copying is required Chuck Ebbert
2009-10-28 7:25 ` Herbert Xu
2009-11-02 22:26 ` Chuck Ebbert
2009-11-03 15:32 ` Herbert Xu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®