Re: [PATCH net 4/4] tls: Fix tls_device receive

2019-02-26 Thread Dave Watson
On 02/26/19 02:12 PM, Boris Pismenny wrote: > Currently, the receive function fails to handle records already > decrypted by the device due to the commit mentioned below. > > This commit advances the TLS record sequence number and prepares the context > to handle the next record. > > Fixes: fedf2

[PATCH net-next v2 1/5] net: tls: Support 256 bit keys

2019-01-30 Thread Dave Watson
Wire up support for 256 bit keys from the setsockopt to the crypto framework Signed-off-by: Dave Watson --- include/net/tls.h | 5 ++- include/uapi/linux/tls.h | 15 net/tls/tls_main.c| 33 +++- net/tls/tls_sw.c

[PATCH net-next v2 3/5] net: tls: Refactor control message handling on recv

2019-01-30 Thread Dave Watson
For TLS 1.3, the control message is encrypted. Handle control message checks after decryption. Signed-off-by: Dave Watson --- net/tls/tls_sw.c | 88 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/net/tls/tls_sw.c b/net/tls

[PATCH net-next v2 5/5] net: tls: Add tests for TLS 1.3

2019-01-30 Thread Dave Watson
Change most tests to TLS 1.3, while adding tests for previous TLS 1.2 behavior. Signed-off-by: Dave Watson --- tools/testing/selftests/net/tls.c | 76 ++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/tls.c b/tools/testing

[PATCH net-next] net: tls: Set async_capable for tls zerocopy only if we see EINPROGRESS

2019-01-30 Thread Dave Watson
d-off-by: Dave Watson --- include/net/tls.h | 1 + net/tls/tls_sw.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h index 4592606e136a..eb73e62ac8c9 100644 --- a/include/net/tls.h +++ b/include/net/tls.h @@ -139,6 +139,7 @@ s

[PATCH net-next v2 0/5] net: tls: TLS 1.3 support

2019-01-30 Thread Dave Watson
was in TLS1.2. This requires moving the control message handling to after decryption, but is otherwise similar. V1 -> V2 The first two patches were dropped, and sent separately, one as a bugfix to the net tree. Dave Watson (5): net: tls: Support 256 bit keys net: tls: Refactor tls aad sp

[PATCH net-next v2 2/5] net: tls: Refactor tls aad space size calculation

2019-01-30 Thread Dave Watson
TLS 1.3 has a different AAD size, use a variable in the code to make TLS 1.3 support easy. Signed-off-by: Dave Watson --- include/net/tls.h | 1 + net/tls/tls_sw.c | 17 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h

[PATCH net-next v2 4/5] net: tls: Add tls 1.3 support

2019-01-30 Thread Dave Watson
zero padding. Signed-off-by: Dave Watson --- include/net/tls.h | 66 ++- include/uapi/linux/tls.h | 4 ++ net/tls/tls_device.c | 5 +- net/tls/tls_device_fallback.c | 3 +- net/tls/tls_main.c| 3 +- net/tls/tls_sw.c | 116

Re: [PATCH net] net: tls: Save iv in tls_rec for async crypto requests

2019-01-29 Thread Dave Watson
On 01/28/19 11:06 PM, David Miller wrote: > From: Dave Watson > Date: Sun, 27 Jan 2019 00:57:38 + > > > aead_request_set_crypt takes an iv pointer, and we change the iv > > soon after setting it. Some async crypto algorithms don't save the iv, > > so we ne

[PATCH net] net: tls: Fix deadlock in free_resources tx

2019-01-26 Thread Dave Watson
t for async encryption of records...") Signed-off-by: Dave Watson --- net/tls/tls_sw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 7e963560edef..bf5b54b513bc 100644 --- a/net/tls/tls_sw.c +++ b/net/tls/tls_sw.c @@ -1794,7 +1794

[PATCH net] net: tls: Save iv in tls_rec for async crypto requests

2019-01-26 Thread Dave Watson
don't think this combination can happen in the wild. Presumably other hardware offloads will need this fix, but there have been no user reports. Fixes: a42055e8d2c30 ("Add support for async encryption of records...") Signed-off-by: Dave Watson --- include/net/tls.h | 2 ++ n

Re: [PATCH net-next 1/7] net: tls: Save iv in tls_rec for async crypto requests

2019-01-24 Thread Dave Watson
On 01/24/19 02:14 PM, Jakub Kicinski wrote: > On Thu, 24 Jan 2019 17:20:12 +0000, Dave Watson wrote: > > aead_request_set_crypt takes an iv pointer, and we change the iv > > soon after setting it. Some async crypto algorithms don't save the iv, > > so we need to save i

[PATCH net-next 5/7] net: tls: Refactor control message handling on recv

2019-01-24 Thread Dave Watson
For TLS 1.3, the control message is encrypted. Handle control message checks after decryption. Signed-off-by: Dave Watson --- net/tls/tls_sw.c | 88 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/net/tls/tls_sw.c b/net/tls

[PATCH net-next 7/7] net: tls: Add tests for TLS 1.3

