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
This commit is contained in:
commit
1e3cbe4c27
@ -59,11 +59,13 @@ static inline void blkcipher_unmap_dst(struct blkcipher_walk *walk)
|
|||||||
scatterwalk_unmap(walk->dst.virt.addr, 1);
|
scatterwalk_unmap(walk->dst.virt.addr, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get a spot of the specified length that does not straddle a page.
|
||||||
|
* The caller needs to ensure that there is enough space for this operation.
|
||||||
|
*/
|
||||||
static inline u8 *blkcipher_get_spot(u8 *start, unsigned int len)
|
static inline u8 *blkcipher_get_spot(u8 *start, unsigned int len)
|
||||||
{
|
{
|
||||||
if (offset_in_page(start + len) < len)
|
u8 *end_page = (u8 *)(((unsigned long)(start + len - 1)) & PAGE_MASK);
|
||||||
return (u8 *)((unsigned long)(start + len) & PAGE_MASK);
|
return start > end_page ? start : end_page;
|
||||||
return start;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline unsigned int blkcipher_done_slow(struct crypto_blkcipher *tfm,
|
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,
|
|||||||
if (walk->buffer)
|
if (walk->buffer)
|
||||||
goto ok;
|
goto ok;
|
||||||
|
|
||||||
n = bsize * 2 + (alignmask & ~(crypto_tfm_ctx_alignment() - 1));
|
n = bsize * 3 - (alignmask + 1) +
|
||||||
|
(alignmask & ~(crypto_tfm_ctx_alignment() - 1));
|
||||||
walk->buffer = kmalloc(n, GFP_ATOMIC);
|
walk->buffer = kmalloc(n, GFP_ATOMIC);
|
||||||
if (!walk->buffer)
|
if (!walk->buffer)
|
||||||
return blkcipher_walk_done(desc, walk, -ENOMEM);
|
return blkcipher_walk_done(desc, walk, -ENOMEM);
|
||||||
|
Loading…
Reference in New Issue
Block a user