LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] crypto: add missing kernel_fpu_end() call
@ 2021-07-30 13:41 Shreyansh Chouhan
2021-08-06 8:23 ` Herbert Xu
0 siblings, 1 reply; 14+ messages in thread
From: Shreyansh Chouhan @ 2021-07-30 13:41 UTC (permalink / raw)
To: herbert, davem, tglx, mingo, bp, x86, hpa
Cc: Shreyansh Chouhan, linux-crypto, linux-kernel,
syzbot+20191dc583eff8602d2d
xts_crypt() code doesn't call kernel_fpu_end() after calling
kernel_fpu_begin() if walk.nbytes is 0. Add a call to kernel_fpu_end()
for this case.
Reported-by: syzbot+20191dc583eff8602d2d@syzkaller.appspotmail.com
Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
---
arch/x86/crypto/aesni-intel_glue.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 2144e54a6c89..bd55a0cd7bde 100644
--- a/arch/x86/crypto/aesni-intel_glue.c
+++ b/arch/x86/crypto/aesni-intel_glue.c
@@ -894,6 +894,9 @@ static int xts_crypt(struct skcipher_request *req, bool encrypt)
kernel_fpu_begin();
}
+ if (walk.nbytes == 0)
+ kernel_fpu_end();
+
if (unlikely(tail > 0 && !err)) {
struct scatterlist sg_src[2], sg_dst[2];
struct scatterlist *src, *dst;
--
2.31.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: add missing kernel_fpu_end() call
2021-07-30 13:41 [PATCH] crypto: add missing kernel_fpu_end() call Shreyansh Chouhan
@ 2021-08-06 8:23 ` Herbert Xu
2021-08-06 9:05 ` Ard Biesheuvel
0 siblings, 1 reply; 14+ messages in thread
From: Herbert Xu @ 2021-08-06 8:23 UTC (permalink / raw)
To: Shreyansh Chouhan, Ard Biesheuvel
Cc: davem, tglx, mingo, bp, x86, hpa, linux-crypto, linux-kernel,
syzbot+20191dc583eff8602d2d
On Fri, Jul 30, 2021 at 07:11:55PM +0530, Shreyansh Chouhan wrote:
> xts_crypt() code doesn't call kernel_fpu_end() after calling
> kernel_fpu_begin() if walk.nbytes is 0. Add a call to kernel_fpu_end()
> for this case.
>
> Reported-by: syzbot+20191dc583eff8602d2d@syzkaller.appspotmail.com
> Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
> ---
> arch/x86/crypto/aesni-intel_glue.c | 3 +++
> 1 file changed, 3 insertions(+)
Ard?
> diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
> index 2144e54a6c89..bd55a0cd7bde 100644
> --- a/arch/x86/crypto/aesni-intel_glue.c
> +++ b/arch/x86/crypto/aesni-intel_glue.c
> @@ -894,6 +894,9 @@ static int xts_crypt(struct skcipher_request *req, bool encrypt)
> kernel_fpu_begin();
> }
>
> + if (walk.nbytes == 0)
> + kernel_fpu_end();
> +
> if (unlikely(tail > 0 && !err)) {
> struct scatterlist sg_src[2], sg_dst[2];
> struct scatterlist *src, *dst;
> --
> 2.31.1
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: add missing kernel_fpu_end() call
2021-08-06 8:23 ` Herbert Xu
@ 2021-08-06 9:05 ` Ard Biesheuvel
2021-08-06 9:07 ` Ard Biesheuvel
0 siblings, 1 reply; 14+ messages in thread
From: Ard Biesheuvel @ 2021-08-06 9:05 UTC (permalink / raw)
To: Herbert Xu
Cc: Shreyansh Chouhan, David S. Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, X86 ML, H. Peter Anvin,
Linux Crypto Mailing List, Linux Kernel Mailing List,
syzbot+20191dc583eff8602d2d
On Fri, 6 Aug 2021 at 10:23, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Fri, Jul 30, 2021 at 07:11:55PM +0530, Shreyansh Chouhan wrote:
> > xts_crypt() code doesn't call kernel_fpu_end() after calling
> > kernel_fpu_begin() if walk.nbytes is 0. Add a call to kernel_fpu_end()
> > for this case.
> >
> > Reported-by: syzbot+20191dc583eff8602d2d@syzkaller.appspotmail.com
> > Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
> > ---
> > arch/x86/crypto/aesni-intel_glue.c | 3 +++
> > 1 file changed, 3 insertions(+)
>
> Ard?
>
> > diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
> > index 2144e54a6c89..bd55a0cd7bde 100644
> > --- a/arch/x86/crypto/aesni-intel_glue.c
> > +++ b/arch/x86/crypto/aesni-intel_glue.c
> > @@ -894,6 +894,9 @@ static int xts_crypt(struct skcipher_request *req, bool encrypt)
> > kernel_fpu_begin();
> > }
> >
> > + if (walk.nbytes == 0)
> > + kernel_fpu_end();
> > +
Don't we end up calling kernel_fpu_end() twice this way if we do enter
the while() loop at least once?
> > if (unlikely(tail > 0 && !err)) {
> > struct scatterlist sg_src[2], sg_dst[2];
> > struct scatterlist *src, *dst;
> > --
> > 2.31.1
>
> --
> 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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: add missing kernel_fpu_end() call
2021-08-06 9:05 ` Ard Biesheuvel
@ 2021-08-06 9:07 ` Ard Biesheuvel
2021-08-06 10:36 ` Shreyansh Chouhan
0 siblings, 1 reply; 14+ messages in thread
From: Ard Biesheuvel @ 2021-08-06 9:07 UTC (permalink / raw)
To: Herbert Xu
Cc: Shreyansh Chouhan, David S. Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, X86 ML, H. Peter Anvin,
Linux Crypto Mailing List, Linux Kernel Mailing List,
syzbot+20191dc583eff8602d2d
On Fri, 6 Aug 2021 at 11:05, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Fri, 6 Aug 2021 at 10:23, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> >
> > On Fri, Jul 30, 2021 at 07:11:55PM +0530, Shreyansh Chouhan wrote:
> > > xts_crypt() code doesn't call kernel_fpu_end() after calling
> > > kernel_fpu_begin() if walk.nbytes is 0. Add a call to kernel_fpu_end()
> > > for this case.
> > >
> > > Reported-by: syzbot+20191dc583eff8602d2d@syzkaller.appspotmail.com
> > > Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
> > > ---
> > > arch/x86/crypto/aesni-intel_glue.c | 3 +++
> > > 1 file changed, 3 insertions(+)
> >
> > Ard?
> >
> > > diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
> > > index 2144e54a6c89..bd55a0cd7bde 100644
> > > --- a/arch/x86/crypto/aesni-intel_glue.c
> > > +++ b/arch/x86/crypto/aesni-intel_glue.c
> > > @@ -894,6 +894,9 @@ static int xts_crypt(struct skcipher_request *req, bool encrypt)
> > > kernel_fpu_begin();
> > > }
> > >
> > > + if (walk.nbytes == 0)
> > > + kernel_fpu_end();
> > > +
>
> Don't we end up calling kernel_fpu_end() twice this way if we do enter
> the while() loop at least once?
>
How about the below instead, does that work?
--- 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 (err || !walk.nbytes)
return err;
if (unlikely(tail > 0 && walk.nbytes < walk.total)) {
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: add missing kernel_fpu_end() call
2021-08-06 9:07 ` Ard Biesheuvel
@ 2021-08-06 10:36 ` Shreyansh Chouhan
2021-08-09 14:10 ` [PATCH] crypto: xts_crypt() return if walk.nbytes is 0 Shreyansh Chouhan
0 siblings, 1 reply; 14+ messages in thread
From: Shreyansh Chouhan @ 2021-08-06 10:36 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Herbert Xu, David S. Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, X86 ML, H. Peter Anvin,
Linux Crypto Mailing List, Linux Kernel Mailing List,
syzbot+20191dc583eff8602d2d
Hi,
On Fri, Aug 06, 2021 at 11:07:43AM +0200, Ard Biesheuvel wrote:
> On Fri, 6 Aug 2021 at 11:05, Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > On Fri, 6 Aug 2021 at 10:23, Herbert Xu <herbert@gondor.apana.org.au> wrote:
> > >
> > > On Fri, Jul 30, 2021 at 07:11:55PM +0530, Shreyansh Chouhan wrote:
> > > > xts_crypt() code doesn't call kernel_fpu_end() after calling
> > > > kernel_fpu_begin() if walk.nbytes is 0. Add a call to kernel_fpu_end()
> > > > for this case.
> > > >
> > > > Reported-by: syzbot+20191dc583eff8602d2d@syzkaller.appspotmail.com
> > > > Signed-off-by: Shreyansh Chouhan <chouhan.shreyansh630@gmail.com>
> > > > ---
> > > > arch/x86/crypto/aesni-intel_glue.c | 3 +++
> > > > 1 file changed, 3 insertions(+)
> > >
> > > Ard?
> > >
> > > > diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
> > > > index 2144e54a6c89..bd55a0cd7bde 100644
> > > > --- a/arch/x86/crypto/aesni-intel_glue.c
> > > > +++ b/arch/x86/crypto/aesni-intel_glue.c
> > > > @@ -894,6 +894,9 @@ static int xts_crypt(struct skcipher_request *req, bool encrypt)
> > > > kernel_fpu_begin();
> > > > }
> > > >
> > > > + if (walk.nbytes == 0)
> > > > + kernel_fpu_end();
> > > > +
> >
> > Don't we end up calling kernel_fpu_end() twice this way if we do enter
> > the while() loop at least once?
> >
Oh ha, we do. I missed that.
>
> How about the below instead, does that work?
>
This should work. I will resend the updated patch.
> --- 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 (err || !walk.nbytes)
> return err;
>
> if (unlikely(tail > 0 && walk.nbytes < walk.total)) {
Thanks a lot for the review.
Regards,
Shreyansh Chouhan
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH] crypto: xts_crypt() return if walk.nbytes is 0
2021-08-06 10:36 ` Shreyansh Chouhan
@ 2021-08-09 14:10 ` Shreyansh Chouhan
2021-08-17 14:18 ` Ard Biesheuvel
2021-08-20 8:31 ` Herbert Xu
0 siblings, 2 replies; 14+ messages in thread
From: Shreyansh Chouhan @ 2021-08-09 14:10 UTC (permalink / raw)
To: herbert, davem, tglx, mingo, bp, x86, hpa, ardb
Cc: Shreyansh Chouhan, linux-crypto, linux-kernel,
syzbot+20191dc583eff8602d2d
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(-)
diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
index 388643ca2177..ec6eac57c493 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 (err || !walk.nbytes)
return err;
if (unlikely(tail > 0 && walk.nbytes < walk.total)) {
--
2.31.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: xts_crypt() return if walk.nbytes is 0
2021-08-09 14:10 ` [PATCH] crypto: xts_crypt() return if walk.nbytes is 0 Shreyansh Chouhan
@ 2021-08-17 14:18 ` Ard Biesheuvel
2021-08-20 8:31 ` Herbert Xu
1 sibling, 0 replies; 14+ messages in thread
From: Ard Biesheuvel @ 2021-08-17 14:18 UTC (permalink / raw)
To: Shreyansh Chouhan
Cc: Herbert Xu, David S. Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, X86 ML, H. Peter Anvin,
Linux Crypto Mailing List, Linux Kernel Mailing List,
syzbot+20191dc583eff8602d2d
On Mon, 9 Aug 2021 at 16:10, Shreyansh Chouhan
<chouhan.shreyansh630@gmail.com> 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>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
> ---
> arch/x86/crypto/aesni-intel_glue.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
> index 388643ca2177..ec6eac57c493 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 (err || !walk.nbytes)
> return err;
>
> if (unlikely(tail > 0 && walk.nbytes < walk.total)) {
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: xts_crypt() return if walk.nbytes is 0
2021-08-09 14:10 ` [PATCH] crypto: xts_crypt() return if walk.nbytes is 0 Shreyansh Chouhan
2021-08-17 14:18 ` Ard Biesheuvel
@ 2021-08-20 8:31 ` Herbert Xu
2021-08-20 11:14 ` Ard Biesheuvel
1 sibling, 1 reply; 14+ messages in thread
From: Herbert Xu @ 2021-08-20 8:31 UTC (permalink / raw)
To: Shreyansh Chouhan
Cc: davem, tglx, mingo, bp, x86, hpa, ardb, linux-crypto,
linux-kernel, syzbot+20191dc583eff8602d2d
On Mon, Aug 09, 2021 at 07:40:27PM +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(-)
>
> diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
> index 388643ca2177..ec6eac57c493 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 (err || !walk.nbytes)
> return err;
The err check is now redundant because when there is an error
nbytes is always zero.
Cheers,
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: xts_crypt() return if walk.nbytes is 0
2021-08-20 8:31 ` Herbert Xu
@ 2021-08-20 11:14 ` Ard Biesheuvel
2021-08-20 12:53 ` Herbert Xu
0 siblings, 1 reply; 14+ messages in thread
From: Ard Biesheuvel @ 2021-08-20 11:14 UTC (permalink / raw)
To: Herbert Xu
Cc: Shreyansh Chouhan, David S. Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, X86 ML, H. Peter Anvin,
Linux Crypto Mailing List, Linux Kernel Mailing List,
syzbot+20191dc583eff8602d2d
On Fri, 20 Aug 2021 at 10:31, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Mon, Aug 09, 2021 at 07:40:27PM +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(-)
> >
> > diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c
> > index 388643ca2177..ec6eac57c493 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 (err || !walk.nbytes)
> > return err;
>
> The err check is now redundant because when there is an error
> nbytes is always zero.
>
In spite of that, I have a slight preference for this version, given
that it makes it obvious that we bail on two separate conditions:
- an error has occurred
- no error has occurred but the resulting walk is empty
Testing walk.nbytes only needlessly obfuscates the code, as we need to
return 'err' in the end anyway.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: xts_crypt() return if walk.nbytes is 0
2021-08-20 11:14 ` Ard Biesheuvel
@ 2021-08-20 12:53 ` Herbert Xu
2021-08-22 3:45 ` [PATCH v2] " Shreyansh Chouhan
` (2 more replies)
0 siblings, 3 replies; 14+ messages in thread
From: Herbert Xu @ 2021-08-20 12:53 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: Shreyansh Chouhan, David S. Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, X86 ML, H. Peter Anvin,
Linux Crypto Mailing List, Linux Kernel Mailing List,
syzbot+20191dc583eff8602d2d
On Fri, Aug 20, 2021 at 01:14:52PM +0200, Ard Biesheuvel wrote:
>
> In spite of that, I have a slight preference for this version, given
> that it makes it obvious that we bail on two separate conditions:
> - an error has occurred
> - no error has occurred but the resulting walk is empty
>
> Testing walk.nbytes only needlessly obfuscates the code, as we need to
> return 'err' in the end anyway.
I disagree, this is how most skcipher walkers are structured, they
never explicitly test on err and only terminate the loop when
walk->nbytes hits zero, in which case err is returned as is.
I don't see why this particular skcipher walker should deviate
from that paradigm. In fact it is exactly that deviation that
caused the bug in the first instance.
Cheers,
--
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
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v2] crypto: xts_crypt() return if walk.nbytes is 0
2021-08-20 12:53 ` Herbert Xu
@ 2021-08-22 3:45 ` Shreyansh Chouhan
2021-08-27 8:38 ` Herbert Xu
2021-08-22 3:48 ` [PATCH] " Shreyansh Chouhan
2021-08-22 13:23 ` Ard Biesheuvel
2 siblings, 1 reply; 14+ messages in thread
From: Shreyansh Chouhan @ 2021-08-22 3:45 UTC (permalink / raw)
To: herbert, davem, tglx, mingo, bp, hpa, x86, ardb
Cc: Shreyansh Chouhan, linux-crypto, linux-kernel,
syzbot+20191dc583eff8602d2d
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(-)
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)) {
--
2.31.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: xts_crypt() return if walk.nbytes is 0
2021-08-20 12:53 ` Herbert Xu
2021-08-22 3:45 ` [PATCH v2] " Shreyansh Chouhan
@ 2021-08-22 3:48 ` Shreyansh Chouhan
2021-08-22 13:23 ` Ard Biesheuvel
2 siblings, 0 replies; 14+ messages in thread
From: Shreyansh Chouhan @ 2021-08-22 3:48 UTC (permalink / raw)
To: Herbert Xu
Cc: Ard Biesheuvel, David S. Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, X86 ML, H. Peter Anvin,
Linux Crypto Mailing List, Linux Kernel Mailing List,
syzbot+20191dc583eff8602d2d
Hi,
Thank you Ard and Herebrt for your reviews. I have sent an updated
patch. Sorry for the delay.
Regards,
Shreyansh
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH] crypto: xts_crypt() return if walk.nbytes is 0
2021-08-20 12:53 ` Herbert Xu
2021-08-22 3:45 ` [PATCH v2] " Shreyansh Chouhan
2021-08-22 3:48 ` [PATCH] " Shreyansh Chouhan
@ 2021-08-22 13:23 ` Ard Biesheuvel
2 siblings, 0 replies; 14+ messages in thread
From: Ard Biesheuvel @ 2021-08-22 13:23 UTC (permalink / raw)
To: Herbert Xu
Cc: Shreyansh Chouhan, David S. Miller, Thomas Gleixner, Ingo Molnar,
Borislav Petkov, X86 ML, H. Peter Anvin,
Linux Crypto Mailing List, Linux Kernel Mailing List,
syzbot+20191dc583eff8602d2d
On Fri, 20 Aug 2021 at 14:53, Herbert Xu <herbert@gondor.apana.org.au> wrote:
>
> On Fri, Aug 20, 2021 at 01:14:52PM +0200, Ard Biesheuvel wrote:
> >
> > In spite of that, I have a slight preference for this version, given
> > that it makes it obvious that we bail on two separate conditions:
> > - an error has occurred
> > - no error has occurred but the resulting walk is empty
> >
> > Testing walk.nbytes only needlessly obfuscates the code, as we need to
> > return 'err' in the end anyway.
>
> I disagree, this is how most skcipher walkers are structured, they
> never explicitly test on err and only terminate the loop when
> walk->nbytes hits zero, in which case err is returned as is.
>
> I don't see why this particular skcipher walker should deviate
> from that paradigm. In fact it is exactly that deviation that
> caused the bug in the first instance.
>
Fair enough.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v2] crypto: xts_crypt() return if walk.nbytes is 0
2021-08-22 3:45 ` [PATCH v2] " Shreyansh Chouhan
@ 2021-08-27 8:38 ` Herbert Xu
0 siblings, 0 replies; 14+ messages in thread
From: Herbert Xu @ 2021-08-27 8:38 UTC (permalink / raw)
To: Shreyansh Chouhan
Cc: davem, tglx, mingo, bp, hpa, x86, ardb, linux-crypto,
linux-kernel, syzbot+20191dc583eff8602d2d
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
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2021-08-27 8:38 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-30 13:41 [PATCH] crypto: add missing kernel_fpu_end() call Shreyansh Chouhan
2021-08-06 8:23 ` Herbert Xu
2021-08-06 9:05 ` Ard Biesheuvel
2021-08-06 9:07 ` Ard Biesheuvel
2021-08-06 10:36 ` Shreyansh Chouhan
2021-08-09 14:10 ` [PATCH] crypto: xts_crypt() return if walk.nbytes is 0 Shreyansh Chouhan
2021-08-17 14:18 ` Ard Biesheuvel
2021-08-20 8:31 ` Herbert Xu
2021-08-20 11:14 ` Ard Biesheuvel
2021-08-20 12:53 ` Herbert Xu
2021-08-22 3:45 ` [PATCH v2] " Shreyansh Chouhan
2021-08-27 8:38 ` Herbert Xu
2021-08-22 3:48 ` [PATCH] " Shreyansh Chouhan
2021-08-22 13:23 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).