Re: [PATCH] gcmaes_crypt_by_sg: don't use GFP_ATOMIC allocation if the request doesn't cross a page

2018-09-14 Thread Herbert Xu
On Wed, Sep 05, 2018 at 09:18:43AM -0400, Mikulas Patocka wrote:
> This patch fixes gcmaes_crypt_by_sg so that it won't use memory
> allocation if the data doesn't cross a page boundary.
> 
> Authenticated encryption may be used by dm-crypt. If the encryption or
> decryption fails, it would result in I/O error and filesystem corruption.
> The function gcmaes_crypt_by_sg is using GFP_ATOMIC allocation that can
> fail anytime. This patch fixes the logic so that it won't attempt the
> failing allocation if the data doesn't cross a page boundary.
> 
> Signed-off-by: Mikulas Patocka 
> Cc: sta...@vger.kernel.org

Patch applied.  Thanks.
-- 
Email: Herbert Xu 
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt


[PATCH] gcmaes_crypt_by_sg: don't use GFP_ATOMIC allocation if the request doesn't cross a page

2018-09-05 Thread Mikulas Patocka
This patch fixes gcmaes_crypt_by_sg so that it won't use memory
allocation if the data doesn't cross a page boundary.

Authenticated encryption may be used by dm-crypt. If the encryption or
decryption fails, it would result in I/O error and filesystem corruption.
The function gcmaes_crypt_by_sg is using GFP_ATOMIC allocation that can
fail anytime. This patch fixes the logic so that it won't attempt the
failing allocation if the data doesn't cross a page boundary.

Signed-off-by: Mikulas Patocka 
Cc: sta...@vger.kernel.org

---
 arch/x86/crypto/aesni-intel_glue.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6/arch/x86/crypto/aesni-intel_glue.c
===
--- linux-2.6.orig/arch/x86/crypto/aesni-intel_glue.c   2018-05-31 
18:04:37.80800 +0200
+++ linux-2.6/arch/x86/crypto/aesni-intel_glue.c2018-09-04 
21:56:35.33000 +0200
@@ -817,7 +817,7 @@ static int gcmaes_crypt_by_sg(bool enc,
/* Linearize assoc, if not already linear */
if (req->src->length >= assoclen && req->src->length &&
(!PageHighMem(sg_page(req->src)) ||
-   req->src->offset + req->src->length < PAGE_SIZE)) {
+   req->src->offset + req->src->length <= PAGE_SIZE)) {
scatterwalk_start(_sg_walk, req->src);
assoc = scatterwalk_map(_sg_walk);
} else {