Re: [PATCH v3 0/4] crypto: aesni - Use zero-copy for gcm(aes) buffers that are partially contiguous

2018-02-23 Thread Junaid Shahid
On 02/22/2018 06:50 AM, Herbert Xu wrote: > > I think this conflicts with Dave Watson's work. Could you rebase > this on top of his patches? > > Thanks, > Hi Herbert, I'll try to send a new version rebased on top of Dave's patches, but it might be some time before I can get to it. I guess it

Re: [PATCH 14/14] x86/crypto: aesni: Update aesni-intel_glue to use scatter/gather

2018-02-13 Thread Junaid Shahid
[Resending after delivery failure] Hi Dave, On 02/13/2018 10:22 AM, Dave Watson wrote: > > Yes, these both sound reasonable. I will send a V2. > > Thanks! Another minor suggestion for v2: It might be a good idea to check if the first assoclen bytes are already contiguous and only do the kmall

Re: [PATCH 14/14] x86/crypto: aesni: Update aesni-intel_glue to use scatter/gather

2018-02-12 Thread Junaid Shahid
Hi Dave, On 02/12/2018 11:51 AM, Dave Watson wrote: > +static int gcmaes_encrypt_sg(struct aead_request *req, unsigned int assoclen, > + u8 *hash_subkey, u8 *iv, void *aes_ctx) > > +static int gcmaes_decrypt_sg(struct aead_request *req, unsigned int assoclen, > +

[PATCH v3 3/4] crypto: aesni - Directly use kmap_atomic instead of scatter_walk object in gcm(aes)

2018-01-31 Thread Junaid Shahid
object for simplicity. Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_glue.c | 36 +++- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index c11e531d21dd

[PATCH v3 4/4] crypto: aesni - Use zero-copy for gcm(aes) even if the AAD/Data/AuthTag are separate

2018-01-31 Thread Junaid Shahid
Enable the use of zero-copy even if the AAD and/or Auth Tag are in different buffers than the actual data, as long as each of them individually satisfies the zero-copy conditions (i.e. the entire buffer is either in low-mem or within a single high-mem page). Signed-off-by: Junaid Shahid

[PATCH v3 0/4] crypto: aesni - Use zero-copy for gcm(aes) buffers that are partially contiguous

2018-01-31 Thread Junaid Shahid
enables the use of zero-copy even if only one of src and dest satisfies these conditions rather than only when both of them do. Junaid Shahid (4): crypto: aesni - Fix out-of-bounds access of the AAD buffer in AVX gcm-aesni crypto: aesni - Enable one-sided zero copy for gcm(aes) request

[PATCH v3 1/4] crypto: aesni - Fix out-of-bounds access of the AAD buffer in AVX gcm-aesni

2018-01-31 Thread Junaid Shahid
that by reading the last <16 byte block of the AAD byte-by-byte and optionally via an 8-byte load if the block was at least 8 bytes. Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_avx-x86_64.S | 154 +-- 1 file changed, 42 insertions(+), 112 deletions(

[PATCH v3 2/4] crypto: aesni - Enable one-sided zero copy for gcm(aes) request buffers

2018-01-31 Thread Junaid Shahid
. This optimization is now extended to avoid the copy on the side that does satisfy the zero-copy conditions. Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_glue.c | 256 +++-- 1 file changed, 134 insertions(+), 122 deletions(-) diff --git a/arch/x86

Re: [PATCH v2 0/4] crypto: aesni - Use zero-copy for gcm(aes) buffers that are partially contiguous

2018-01-31 Thread Junaid Shahid
Hi Steffen, On Wed, Jan 31, 2018 at 12:13 AM, Steffen Klassert wrote: > > I wonder which special usecase you have in mind that will be improved > by your patches. > This is not related to IPsec. We have an internal use case where the data buffer itself is a single memory page but the authenticat

Re: [PATCH v2 2/4] crypto: aesni - Enable one-sided zero copy for gcm(aes) request buffers

2018-01-31 Thread Junaid Shahid
Hi Stephan, Sure, I'll rebase and send another revision. Thanks, Junaid

[PATCH v2 3/4] crypto: aesni - Directly use kmap_atomic instead of scatter_walk object in gcm(aes)

2018-01-23 Thread Junaid Shahid
object for simplicity. Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_glue.c | 36 +++- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index aef6c82b9ca7

[PATCH v2 4/4] crypto: aesni - Use zero-copy for gcm(aes) even if the AAD/Data/AuthTag are separate

2018-01-23 Thread Junaid Shahid
Enable the use of zero-copy even if the AAD and/or Auth Tag are in different buffers than the actual data, as long as each of them individually satisfies the zero-copy conditions (i.e. the entire buffer is either in low-mem or within a single high-mem page). Signed-off-by: Junaid Shahid

[PATCH v2 2/4] crypto: aesni - Enable one-sided zero copy for gcm(aes) request buffers

2018-01-23 Thread Junaid Shahid
. This optimization is now extended to avoid the copy on the side that does satisfy the zero-copy conditions. Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_glue.c | 256 +++-- 1 file changed, 134 insertions(+), 122 deletions(-) diff --git a/arch/x86

[PATCH v2 1/4] crypto: aesni - Fix out-of-bounds access of the AAD buffer in AVX gcm-aesni

2018-01-23 Thread Junaid Shahid
that by reading the last <16 byte block of the AAD byte-by-byte and optionally via an 8-byte load if the block was at least 8 bytes. Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_avx-x86_64.S | 154 +-- 1 file changed, 42 insertions(+), 112 deletions(

[PATCH v2 0/4] crypto: aesni - Use zero-copy for gcm(aes) buffers that are partially contiguous

2018-01-23 Thread Junaid Shahid
dest satisfies these conditions rather than only when both of them do. Junaid Shahid (4): crypto: aesni - Fix out-of-bounds access of the AAD buffer in AVX gcm-aesni crypto: aesni - Enable one-sided zero copy for gcm(aes) request buffers crypto: aesni - Directly use kmap_atomic instead

[PATCH 0/4] crypto: aesni - Use zero-copy for gcm(aes) buffers that are partially contiguous

2018-01-22 Thread Junaid Shahid
. Junaid Shahid (4): crypto: aesni - Fix out-of-bounds access of the AAD buffer in AVX gcm-aesni crypto: aesni - Enable one-sided zero copy for gcm(aes) request buffers crypto: aesni - Directly use kmap_atomic instead of scatter_walk object in gcm(aes) crypto: aesni - Use zero-copy for

[PATCH 2/4] crypto: aesni - Enable one-sided zero copy for gcm(aes) request buffers

2018-01-22 Thread Junaid Shahid
. This optimization is now extended to avoid the copy on the side that does satisfy the zero-copy conditions. Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_glue.c | 256 +++-- 1 file changed, 134 insertions(+), 122 deletions(-) diff --git a/arch/x86

[PATCH 1/4] crypto: aesni - Fix out-of-bounds access of the AAD buffer in AVX gcm-aesni

2018-01-22 Thread Junaid Shahid
that by reading the last <16 byte block of the AAD byte-by-byte and optionally via an 8-byte load if the block was at least 8 bytes. Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_avx-x86_64.S | 154 +-- 1 file changed, 42 insertions(+), 112 deletions(

[PATCH 3/4] crypto: aesni - Directly use kmap_atomic instead of scatter_walk object in gcm(aes)

2018-01-22 Thread Junaid Shahid
object for simplicity. Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_glue.c | 36 +++- 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c index a46eb2d25f71

[PATCH 4/4] crypto: aesni - Use zero-copy for gcm(aes) even if the AAD/Data/AuthTag are separate

2018-01-22 Thread Junaid Shahid
Enable the use of zero-copy even if the AAD and/or Auth Tag are in different buffers than the actual data, as long as each of them individually satisfies the zero-copy conditions (i.e. the entire buffer is either in low-mem or within a single high-mem page). Signed-off-by: Junaid Shahid

Re: [PATCH v3 1/2] crypto: Fix out-of-bounds access of the data buffer in generic-gcm-aesni

2017-12-20 Thread Junaid Shahid
On Wednesday, December 20, 2017 5:08:37 PM PST Junaid Shahid wrote: > +.macro READ_PARTIAL_BLOCK DPTR DLEN XMM1 XMMDst > +cmp $8, \DLEN > +jl _read_lt8_\@ > +mov (\DPTR), %rax > +MOVQ_R64_XMM %rax, \XMMDst Just noticed that these two can b

[PATCH v3 2/2] crypto: Fix out-of-bounds access of the AAD buffer in generic-gcm-aesni

2017-12-20 Thread Junaid Shahid
n-AVX AES-GCM work with any aadlen") Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_asm.S | 112 -- 1 file changed, 12 insertions(+), 100 deletions(-) diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S

[PATCH v3 1/2] crypto: Fix out-of-bounds access of the data buffer in generic-gcm-aesni

2017-12-20 Thread Junaid Shahid
machine to crash. This patch fixes that by reading the partial block byte-by-byte and optionally an via 8-byte load if the block was at least 8 bytes. Fixes: 0487ccac ("crypto: aesni - make non-AVX AES-GCM work with any aadlen") Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_

[PATCH v3 0/2] Fix out-of-bounds memory accesses in generic-gcm-aesni

2017-12-20 Thread Junaid Shahid
, that is no longer the case with the generic-gcm-aesni mode. This could potentially result in accessing pages that are not mapped, thus causing a crash. Junaid Shahid (2): crypto: Fix out-of-bounds access of the data buffer in generic-gcm-aesni crypto: Fix out-of-bounds access of the AAD

Re: [PATCH v2 2/2] crypto: Fix out-of-bounds access of the AAD buffer in generic-gcm-aesni

2017-12-20 Thread Junaid Shahid
On Wednesday, December 20, 2017 1:12:54 PM PST Eric Biggers wrote: > > > > We do need both registers, though we could certainly swap their usage to > > make > > r12 the temp register. The reason we need the second register is because we > > need to keep the original length to perform the pshufb a

Re: [PATCH v2 2/2] crypto: Fix out-of-bounds access of the AAD buffer in generic-gcm-aesni

2017-12-20 Thread Junaid Shahid
On Wednesday, December 20, 2017 12:42:10 AM PST Eric Biggers wrote: > > -_get_AAD_rest0\num_initial_blocks\operation: > > - /* finalize: shift out the extra bytes we read, and align > > - left. since pslldq can only shift by an immediate, we use > > - vpshufb and an array of shuffle masks */

Re: [PATCH v2 1/2] crypto: Fix out-of-bounds access of the data buffer in generic-gcm-aesni

2017-12-20 Thread Junaid Shahid
On Wednesday, December 20, 2017 12:36:16 AM PST Eric Biggers wrote: > > Did you run the self-tests (boot with CONFIG_CRYPTO_MANAGER_DISABLE_TESTS > unset)? The second patch causes them to start failing: > > [1.169640] alg: aead: Test 7 failed on encryption for rfc4106-gcm-aesni > [1.1783

[PATCH v2 1/2] crypto: Fix out-of-bounds access of the data buffer in generic-gcm-aesni

2017-12-19 Thread Junaid Shahid
machine to crash. This patch fixes that by reading the partial block byte-by-byte and optionally an via 8-byte load if the block was at least 8 bytes. Fixes: 0487ccac ("crypto: aesni - make non-AVX AES-GCM work with any aadlen") Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_

[PATCH v2 2/2] crypto: Fix out-of-bounds access of the AAD buffer in generic-gcm-aesni

2017-12-19 Thread Junaid Shahid
n-AVX AES-GCM work with any aadlen") Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_asm.S | 80 +-- 1 file changed, 10 insertions(+), 70 deletions(-) diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S

[PATCH v2 0/2] Fix out-of-bounds memory accesses in generic-gcm-aesni

2017-12-19 Thread Junaid Shahid
pages that are not mapped, thus causing a crash. Junaid Shahid (2): crypto: Fix out-of-bounds access of the data buffer in generic-gcm-aesni crypto: Fix out-of-bounds access of the AAD buffer in generic-gcm-aesni arch/x86/crypto/aesni-intel_asm.S | 166

[PATCH] crypto: Fix out-of-bounds memory access in generic-gcm-aesni

2017-12-19 Thread Junaid Shahid
an 8-byte load if the block was at least 8 bytes. Fixes: 0487ccac ("crypto: aesni - make non-AVX AES-GCM work with any aadlen") Signed-off-by: Junaid Shahid --- arch/x86/crypto/aesni-intel_asm.S | 85 --- 1 file changed, 43 insertions(+), 42 deletions(-