diff options
author | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-09-10 17:40:29 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-09-10 17:40:29 -0400 |
commit | 1e3cbe4c274b2794fd2888f2c71ea97c9b5f9519 (patch) | |
tree | 5663c2808cff68c18af3be7b0f7c09daaba8c4e9 | |
parent | e032d93e1a3b2facf17029a643faf141dcea5f70 (diff) | |
parent | 32528d0fbda1093eeeaa7d0a2c498bbb5154099d (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6:
[CRYPTO] blkcipher: Fix inverted test in blkcipher_get_spot
[CRYPTO] blkcipher: Fix handling of kmalloc page straddling
-rw-r--r-- | crypto/blkcipher.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/crypto/blkcipher.c b/crypto/blkcipher.c index 7755834b8846..d8f8ec320213 100644 --- a/crypto/blkcipher.c +++ b/crypto/blkcipher.c | |||
@@ -59,11 +59,13 @@ static inline void blkcipher_unmap_dst(struct blkcipher_walk *walk) | |||
59 | scatterwalk_unmap(walk->dst.virt.addr, 1); | 59 | scatterwalk_unmap(walk->dst.virt.addr, 1); |
60 | } | 60 | } |
61 | 61 | ||
62 | /* Get a spot of the specified length that does not straddle a page. | ||
63 | * The caller needs to ensure that there is enough space for this operation. | ||
64 | */ | ||
62 | static inline u8 *blkcipher_get_spot(u8 *start, unsigned int len) | 65 | static inline u8 *blkcipher_get_spot(u8 *start, unsigned int len) |
63 | { | 66 | { |
64 | if (offset_in_page(start + len) < len) | 67 | u8 *end_page = (u8 *)(((unsigned long)(start + len - 1)) & PAGE_MASK); |
65 | return (u8 *)((unsigned long)(start + len) & PAGE_MASK); | 68 | return start > end_page ? start : end_page; |
66 | return start; | ||
67 | } | 69 | } |
68 | 70 | ||
69 | static inline unsigned int blkcipher_done_slow(struct crypto_blkcipher *tfm, | 71 | static inline unsigned int blkcipher_done_slow(struct crypto_blkcipher *tfm, |
@@ -155,7 +157,8 @@ static inline int blkcipher_next_slow(struct blkcipher_desc *desc, | |||
155 | if (walk->buffer) | 157 | if (walk->buffer) |
156 | goto ok; | 158 | goto ok; |
157 | 159 | ||
158 | n = bsize * 2 + (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); | 160 | n = bsize * 3 - (alignmask + 1) + |
161 | (alignmask & ~(crypto_tfm_ctx_alignment() - 1)); | ||
159 | walk->buffer = kmalloc(n, GFP_ATOMIC); | 162 | walk->buffer = kmalloc(n, GFP_ATOMIC); |
160 | if (!walk->buffer) | 163 | if (!walk->buffer) |
161 | return blkcipher_walk_done(desc, walk, -ENOMEM); | 164 | return blkcipher_walk_done(desc, walk, -ENOMEM); |