opnsense-src/sys/sys
John Baldwin ba6b771d17 ktls: Ensure FIFO encryption order for TLS 1.0.
TLS 1.0 records are encrypted as one continuous CBC chain where the
last block of the previous record is used as the IV for the next
record.  As a result, TLS 1.0 records cannot be encrypted out of order
but must be encrypted as a FIFO.

If the later pages of a sendfile(2) request complete before the first
pages, then TLS records can be encrypted out of order.  For TLS 1.1
and later this is fine, but this can break for TLS 1.0.

To cope, add a queue in each TLS session to hold TLS records that
contain valid unencrypted data but are waiting for an earlier TLS
record to be encrypted first.

- In ktls_enqueue(), check if a TLS record being queued is the next
  record expected for a TLS 1.0 session.  If not, it is placed in
  sorted order in the pending_records queue in the TLS session.

  If it is the next expected record, queue it for SW encryption like
  normal.  In addition, check if this new record (really a potential
  batch of records) was holding up any previously queued records in
  the pending_records queue.  Any of those records that are now in
  order are also placed on the queue for SW encryption.

- In ktls_destroy(), free any TLS records on the pending_records
  queue.  These mbufs are marked M_NOTREADY so were not freed when the
  socket buffer was purged in sbdestroy().  Instead, they must be
  freed explicitly.

Reviewed by:	gallatin, markj
Sponsored by:	Netflix
Differential Revision:	https://reviews.freebsd.org/D32381