2019-01-24 Thread Dave Watson
Change most tests to TLS 1.3, while adding tests for previous TLS 1.2 behavior. Signed-off-by: Dave Watson --- tools/testing/selftests/net/tls.c | 76 ++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/tls.c b/tools/testing

[PATCH net-next 6/7] net: tls: Add tls 1.3 support

2019-01-24 Thread Dave Watson
zero padding. Signed-off-by: Dave Watson --- include/net/tls.h | 66 ++- include/uapi/linux/tls.h | 4 ++ net/tls/tls_device.c | 5 +- net/tls/tls_device_fallback.c | 3 +- net/tls/tls_main.c| 3 +- net/tls/tls_sw.c | 116

[PATCH net-next 3/7] net: tls: Support 256 bit keys

2019-01-24 Thread Dave Watson
Wire up support for 256 bit keys from the setsockopt to the crypto framework Signed-off-by: Dave Watson --- include/net/tls.h | 5 ++- include/uapi/linux/tls.h | 15 net/tls/tls_main.c| 33 +++- net/tls/tls_sw.c

[PATCH net-next 4/7] net: tls: Refactor tls aad space size calculation

2019-01-24 Thread Dave Watson
TLS 1.3 has a different AAD size, use a variable in the code to make TLS 1.3 support easy. Signed-off-by: Dave Watson --- include/net/tls.h | 1 + net/tls/tls_sw.c | 17 + 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h

[PATCH net-next 1/7] net: tls: Save iv in tls_rec for async crypto requests

2019-01-24 Thread Dave Watson
don't think this combination can happen in the wild. Presumably other hardware offloads will need this fix, but there have been no user reports. Fixes: a42055e8d2c30 ("Add support for async encryption of records...") Signed-off-by: Dave Watson --- include/net/tls.h | 2 ++ n

[PATCH net-next 2/7] net: tls: Set async_capable for tls zerocopy only if we see EINPROGRESS

2019-01-24 Thread Dave Watson
d-off-by: Dave Watson --- include/net/tls.h | 1 + net/tls/tls_sw.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h index 4592606e136a..eb73e62ac8c9 100644 --- a/include/net/tls.h +++ b/include/net/tls.h @@ -139,6 +139,7 @@ s

[PATCH net-next] tls: Add maintainers

2018-10-22 Thread Dave Watson
Add John and Daniel as additional tls co-maintainers to help review patches and fix syzbot reports. Acked-by: John Fastabend Acked-by: Daniel Borkmann Signed-off-by: Dave Watson --- MAINTAINERS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index 7f1399ac028e

Re: [PATCH bpf-next 4/8] tls: convert to generic sk_msg interface

2018-10-12 Thread Dave Watson
On 10/11/18 02:45 AM, Daniel Borkmann wrote: > Convert kTLS over to make use of sk_msg interface for plaintext and > encrypted scattergather data, so it reuses all the sk_msg helpers > and data structure which later on in a second step enables to glue > this to BPF. Looks very clean, thanks! > >

Re: [PATCH net-next] tls: Add support for inplace records encryption

2018-10-01 Thread Dave Watson
roduced in > record structure to signify whether the same scatterlist can be used. > By default, the inplace_crypto is enabled in get_rec(). If zero-copy is > used (i.e. plaintext data is not copied), inplace_crypto is set to '0'. > > Signed-off-by: Vakul Garg Looks reasonable to me, thanks. Reviewed-by: Dave Watson

Re: [bpf PATCH 1/2] tls: possible hang when do_tcp_sendpages hits sndbuf is full case

2018-08-22 Thread Dave Watson
this reduce the sndbuf size and stress > the tls layer by sending many 1B sends. This results in every byte > needing a header and each byte individually being sent to the crypto > layer. > > Signed-off-by: John Fastabend Super, thanks! Acked-by: Dave Watson

Re: [PATCH net-next v1] net/tls: Add support for async decryption of tls records

2018-08-17 Thread Dave Watson
On 08/16/18 08:49 PM, Vakul Garg wrote: > Changes since RFC version: > 1) Improved commit message. > 2) Fixed dequeued record offset handling because of which few of > tls selftests 'recv_partial, recv_peek, recv_peek_multiple' were > failing. Thanks! Commit message much more

Re: [PATCH net-next][RFC] net/tls: Add support for async decryption of tls records

2018-08-15 Thread Dave Watson
On 08/14/18 07:47 PM, Vakul Garg wrote: > Incoming TLS records which are directly decrypted into user space > application buffer i.e. records which are decrypted in zero-copy mode > are submitted for async decryption. When the decryption cryptoapi > returns -EINPROGRESS, the next tls record is pars

Re: [PATCH net-next v2 1/1] net/tls: Combined memory allocation for decryption request

2018-08-09 Thread Dave Watson
able and not come from stack. The buffers for > aad and iv can be separately kmalloced each, but it is inefficient. > This patch does a combined allocation for preparing decryption request > and then segments into aead_req || sgin || sgout || iv || aad. > > Signed-off-by: Vakul Garg

Re: [PATCH net-next v1 1/1] net/tls: Combined memory allocation for decryption request

