diff mbox series

[v2] crypto: xts_crypt() return if walk.nbytes is 0

Message ID 20210822034514.926652-1-chouhan.shreyansh630@gmail.com
State Accepted
Commit 72ff2bf04db2a48840df93a461b7115900f46c05
Headers show
Series [v2] crypto: xts_crypt() return if walk.nbytes is 0 | expand

Commit Message

Shreyansh Chouhan Aug. 22, 2021, 3:45 a.m. UTC
xts_crypt() code doesn't call kernel_fpu_end() after calling
kernel_fpu_begin() if walk.nbytes is 0. The correct behavior should be
not calling kernel_fpu_begin() if walk.nbytes is 0.

Reported-by: syzbot+20191dc583eff8602d2d@syzkaller.appspotmail.com
Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
---
 arch/x86/crypto/aesni-intel_glue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Herbert Xu Aug. 27, 2021, 8:38 a.m. UTC | #1
On Sun, Aug 22, 2021 at 09:15:14AM +0530, Shreyansh Chouhan wrote:
> xts_crypt() code doesn't call kernel_fpu_end() after calling

> kernel_fpu_begin() if walk.nbytes is 0. The correct behavior should be

> not calling kernel_fpu_begin() if walk.nbytes is 0.

> 

> Reported-by: syzbot+20191dc583eff8602d2d@syzkaller.appspotmail.com

> Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>

> ---

>  arch/x86/crypto/aesni-intel_glue.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)


Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
diff mbox series

Patch

diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 388643ca2177..0fc961bef299 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -849,7 +849,7 @@  static int xts_crypt(struct skcipher_request *req, bool encrypt)
 		return -EINVAL;
 
 	err = skcipher_walk_virt(&walk, req, false);
-	if (err)
+	if (!walk.nbytes)
 		return err;
 
 	if (unlikely(tail > 0 && walk.nbytes < walk.total)) {