(cherry picked from commit 9f03d2c001)
2021-11-23 15:11:44 -08:00
..
disk
_atomic64e.h
_atomic_subword.h
_bitset.h
_blockcount.h
_bus_dma.h
_callout.h
_clock_id.h clock_gettime: Add Linux aliases for CLOCK_* 2021-09-12 09:56:16 -06:00
_cpuset.h
_domainset.h
_endian.h Consolidate machine/endian.h definitions 2021-06-24 20:42:56 -03:00
_eventhandler.h
_ffcounter.h
_iovec.h
_lock.h
_lockmgr.h
_mutex.h
_null.h
_pctrie.h
_pthreadtypes.h
_rangeset.h
_rmlock.h
_rwlock.h
_semaphore.h
_seqc.h
_sigset.h
_smr.h
_sockaddr_storage.h
_stack.h
_stdarg.h
_stdint.h
_sx.h
_task.h
_termios.h termios: add more speeds 2021-07-18 00:34:57 +00:00
_timespec.h
_timeval.h
_types.h
_ucontext.h
_uio.h
_umtx.h Revert most of ce42e79310 2021-08-03 12:52:36 +03:00
_unrhdr.h
_winsize.h
aac_ioctl.h
abi_compat.h
acct.h
acl.h
agpio.h
aio.h
alq.h
apm.h
arb.h
asan.h kasan: Use vm_offset_t for the first parameter to kasan_shadow_map() 2021-11-02 18:17:58 -04:00
assym.h genoffset: simplify and rewrite in sh 2021-09-12 09:56:14 -06:00
ata.h
atomic_common.h atomic: add atomic_interrupt_fence() 2021-03-03 05:08:15 +02:00
atomic_san.h Generalize bus_space(9) and atomic(9) sanitizer interceptors 2021-11-01 10:16:39 -04:00
auxv.h
backlight.h
bio.h
bitset.h bitset: Reimplement BIT_FOREACH_IS(SET|CLR) 2021-11-01 09:20:11 -04:00
bitstring.h bitstring(3): Add bitstring traversal macros. 2021-08-24 01:23:10 +03:00
blist.h
blockcount.h
boot.h
buf.h buffer pager: allow get_blksize method to return error 2021-09-24 03:26:59 +03:00
buf_ring.h
bufobj.h
bus.h sys/bus.h: silence warnings about write-only variables 2021-10-27 03:24:40 +03:00
bus_dma.h
bus_dma_internal.h
bus_san.h Generalize bus_space(9) and atomic(9) sanitizer interceptors 2021-11-01 10:16:39 -04:00
busdma_bufalloc.h
callout.h
caprights.h
capsicum.h
cdefs.h cdefs: Make __nosanitizeaddress work for KASAN as well 2021-11-01 10:05:50 -04:00
cdio.h
cdrio.h
cfictl.h
chio.h
ck.h sys/ck.h: Add an include guard 2021-04-15 16:01:49 -07:00
clock.h
cnv.h
compressor.h
condvar.h
conf.h Suppress D_NEEDGIANT warnings for some drivers 2021-06-14 16:25:14 -04:00
cons.h Re-implement virtual console (constty). 2021-10-03 21:15:02 -04:00
consio.h
copyright.h
counter.h
coverage.h
cpu.h
cpuctl.h
cpuset.h cpuset(9): Add CPU_FOREACH_IS(SET|CLR) and modify consumers to use it 2021-11-01 09:20:11 -04:00
csan.h
ctype.h
devctl.h
devicestat.h
devmap.h
dirent.h
disk.h
disk_zone.h
disklabel.h
diskmbr.h
dkstat.h
dnv.h
domain.h
domainset.h domainset: Define additional global policies 2021-04-28 10:00:36 -04:00
dtrace_bsd.h
dvdio.h
efi.h
efiio.h
elf.h
elf32.h sys: Add definitions for RELR relative relocation format 2021-10-23 02:32:27 +03:00
elf64.h sys: Add definitions for RELR relative relocation format 2021-10-23 02:32:27 +03:00
elf_common.h sys: Add definitions for RELR relative relocation format 2021-10-23 02:32:27 +03:00
elf_generic.h sys: Add definitions for RELR relative relocation format 2021-10-23 02:32:27 +03:00
endian.h
epoch.h The old thread priority must be stored as part of the EPOCH(9) tracker. 2021-06-02 14:03:21 +02:00
errno.h
eui64.h
event.h kqueue: drain kqueue taskqueue if syscall tickled it 2021-09-12 15:17:27 +03:00
eventfd.h
eventhandler.h
eventvar.h
exec.h
extattr.h
fail.h
fbio.h
fcntl.h openat(2): add O_EMPTY_PATH 2021-05-19 06:13:14 +03:00
fdcio.h
file.h O_PATH: allow vnode kevent filter on such files 2021-04-23 14:14:10 +03:00
filedesc.h fd: add pwd_hold_proc 2021-10-11 09:13:03 +00:00
filio.h
firmware.h firmware(9): extend firmware_get() by a "no warn" flag. 2021-02-01 07:15:29 +00:00
fnv_hash.h
font.h loader: remove BORDER_PIXELS 2021-02-15 23:04:01 +02:00
gmon.h
gpio.h Fix build of stand/usb . 2021-05-10 16:11:19 +02:00
gpt.h
gsb_crc32.h tests/sys/kern/crc32: Check for SSE4.2 before using it 2021-04-22 10:41:09 +01:00
gtaskqueue.h Make sure all tasklets are drained before unloading the LinuxKPI. 2021-06-02 13:23:19 +02:00
hash.h
hhook.h
iconv.h
imgact.h struct image_params: use bool type for boolean members 2021-11-06 04:12:31 +02:00
imgact_aout.h
imgact_binmisc.h
imgact_elf.h
interrupt.h MFC 6eb60f5b7f: 2021-03-23 11:51:04 +01:00
intr.h kern/intr: declare interrupt vectors unsigned 2021-05-10 09:36:20 -04:00
ioccom.h ioccom: define ioctl cmd value that can never be valid 2021-05-07 03:36:00 +03:00
ioctl.h
ioctl_compat.h
iov.h
iov_schema.h
ipc.h
ipmi.h
jail.h kern: ether_gen_addr: randomize on default hostuuid, too 2021-08-20 14:32:31 -07:00
joystick.h
kbio.h
kcov.h
kdb.h Introduce kdb-level watchpoint functions 2021-04-21 10:20:33 -03:00
kenv.h kenv: allow listing of static kernel environments 2021-08-26 01:35:33 -05:00
kern_prefetch.h
kernel.h config_intrhook: provide config_intrhook_drain 2021-07-12 13:30:55 -06:00
kerneldump.h minidump: De-duplicate the progress bar 2021-10-15 12:20:48 -03:00
khelp.h
kobj.h
kpilite.h Use atomic_interrupt_fence() instead of bare __compiler_membar() 2021-03-06 04:06:55 +02:00
ksem.h
kthread.h
ktls.h ktls: Ensure FIFO encryption order for TLS 1.0. 2021-11-23 15:11:44 -08:00
ktr.h
ktr_class.h
ktrace.h Fix a braino in previous. 2021-06-13 04:22:34 +03:00
libkern.h Generalize sanitizer interceptors for memory and string routines 2021-11-01 10:20:50 -04:00
limits.h
link_aout.h
link_elf.h
linker.h link_elf_obj: Invoke fini callbacks 2021-08-12 09:43:41 -04:00
linker_set.h linker_set: Disable ASAN only in userspace 2021-11-01 10:05:39 -04:00
lock.h
lock_profile.h lockprof: pass lock type as an argument instead of reading the spin flag 2021-06-02 15:00:23 +00:00
lockf.h
lockmgr.h
lockstat.h lockprof: pass lock type as an argument instead of reading the spin flag 2021-06-02 15:00:23 +00:00
loginclass.h
mac.h
malloc.h Add a VM flag to prevent reclaim on a failed contig allocation 2021-11-03 13:35:16 -04:00
mbuf.h mbuf: PACKET_TAG_PF should not be persistent 2021-11-19 06:51:58 +01:00
mchain.h
md4.h
md5.h
mdioctl.h
memdesc.h
memrange.h
mman.h
module.h
module_khelp.h
mount.h mount.h: improve a comment about flags 2021-08-28 10:16:52 +02:00
mouse.h
mpt_ioctl.h
mqueue.h
msg.h
msgbuf.h
mtio.h
mutex.h lockprof: pass lock type as an argument instead of reading the spin flag 2021-06-02 15:00:23 +00:00
namei.h softdep_prelink(): only do sync if other thread changed the vnode metadata since previous prelink 2021-07-07 13:50:13 +03:00
nlist_aout.h
nv.h
osd.h
param.h Bump __FreeBSD_version to 1300521. 2021-11-19 00:09:37 +00:00
pciio.h pci: Add an ioctl to perform I/O to BARs 2021-08-29 12:39:42 -04:00
pcpu.h Rename struct device to struct _device 2021-04-19 14:17:08 -04:00
pctrie.h
physmem.h
pidctrl.h
pipe.h
pmc.h hwpmc: fix PMC_CPU_LAST 2021-07-29 12:01:09 -03:00
pmckern.h
pmclog.h
poll.h
posix4.h
power.h
priority.h
priv.h
prng.h
proc.h Extract proc_get_binpath() from sysctl_kern_proc_pathname() 2021-11-06 04:12:32 +02:00
procctl.h procctl(2): Add PROC_WXMAP_CTL/STATUS 2021-09-24 03:26:59 +03:00
procdesc.h
procfs.h
protosw.h uipc: create dedicated lists for fast and slow timeout callbacks 2021-08-23 12:32:01 +00:00
ptio.h
ptrace.h sys_process.c: extract ptrace_unsuspend() 2021-06-01 03:38:53 +03:00
qmath.h
queue.h qeueue.h: Add {SLIST,STAILQ,LIST,TAILQ}_END() 2021-03-04 17:43:48 +00:00
racct.h
random.h
rangelock.h
rangeset.h
rctl.h
reboot.h
refcount.h
regression.h
resource.h
resourcevar.h Fix up macro use in lim_cur 2021-06-07 00:34:55 +00:00
rman.h
rmlock.h rmlock(9): add an RM_DUPOK flag 2021-04-16 10:48:02 -03:00
rtprio.h
runq.h
rwlock.h
sbuf.h Export sbuf_drain to orchestrate lock and drain action 2021-04-16 20:50:48 +02:00
sched.h Use atomic_interrupt_fence() instead of bare __compiler_membar() 2021-03-06 04:06:55 +02:00
sdt.h
select.h
selinfo.h
sem.h
sema.h
seqc.h seqc: add symbolic name for in-modify bit 2021-07-07 13:23:20 +03:00
serial.h
sf_buf.h
sglist.h sglist: Add sglist_append_single_mbuf(). 2021-10-21 08:51:26 -07:00
shm.h
sigio.h
signal.h
signalvar.h signal: Add SIG_FOREACH and refactor issignal() 2021-11-01 09:20:11 -04:00
sleepqueue.h Allow sleepq_signal() to drop the lock. 2021-07-08 21:38:32 -04:00
slicer.h
smp.h x86: Add NUMA nodes into CPU topology. 2021-10-21 18:24:36 -04:00
smr.h
smr_types.h
snoop.h
sockbuf.h socket: Rename sb(un)lock() and interlock with listen(2) 2021-10-07 09:56:47 -04:00
socket.h socket: Implement SO_RERROR 2021-08-10 18:54:00 -07:00
socketvar.h socket: Rename sb(un)lock() and interlock with listen(2) 2021-10-07 09:56:47 -04:00
sockio.h
sockopt.h
soundcard.h Fix a few typos in comments 2021-03-20 11:13:01 +01:00
specialfd.h
spigenio.h
stack.h
stat.h
stats.h
statvfs.h
stdatomic.h
stddef.h
stdint.h
sx.h
syscall.h Regen 2021-08-03 12:52:36 +03:00
syscall.mk Regen 2021-08-03 12:52:36 +03:00
syscallsubr.h
sysctl.h
sysent.h Unmap shared page manually before doing vm_map_remove() on exit or exec 2021-11-04 02:56:39 +02:00
syslimits.h
syslog.h
sysproto.h Regen 2021-08-03 12:52:36 +03:00
systm.h sysbeep: Adjust interface to take a duration as a sbt 2021-11-18 21:52:22 -07:00
taskqueue.h taskqueue: Add missing comma to TASKQUEUE_FAST_DEFINE_THREAD 2021-05-31 17:54:08 -07:00
terminal.h
termios.h
thr.h
tiio.h
tim_filter.h
time.h time.h: reduce CLOCK_ namespace pollution, move to _clock_id.h 2021-09-12 09:56:16 -06:00
timeb.h
timeet.h
timeffc.h
timepps.h
timers.h Stop arming realtime posix process timers on suspend or terminate 2021-04-23 14:14:09 +03:00
times.h
timespec.h
timetc.h
timex.h
tree.h
tslog.h
tty.h
ttycom.h
ttydefaults.h
ttydevsw.h
ttydisc.h
ttyhook.h
ttyqueue.h
turnstile.h
types.h Rename struct device to struct _device 2021-04-19 14:17:08 -04:00
ucontext.h
ucred.h
uio.h
umtx.h Revert most of ce42e79310 2021-08-03 12:52:36 +03:00
un.h
unistd.h
unpcb.h
user.h sysctl vm.objects: report backing object and swap use 2021-04-23 14:14:11 +03:00
utsname.h
uuid.h
vdso.h
vmem.h
vmmeter.h
vnode.h Make locking assertions for VOP_FSYNC() and VOP_FDATASYNC() more correct 2021-11-19 06:25:29 +02:00
vtoc.h
wait.h
watchdog.h