1 From e8edb3cbd7dd8acf6c748a02d06ec1d82c4124ea Mon Sep 17 00:00:00 2001
2 From: Chuck Ebbert <cebbert@redhat.com>
3 Date: Tue, 3 Nov 2009 10:32:03 -0500
4 Subject: crypto: padlock-aes - Use the correct mask when checking whether copying is required
6 From: Chuck Ebbert <cebbert@redhat.com>
8 commit e8edb3cbd7dd8acf6c748a02d06ec1d82c4124ea upstream.
10 Masking with PAGE_SIZE is just wrong...
12 Signed-off-by: Chuck Ebbert <cebbert@redhat.com>
13 Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
14 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
17 drivers/crypto/padlock-aes.c | 4 ++--
18 1 file changed, 2 insertions(+), 2 deletions(-)
20 --- a/drivers/crypto/padlock-aes.c
21 +++ b/drivers/crypto/padlock-aes.c
22 @@ -236,7 +236,7 @@ static inline void ecb_crypt(const u8 *i
23 /* Padlock in ECB mode fetches at least ecb_fetch_bytes of data.
24 * We could avoid some copying here but it's probably not worth it.
26 - if (unlikely(((unsigned long)in & PAGE_SIZE) + ecb_fetch_bytes > PAGE_SIZE)) {
27 + if (unlikely(((unsigned long)in & ~PAGE_MASK) + ecb_fetch_bytes > PAGE_SIZE)) {
28 ecb_crypt_copy(in, out, key, cword, count);
31 @@ -248,7 +248,7 @@ static inline u8 *cbc_crypt(const u8 *in
32 u8 *iv, struct cword *cword, int count)
34 /* Padlock in CBC mode fetches at least cbc_fetch_bytes of data. */
35 - if (unlikely(((unsigned long)in & PAGE_SIZE) + cbc_fetch_bytes > PAGE_SIZE))
36 + if (unlikely(((unsigned long)in & ~PAGE_MASK) + cbc_fetch_bytes > PAGE_SIZE))
37 return cbc_crypt_copy(in, out, key, iv, cword, count);
39 return rep_xcrypt_cbc(in, out, key, iv, cword, count);