2018-08-08 Thread Dave Watson
On 08/08/18 06:36 PM, Vakul Garg wrote: > For preparing decryption request, several memory chunks are required > (aead_req, sgin, sgout, iv, aad). For submitting the decrypt request to > an accelerator, it is required that the buffers which are read by the > accelerator must be dma-able and not com

Re: [PATCH RFC net-next 1/1] net/tls: Combined memory allocation for decryption request

2018-08-07 Thread Dave Watson
Hi Vakul, Only minor comments, mostly looks good to me. Thanks > +/* This function decrypts the input skb into either out_iov or in out_sg > + * or in skb buffers itself. The input parameter 'zc' indicates if > + * zero-copy mode needs to be tried or not. With zero-copy mode, either > + * out_io

Re: Security enhancement proposal for kernel TLS

2018-08-03 Thread Dave Watson
On 08/02/18 05:23 PM, Vakul Garg wrote: > > I agree that Boris' patch does what you say it does - it sets keys > > immediately > > after CCS instead of after FINISHED message. I disagree that the kernel tls > > implementation currently requires that specific ordering, nor do I think > > that it

Re: [PATCH net-next] net/tls: Mark the end in scatterlist table

2018-08-02 Thread Dave Watson
On 08/02/18 05:05 PM, Vakul Garg wrote: > In case zerocopy_from_iter() fails, 'end' won't get marked. > So fallback path is fine. > > > Which codepath is calling sg_nents()? > > While testing my WIP implementation of combined dynamic memory allocation for > (aead_req || sgin || sgout || aad || i

Re: [PATCH net-next] net/tls: Always get number of sg entries for skb to be decrypted

2018-08-02 Thread Dave Watson
On 08/02/18 09:50 PM, Vakul Garg wrote: > Function decrypt_skb() made a bad assumption that number of sg entries > required for mapping skb to be decrypted would always be less than > MAX_SKB_FRAGS. The required count of sg entries for skb should always be > calculated. If they cannot fit in local

Re: [PATCH net-next] net/tls: Mark the end in scatterlist table

2018-08-02 Thread Dave Watson
the function needs to mark the 'end' in the last entry it > adds. > > Signed-off-by: Vakul Garg Looks good to me, it looks like the fallback path should unmark the end appropriately. Which codepath is calling sg_nents()? Acked-by: Dave Watson

Re: [net-next v5 3/3] net/tls: Remove redundant array allocation.

2018-08-01 Thread Dave Watson
On 08/01/18 01:49 PM, Vakul Garg wrote: > > I don't think this patch is safe as-is. sgin_arr is a stack array of size > > MAX_SKB_FRAGS (+ overhead), while my read of skb_cow_data is that it > > walks the whole chain of skbs from skb->next, and can return any number of > > segments. Therefore we

Re: Security enhancement proposal for kernel TLS

2018-08-01 Thread Dave Watson
On 07/31/18 10:45 AM, Vakul Garg wrote: > > > IIUC, with the upstream implementation of tls record layer in kernel, > > > the decryption of tls FINISHED message happens in kernel. Therefore > > > the keys are already being sent to kernel tls socket before handshake is > > completed. > > > > This i

Re: Security enhancement proposal for kernel TLS

2018-07-30 Thread Dave Watson
On 07/30/18 06:31 AM, Vakul Garg wrote: > > It's not entirely clear how your TLS handshake daemon works - Why is > > it necessary to set the keys in the kernel tls socket before the handshake > > is > > completed? > > IIUC, with the upstream implementation of tls record layer in kernel, the >

Re: [net-next v5 3/3] net/tls: Remove redundant array allocation.

2018-07-27 Thread Dave Watson
On 07/27/18 09:34 AM, Vakul Garg wrote: > > > > -Original Message- > > From: Dave Watson [mailto:davejwat...@fb.com] > > Sent: Thursday, July 26, 2018 2:31 AM > > To: Vakul Garg > > Cc: David Miller ; netdev@vger.kernel.org; > > bor...@mellano

Re: [PATCH net-next] net/tls: Removed redundant checks for non-NULL

2018-07-25 Thread Dave Watson
On 07/24/18 04:54 PM, Vakul Garg wrote: > Removed checks against non-NULL before calling kfree_skb() and > crypto_free_aead(). These functions are safe to be called with NULL > as an argument. > > Signed-off-by: Vakul Garg Acked-by: Dave Watson

Re: [net-next v5 3/3] net/tls: Remove redundant array allocation.

2018-07-25 Thread Dave Watson
On 07/24/18 08:22 AM, Vakul Garg wrote: > > I don't think this patch is safe as-is. sgin_arr is a stack array of size > > MAX_SKB_FRAGS (+ overhead), while my read of skb_cow_data is that it > > walks the whole chain of skbs from skb->next, and can return any number of > > segments. Therefore we

Re: Security enhancement proposal for kernel TLS

2018-07-25 Thread Dave Watson
You would probably get more responses if you cc the relevant people. Comments inline On 07/22/18 12:49 PM, Vakul Garg wrote: > The kernel based TLS record layer allows the user space world to use a > decoupled TLS implementation. > The applications need not be linked with TLS stack. > The TLS ha

Re: [net-next v5 3/3] net/tls: Remove redundant array allocation.

2018-07-23 Thread Dave Watson
On 07/21/18 07:25 PM, David Miller wrote: > From: Vakul Garg > Date: Thu, 19 Jul 2018 21:56:13 +0530 > > > In function decrypt_skb(), array allocation in case when sgout is NULL > > is unnecessary. Instead, local variable sgin_arr[] can be used. > > > > Signed-off-by: Vakul Garg > > Hmmm... >

[PATCH net-next] selftests: tls: add selftests for TLS sockets

2018-07-12 Thread Dave Watson
: Dave Watson --- tools/testing/selftests/net/Makefile | 2 +- tools/testing/selftests/net/tls.c| 692 +++ 2 files changed, 693 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/net/tls.c diff --git a/tools/testing/selftests/net/Makefile b/tools

Re: [PATCH v3 net-next 00/19] TLS offload rx, netdev & mlx5

2018-07-12 Thread Dave Watson
On 07/11/18 10:54 PM, Boris Pismenny wrote: > Hi, > > The following series provides TLS RX inline crypto offload. All the tls patches look good to me except #10 "tls: Fix zerocopy_from_iter iov handling" which seems to break the non-device zerocopy flow. The integration is very clean, thanks!

Re: [PATCH v3 net-next 10/19] tls: Fix zerocopy_from_iter iov handling

2018-07-12 Thread Dave Watson
On 07/11/18 10:54 PM, Boris Pismenny wrote: > zerocopy_from_iter iterates over the message, but it doesn't revert the > updates made by the iov iteration. This patch fixes it. Now, the iov can > be used after calling zerocopy_from_iter. This breaks tests (which I will send up as selftests shortly)

[PATCH net] tls: Stricter error checking in zerocopy sendmsg path

2018-07-12 Thread Dave Watson
26690f7b3126c5e...@syzkaller.appspotmail.com Reported-by: syzbot+709f2810a6a05f11d...@syzkaller.appspotmail.com Signed-off-by: Dave Watson Fixes: 3c4d7559159b ("tls: kernel TLS support") --- net/tls/tls_sw.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/tls/tls_sw.c b/net/tls/tl

Re: [PATCH net-next] net/tls: Removed redundant variable from 'struct tls_sw_context_rx'

2018-07-12 Thread Dave Watson
On 07/12/18 11:14 AM, Vakul Garg wrote: > Hi Boris > > Thanks for explaining. > Few questions/observations. > > 1. Isn't ' ctx->decrypted = true' a redundant statement in > tls_do_decryption()? > The same has been repeated in tls_recvmsg() after calling decrypt_skb()? > > 2. Similarly, ctx->sav

Re: [PATCH net] tls: fix NULL pointer dereference on poll

2018-06-11 Thread Dave Watson
s now NULL. > > Convert kTLS over to use ->poll_mask instead. Also instead of POLLIN | > POLLRDNORM use the proper EPOLLIN | EPOLLRDNORM bits as the case in > tcp_poll_mask() as well that is mangled here. Thanks, was just trying to bisect this myself. Works for me. Tested-by: Dave

[PATCH net] net/tls: Don't recursively call push_record during tls_write_space callbacks

2018-05-01 Thread Dave Watson
Andre Tomt Signed-off-by: Dave Watson --- include/net/tls.h | 1 + net/tls/tls_main.c | 7 +++ 2 files changed, 8 insertions(+) diff --git a/include/net/tls.h b/include/net/tls.h index 3da8e13..b400d0bb 100644 --- a/include/net/tls.h +++ b/include/net/tls.h @@ -148,6 +148,7 @@ struct tls_co

Re: kTLS in combination with mlx4 is very unstable

2018-05-01 Thread Dave Watson
Hi Andre, On 04/24/18 10:01 AM, Dave Watson wrote: > On 04/22/18 11:21 PM, Andre Tomt wrote: > > The kernel seems to get increasingly unstable as I load it up with client > > connections. At about 9Gbps and 700 connections, it is okay at least for a > > while - it migh

Re: kTLS in combination with mlx4 is very unstable

2018-04-24 Thread Dave Watson
On 04/22/18 11:21 PM, Andre Tomt wrote: > kTLS looks fun, so I decided to play with it. It is quite spiffy - however > with mlx4 I get kernel crashes I'm not seeing when testing on ixgbe. > > For testing I'm using a git build of the "stream reflector" cubemap[1] > configured with kTLS and 8 worker

Re: [PATCH] net/tls: Remove VLA usage

2018-04-11 Thread Dave Watson
4A2FQpadafLfEzK6CC=qpxydaacu1rq...@mail.gmail.com > > Signed-off-by: Kees Cook Thanks Acked-by: Dave Watson > --- > net/tls/tls_sw.c | 10 +- > 1 file changed, 9 insertions(+), 1 deletion(-) > > diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c > index 4dc766b

Re: [PATCH V4 net-next 06/14] net/tls: Add generic NIC offload infrastructure

2018-03-27 Thread Dave Watson
Thanks for doing the merge, it looks good to me. One issue below, otherwise all my SW tests still pass. On 03/27/18 02:51 PM, Saeed Mahameed wrote: > - if (ctx->conf == TLS_SW_TX || > - ctx->conf == TLS_SW_RX || > - ctx->conf == TLS_SW_RXTX) { > - tls_sw_free_resou

[PATCH v2 net] strparser: Fix sign of err codes

2018-03-27 Thread Dave Watson
xes: 43a0c6751a322847 ("strparser: Stream parser for messages") Signed-off-by: Dave Watson --- Documentation/networking/strparser.txt | 5 +++-- net/strparser/strparser.c | 8 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Documentation/networking/str

Re: [PATCH net] strparser: Fix sign of err codes

2018-03-27 Thread Dave Watson
On 03/26/18 01:44 PM, Tom Herbert wrote: > On Mon, Mar 26, 2018 at 12:31 PM, Dave Watson wrote: > > strp_parser_err is called with a negative code everywhere, which then > > calls abort_parser with a negative code. strp_msg_timeout calls > > abort_parser directly with a p

[PATCH net] strparser: Fix sign of err codes

2018-03-26 Thread Dave Watson
xes: 43a0c6751a322847 ("strparser: Stream parser for messages") Signed-off-by: Dave Watson --- net/strparser/strparser.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/strparser/strparser.c b/net/strparser/strparser.c index 1fdab5c..b9283ce 100644 --- a/net/strparse

[PATCH v2 net-next 5/6] tls: RX path for ktls

2018-03-22 Thread Dave Watson
finish reading a full frame. Actual decryption is only done during recvmsg or splice_read calls. Signed-off-by: Dave Watson --- include/net/tls.h| 27 ++- include/uapi/linux/tls.h | 2 + net/tls/Kconfig | 1 + net/tls/tls_main.c | 62 - net/tls/tls_sw.c

[PATCH v2 net-next 6/6] tls: Add receive path documentation

2018-03-22 Thread Dave Watson
Add documentation on rx path setup and cmsg interface. Signed-off-by: Dave Watson --- Documentation/networking/tls.txt | 66 ++-- 1 file changed, 64 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/tls.txt b/Documentation/networking

[PATCH v2 net-next 1/6] tls: Generalize zerocopy_from_iter

2018-03-22 Thread Dave Watson
Refactor zerocopy_from_iter to take arguments for pages and size, such that it can be used for both tx and rx. RX will also support zerocopy direct to output iter, as long as the full message can be copied at once (a large enough userspace buffer was provided). Signed-off-by: Dave Watson

[PATCH v2 net-next 3/6] tls: Pass error code explicitly to tls_err_abort

2018-03-22 Thread Dave Watson
Pass EBADMSG explicitly to tls_err_abort. Receive path will pass additional codes - EMSGSIZE if framing is larger than max TLS record size, EINVAL if TLS version mismatch. Signed-off-by: Dave Watson --- include/net/tls.h | 6 +++--- net/tls/tls_sw.c | 2 +- 2 files changed, 4 insertions(+), 4

[PATCH v2 net-next 2/6] tls: Move cipher info to a separate struct

2018-03-22 Thread Dave Watson
Separate tx crypto parameters to a separate cipher_context struct. The same parameters will be used for rx using the same struct. tls_advance_record_sn is modified to only take the cipher info. Signed-off-by: Dave Watson --- include/net/tls.h | 26 +--- net/tls/tls_main.c

[PATCH v2 net-next 4/6] tls: Refactor variable names

2018-03-22 Thread Dave Watson
Several config variables are prefixed with tx, drop the prefix since these will be used for both tx and rx. Signed-off-by: Dave Watson --- include/net/tls.h | 2 +- net/tls/tls_main.c | 26 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/net

[PATCH v2 net-next 0/6] TLS Rx

2018-03-22 Thread Dave Watson
ent crypto patchset to remove copies, resulting in optimally zero copies vs. userspace's one, vs. previous kernel's two. https://marc.info/?l=linux-crypto-vger&m=151931242406416&w=2 [2] https://github.com/Mellanox/openssl/commits/tls_rx2 [3] https://github.com/ktls/af_ktls

Re: [PATCH net-next 5/6] tls: RX path for ktls

2018-03-21 Thread Dave Watson
On 03/21/18 07:20 AM, Boris Pismenny wrote: > > > On 3/20/2018 7:54 PM, Dave Watson wrote: > > + ctx->control = header[0]; > > + > > + data_len = ((header[4] & 0xFF) | (header[3] << 8)); > > + > > + cipher_overhead = tls_ctx->rx.tag

Re: [PATCH net-next 06/14] net/tls: Add generic NIC offload infrastructure

2018-03-21 Thread Dave Watson
On 03/19/18 07:45 PM, Saeed Mahameed wrote: > +#define TLS_OFFLOAD_CONTEXT_SIZE > \ > + (ALIGN(sizeof(struct tls_offload_context), sizeof(void *)) + \ > + TLS_DRIVER_STATE_SIZE) > + > + pfrag = sk_page_frag(sk); > + > + /* KT

[PATCH net-next 6/6] tls: Add receive path documentation

2018-03-20 Thread Dave Watson
Add documentation on rx path setup and cmsg interface. Signed-off-by: Dave Watson --- Documentation/networking/tls.txt | 67 ++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/tls.txt b/Documentation/networking

[PATCH net-next 4/6] tls: Refactor variable names

2018-03-20 Thread Dave Watson
Several config variables are prefixed with tx, drop the prefix since these will be used for both tx and rx. Signed-off-by: Dave Watson --- include/net/tls.h | 2 +- net/tls/tls_main.c | 26 +- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/net

[PATCH net-next 5/6] tls: RX path for ktls

2018-03-20 Thread Dave Watson
finish reading a full frame. Actual decryption is only done during recvmsg or splice_read calls. Signed-off-by: Dave Watson --- include/net/tls.h| 27 ++- include/uapi/linux/tls.h | 2 + net/tls/Kconfig | 1 + net/tls/tls_main.c | 62 - net/tls/tls_sw.c | 587

[PATCH net-next 3/6] tls: Pass error code explicitly to tls_err_abort

2018-03-20 Thread Dave Watson
Pass EBADMSG explicitly to tls_err_abort. Receive path will pass additional codes - EMSGSIZE if framing is larger than max TLS record size, EINVAL if TLS version mismatch. Signed-off-by: Dave Watson --- include/net/tls.h | 6 +++--- net/tls/tls_sw.c | 2 +- 2 files changed, 4 insertions(+), 4

[PATCH net-next 1/6] tls: Generalize zerocopy_from_iter

2018-03-20 Thread Dave Watson
Refactor zerocopy_from_iter to take arguments for pages and size, such that it can be used for both tx and rx. RX will also support zerocopy direct to output iter, as long as the full message can be copied at once (a large enough userspace buffer was provided). Signed-off-by: Dave Watson

[PATCH net-next 2/6] tls: Move cipher info to a separate struct

2018-03-20 Thread Dave Watson
Separate tx crypto parameters to a separate cipher_context struct. The same parameters will be used for rx using the same struct. tls_advance_record_sn is modified to only take the cipher info. Signed-off-by: Dave Watson --- include/net/tls.h | 26 +--- net/tls/tls_main.c

[PATCH net-next 0/6] TLS Rx

2018-03-20 Thread Dave Watson
/marc.info/?l=linux-crypto-vger&m=151931242406416&w=2 [2] https://github.com/Mellanox/openssl/commits/tls_rx2 [3] https://github.com/ktls/af_ktls-tool/tree/RX Dave Watson (6): tls: Generalize zerocopy_from_iter tls: Move cipher info to a separate struct tls: Pass error code explicitly t

Re: [PATCH RFC 4/5] tls: RX path for ktls

2018-03-08 Thread Dave Watson
On 03/08/18 09:48 PM, Boris Pismenny wrote: > Hi Dave, > > On 03/08/18 18:50, Dave Watson wrote: > > Add rx path for tls software implementation. > > > > recvmsg, splice_read, and poll implemented. > > > > An additional sockopt TLS_RX is added, with th

[PATCH RFC 5/5] tls: Add receive path documentation

2018-03-08 Thread Dave Watson
Add documentation on rx path setup and cmsg interface. Signed-off-by: Dave Watson --- Documentation/networking/tls.txt | 59 ++-- 1 file changed, 57 insertions(+), 2 deletions(-) diff --git a/Documentation/networking/tls.txt b/Documentation/networking

[PATCH RFC 1/5] tls: Generalize zerocopy_from_iter

2018-03-08 Thread Dave Watson
Refactor zerocopy_from_iter to take arguments for pages and size, such that it can be used for both tx and rx. RX will also support zerocopy direct to output iter, as long as the full message can be copied at once (a large enough userspace buffer was provided). Signed-off-by: Dave Watson

[PATCH RFC 4/5] tls: RX path for ktls

2018-03-08 Thread Dave Watson
are provided to decrypt in to. sk_poll is overridden, and only returns POLLIN if a full TLS message is received. Otherwise we wait for strparser to finish reading a full frame. Actual decryption is only done during recvmsg or splice_read calls. Signed-off-by: Dave Watson --- include/net/tls.h

[PATCH RFC 3/5] tls: Pass error code explicitly to tls_err_abort

2018-03-08 Thread Dave Watson
Pass EBADMSG explicitly to tls_err_abort. Receive path will pass additional codes - E2BIG if framing is larger than max TLS record size. Signed-off-by: Dave Watson --- include/net/tls.h | 6 +++--- net/tls/tls_sw.c | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/include

[PATCH RFC 2/5] tls: Move cipher info to a separate struct

2018-03-08 Thread Dave Watson
Separate tx crypto parameters to a separate cipher_context struct. The same parameters will be used for rx using the same struct. tls_advance_record_sn is modified to only take the cipher info. Signed-off-by: Dave Watson --- include/net/tls.h | 26 +--- net/tls/tls_main.c

[PATCH RFC 0/5] TLX Rx

2018-03-08 Thread Dave Watson
imally zero copies vs. userspace's one, vs. previous kernel's two. https://marc.info/?l=linux-crypto-vger&m=151931242406416&w=2 [2] https://github.com/Mellanox/openssl/commits/tls_rx [3] https://github.com/ktls/af_ktls-tool/tree/RX Dave Watson (5): tls: Generalize zerocopy_fr

Re: [Crypto v7 03/12] tls: support for inline tls

2018-02-23 Thread Dave Watson
On 02/23/18 04:58 PM, Atul Gupta wrote: > > On 02/22/18 11:21 PM, Atul Gupta wrote: > > > @@ -403,6 +431,15 @@ static int do_tls_setsockopt_tx(struct sock *sk, > > > char __user *optval, > > > goto err_crypto_info; > > > } > > > > > > + rc = tls_offload_dev_absent(sk); > > > + if (rc

Re: [Crypto v7 03/12] tls: support for inline tls

2018-02-23 Thread Dave Watson
On 02/22/18 11:21 PM, Atul Gupta wrote: > @@ -403,6 +431,15 @@ static int do_tls_setsockopt_tx(struct sock *sk, char > __user *optval, > goto err_crypto_info; > } > > + rc = tls_offload_dev_absent(sk); > + if (rc == -EINVAL) { > + goto out; > + } else

Re: [Crypto v5 03/12] support for inline tls

2018-02-15 Thread Dave Watson
On 02/15/18 04:10 PM, Atul Gupta wrote: > > -Original Message- > > From: Dave Watson [mailto:davejwat...@fb.com] > > Sent: Thursday, February 15, 2018 9:22 PM > > To: Atul Gupta > > Cc: da...@davemloft.net; herb...@gondor.apana.org.au; s...@q

Re: [Crypto v5 03/12] support for inline tls

2018-02-15 Thread Dave Watson
On 02/15/18 12:24 PM, Atul Gupta wrote: > @@ -401,6 +430,15 @@ static int do_tls_setsockopt_tx(struct sock *sk, char > __user *optval, > goto out; > } > > + rc = get_tls_offload_dev(sk); > + if (rc) { > + goto out; > + } else { > + /* Retai

Re: [PATCHv2] tls: Add support for encryption using async offload accelerator

2018-01-31 Thread Dave Watson
On 01/31/18 05:22 PM, Vakul Garg wrote: > > > On second though in stable we should probably just disable async tfm > > > allocations. > > > It's simpler. But this approach is still good for -next > > > > > > > > > Gilad > > > > I agree with Gilad, just disable async for now. > > > > How to do it

Re: [RFC crypto v3 8/9] chtls: Register the ULP

2018-01-31 Thread Dave Watson
On 01/31/18 04:14 PM, Atul Gupta wrote: > > > On Tuesday 30 January 2018 10:41 PM, Dave Watson wrote: > > On 01/30/18 06:51 AM, Atul Gupta wrote: > > > > > What I was referring is that passing "tls" ulp type in setsockopt > > > may be insuf

Re: [PATCHv2] tls: Add support for encryption using async offload accelerator

2018-01-31 Thread Dave Watson
On 01/31/18 09:34 PM, Vakul Garg wrote: > Async crypto accelerators (e.g. drivers/crypto/caam) support offloading > GCM operation. If they are enabled, crypto_aead_encrypt() return error > code -EINPROGRESS. In this case tls_do_encryption() needs to wait on a > completion till the time the response

Re: [RFC crypto v3 8/9] chtls: Register the ULP

2018-01-30 Thread Dave Watson
On 01/30/18 06:51 AM, Atul Gupta wrote: > What I was referring is that passing "tls" ulp type in setsockopt > may be insufficient to make the decision when multi HW assist Inline > TLS solution exists. Setting the ULP doesn't choose HW or SW implementation, I think that should be done later when

Re: [bpf PATCH 1/3] net: add a UID to use for ULP socket assignment

2018-01-26 Thread Dave Watson
;t miss one). > @Dave Watson can you take a quick look to verify the changes are > good on TLS ULP side. Looks reasonable, and passes my test suite. One comment below Tested-by: Dave Watson > Signed-off-by: John Fastabend > --- > include/net/tcp.h |

Re: [RFC crypto v3 8/9] chtls: Register the ULP

2018-01-25 Thread Dave Watson
<1513769897-26945-1-git-send-email-atul.gu...@chelsio.com> On 12/20/17 05:08 PM, Atul Gupta wrote: > +static void __init chtls_init_ulp_ops(void) > +{ > + chtls_base_prot = tcp_prot; > + chtls_base_prot.hash= chtls_hash; > + chtls_base_prot.unhash =

[PATCH net] tls: Correct length of scatterlist in tls_sw_sendpage

2018-01-19 Thread Dave Watson
already calls sg_unmark_end correctly when it allocates memory in alloc_sg, or in zerocopy_from_iter. Signed-off-by: Dave Watson --- net/tls/tls_sw.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/tls/tls_sw.c b/net/tls/tls_sw.c index 61f394d..0a9b72f 100644 --- a/net/tls/tls_sw.c +++ b/net

Re: BUG_ON(sg->sg_magic != SG_MAGIC) on tls socket.

2017-08-11 Thread Dave Watson
Hi Dave, On 08/11/17 02:52 PM, Dave Jones wrote: > kernel BUG at ./include/linux/scatterlist.h:189! > invalid opcode: [#1] SMP KASAN ... > Call Trace: > ? copy_page_to_iter+0x6c0/0x6c0 > tls_sw_sendmsg+0x6d8/0x9c0 > ? alloc_sg+0x510/0x510 > ? cyc2ns_read_end+0x10/0x10 > ? import_iovec+

Re: [PATCH v2 net-next 3/4] tcp: Adjust TCP ULP to defer to sockets ULP

2017-08-02 Thread Dave Watson
On 08/01/17 08:18 PM, Tom Herbert wrote: > > -static int tls_init(struct sock *sk) > +static int tls_init(struct sock *sk, char __user *optval, int len) > { > - struct inet_connection_sock *icsk = inet_csk(sk); > struct tls_context *ctx; > int rc = 0; > > @@ -450,7 +449,7 @@ st

Re: [PATCH v2 net-next 3/4] tcp: Adjust TCP ULP to defer to sockets ULP

2017-08-02 Thread Dave Watson
some ktls tests with no issues. Thanks Tested-by: Dave Watson

Re: [PATCH v3 net-next 1/4] tcp: ULP infrastructure

2017-07-31 Thread Dave Watson
On 07/29/17 01:12 PM, Tom Herbert wrote: > On Wed, Jun 14, 2017 at 11:37 AM, Dave Watson wrote: > > Add the infrustructure for attaching Upper Layer Protocols (ULPs) over TCP > > sockets. Based on a similar infrastructure in tcp_cong. The idea is that > > any > > U

Re: Kernel TLS in 4.13-rc1

2017-07-31 Thread Dave Watson
On 07/30/17 11:14 PM, David Oberhollenzer wrote: > On 07/24/2017 11:10 PM, Dave Watson wrote: > > On 07/23/17 09:39 PM, David Oberhollenzer wrote: > >> After fixing the benchmark/test tool that the patch description > >> linked to (https://github.com/Mellanox/tls-af_k

Re: Kernel TLS in 4.13-rc1

2017-07-24 Thread Dave Watson
On 07/23/17 09:39 PM, David Oberhollenzer wrote: > After fixing the benchmark/test tool that the patch description > linked to (https://github.com/Mellanox/tls-af_ktls_tool) to make > sure that the server and client actually *agree* on AES-128-GCM, > I simply ran the client program with the --verif

Re: [PATCH v3 net-next 3/4] tls: kernel TLS support

2017-07-12 Thread Dave Watson
On 07/12/17 09:20 AM, Steffen Klassert wrote: > On Tue, Jul 11, 2017 at 11:53:11AM -0700, Dave Watson wrote: > > On 07/11/17 08:29 AM, Steffen Klassert wrote: > > > Sorry for replying to old mail... > > > > +int tls_set_sw_offload(struct soc

Re: [PATCH v3 net-next 3/4] tls: kernel TLS support

2017-07-11 Thread Dave Watson
On 07/11/17 08:29 AM, Steffen Klassert wrote: > Sorry for replying to old mail... > > +int tls_set_sw_offload(struct sock *sk, struct tls_context *ctx) > > +{ > > ... > > > + > > + if (!sw_ctx->aead_send) { > > + sw_ctx->aead_send = crypto_alloc_aead("gcm(aes)", 0, 0); > > +

Re: [PATCH v3 net-next 0/4] kernel TLS

2017-07-06 Thread Dave Watson
Hi Richard, On 07/06/17 04:30 PM, Richard Weinberger wrote: > Dave, > > On Wed, Jun 14, 2017 at 8:36 PM, Dave Watson wrote: > > Documentation/networking/tls.txt | 135 +++ > > MAINTAINERS| 10 + > > include/linux/socket.h

[PATCH net-next] tcp: fix null ptr deref in getsockopt(..., TCP_ULP, ...)

2017-06-26 Thread Dave Watson
-executor1/15452 Signed-off-by: Dave Watson Reported-by: "Levin, Alexander (Sasha Levin)" --- net/ipv4/tcp.c | 5 + 1 file changed, 5 insertions(+) diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index 058f509..4c88d20 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c @@ -3062,

Re: [PATCH v3 net-next 1/4] tcp: ULP infrastructure

2017-06-26 Thread Dave Watson
On 06/25/17 02:42 AM, Levin, Alexander (Sasha Levin) wrote: > On Wed, Jun 14, 2017 at 11:37:14AM -0700, Dave Watson wrote: > >Add the infrustructure for attaching Upper Layer Protocols (ULPs) over TCP > >sockets. Based on a similar infrastructure in tcp_cong. The idea is that any

Re: [PATCH -net] tls: return -EFAULT if copy_to_user() fails

2017-06-23 Thread Dave Watson
On 06/23/17 01:15 PM, Dan Carpenter wrote: > The copy_to_user() function returns the number of bytes remaining but we > want to return -EFAULT here. > > Fixes: 3c4d7559159b ("tls: kernel TLS support") > Signed-off-by: Dan Carpenter Acked-by: Dave Watson Yes, -EFAU

  1   2   >