freebsd-dev/sys
Andrew Gallatin b2dba6634b kTLS: Fix a bug where we would not encrypt anon data inplace.
Software Kernel TLS needs to allocate a new destination crypto
buffer when encrypting data from the page cache, so as to avoid
overwriting shared clear-text file data with encrypted data
specific to a single socket. When the data is anonymous, eg, not
tied to a file, then we can encrypt in place and avoid allocating
a new page. This fixes a bug where the existing code always
assumes the data is private, and never encrypts in place. This
results in unneeded page allocations and potentially more memory
bandwidth consumption when doing socket writes.

When the code was written at Netflix, ktls_encrypt() looked at
private sendfile flags to determine if the pages being encrypted
where part of the page cache (coming from sendfile) or
anonymous (coming from sosend). This was broken internally at
Netflix when the sendfile flags were made private, and the
M_WRITABLE() check was added. Unfortunately, M_WRITABLE() will
always be false for M_NOMAP mbufs, since one cannot just mtod()
them.

This change introduces a new flags field to the mbuf_ext_pgs
struct by stealing a byte from the tls hdr. Note that the current
header is still 2 bytes larger than the largest header we
support: AES-CBC with explicit IV. We set MBUF_PEXT_FLAG_ANON
when creating an unmapped mbuf in m_uiotombuf_nomap() (which is
the path that socket writes take), and we check for that flag in
ktls_encrypt() when looking for anon pages.

Reviewed by:	jhb
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D21796
2019-09-27 20:08:19 +00:00
..
amd64 Improve MD page fault handlers. 2019-09-27 18:43:36 +00:00
arm Improve MD page fault handlers. 2019-09-27 18:43:36 +00:00
arm64 Improve MD page fault handlers. 2019-09-27 18:43:36 +00:00
bsm
cam Add kern.cam.da.X.quirks tunable, similar existing for ada. 2019-09-26 14:48:39 +00:00
cddl Implement x86 dtrace_invop_(un)init() in C. 2019-09-23 15:08:17 +00:00
compat sysent: regenerate after r352747. 2019-09-26 15:41:10 +00:00
conf Move EPOCH_TRACE to opt_global.h, so that any external modules that 2019-09-26 21:12:47 +00:00
contrib ipf mistakenly regards UDP packets with a checksum of 0xffff as bad. 2019-09-26 03:09:42 +00:00
crypto
ddb
dev nvdimm(4): Extract ACPI root bus driver 2019-09-27 16:32:44 +00:00
dts
fs Replace all mtx_assert() calls for n_mtx and ncl_iod_mutex with macros. 2019-09-26 02:54:45 +00:00
gdb
geom
gnu
i386 Improve MD page fault handlers. 2019-09-27 18:43:36 +00:00
isa
kern kTLS: Fix a bug where we would not encrypt anon data inplace. 2019-09-27 20:08:19 +00:00
kgssapi
libkern
mips Improve MD page fault handlers. 2019-09-27 18:43:36 +00:00
modules nvdimm(4): Extract ACPI root bus driver 2019-09-27 16:32:44 +00:00
net kTLS support for TLS 1.3 2019-09-27 19:17:40 +00:00
net80211
netgraph
netinet Add new functionality to switch to using cookies exclusively when we the 2019-09-26 15:18:57 +00:00
netinet6 When processing an incoming IPv6 packet over the loopback interface which 2019-09-19 10:22:29 +00:00
netipsec
netpfil
netsmb
nfs
nfsclient
nfsserver
nlm
ofed
opencrypto kTLS support for TLS 1.3 2019-09-27 19:17:40 +00:00
powerpc Improve MD page fault handlers. 2019-09-27 18:43:36 +00:00
riscv Improve MD page fault handlers. 2019-09-27 18:43:36 +00:00
rpc
security
sparc64 Improve MD page fault handlers. 2019-09-27 18:43:36 +00:00
sys kTLS: Fix a bug where we would not encrypt anon data inplace. 2019-09-27 20:08:19 +00:00
teken
tests
tools
ufs
vm Improve MD page fault handlers. 2019-09-27 18:43:36 +00:00
x86 Complete the removal of the "wire_count" field from struct vm_page. 2019-09-25 16:11:35 +00:00
xdr
xen
Makefile