All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 net-next 0/6] TLS Rx
@ 2018-03-22 17:09 Dave Watson
  2018-03-23 16:27 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Watson @ 2018-03-22 17:09 UTC (permalink / raw)
  To: David S. Miller, Tom Herbert, Alexei Starovoitov, herbert,
	linux-crypto, netdev, borisp
  Cc: Atul Gupta, Vakul Garg, Hannes Frederic Sowa, Steffen Klassert,
	John Fastabend, Daniel Borkmann

TLS tcp socket RX implementation, to match existing TX code.

This patchset completes the software TLS socket, allowing full
bi-directional communication over TLS using normal socket syscalls,
after the handshake has been done in userspace.  Only the symmetric
encryption is done in the kernel.

This allows usage of TLS sockets from within the kernel (for example
with network block device, or from bpf).  Performance can be better
than userspace, with appropriate crypto routines [1].

sk->sk_socket->ops must be overridden to implement splice_read and
poll, but otherwise the interface & implementation match TX closely.
strparser is used to parse TLS framing on receive.

There are Openssl RX patches that work with this interface [2], as
well as a testing tool using the socket interface directly (without
cmsg support) [3].  An example tcp socket setup is:

  // Normal tcp socket connect/accept, and TLS handshake
  // using any TLS library.
  setsockopt(sock, SOL_TCP, TCP_ULP, "tls", sizeof("tls"));

  struct tls12_crypto_info_aes_gcm_128 crypto_info_rx;
  // Fill in crypto_info based on negotiated keys.

  setsockopt(sock, SOL_TLS, TLS_RX, &crypto_info, sizeof(crypto_info_rx));
  // You can optionally TLX_TX as well.

  char buffer[16384];
  int ret = recv(sock, buffer, 16384);

  // cmsg can be received using recvmsg and a msg_control 
  // of type TLS_GET_RECORD_TYPE will be set.

V1 -> V2

* For too-small framing errors, return EBADMSG, to match openssl error
  code semantics.  Docs and commit logs about this also updated.

RFC -> V1

* Refactor 'tx' variable names to drop tx
* Error return codes changed per discussion
* Only call skb_cow_data based on in-place decryption, 
  drop unnecessary frag list check.

[1] Recent 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-tool/tree/RX

Dave Watson (6):
  tls: Generalize zerocopy_from_iter
  tls: Move cipher info to a separate struct
  tls: Pass error code explicitly to tls_err_abort
  tls: Refactor variable names
  tls: RX path for ktls
  tls: Add receive path documentation

 Documentation/networking/tls.txt |  66 +++-
 include/net/tls.h                |  61 ++--
 include/uapi/linux/tls.h         |   2 +
 net/tls/Kconfig                  |   1 +
 net/tls/tls_main.c               |  92 ++++--
 net/tls/tls_sw.c                 | 644 ++++++++++++++++++++++++++++++++++-----
 6 files changed, 740 insertions(+), 126 deletions(-)

-- 
2.9.5

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH v2 net-next 0/6] TLS Rx
  2018-03-22 17:09 [PATCH v2 net-next 0/6] TLS Rx Dave Watson
@ 2018-03-23 16:27 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-03-23 16:27 UTC (permalink / raw)
  To: davejwatson
  Cc: tom, alexei.starovoitov, herbert, linux-crypto, netdev, borisp,
	atul.gupta, vakul.garg, hannes, steffen.klassert, john.fastabend,
	daniel

From: Dave Watson <davejwatson@fb.com>
Date: Thu, 22 Mar 2018 10:09:44 -0700

> TLS tcp socket RX implementation, to match existing TX code.

Looks great Dave.  Applied, and once my build tests finish I'll push
this out to net-next.

In some of the new functions, reverse christmas tree ordering of local
variables was not adhered to.

I know it can be difficult in some situations, but please fix this up in
followon patches.  You can move the assignments down into the function
body to accomodate this, if necessary.

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-03-23 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-22 17:09 [PATCH v2 net-next 0/6] TLS Rx Dave Watson
2018-03-23 16:27 ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.