freebsd-skq/sys
Gleb Smirnoff 9c64cfe56c The sendfile(2) allows to send extra data from userspace before the file
data (headers).  Historically the size of the headers was not checked
against the socket buffer space.  Application could easily overcommit the
socket buffer space.

With the new sendfile (r293439) the problem remained, but a KASSERT was
inserted that checked that amount of data written to the socket matches
its space.  In case when size of headers is bigger that socket space,
KASSERT fires.  Without INVARIANTS the new sendfile won't panic, but
would report incorrect amount of bytes sent.

o With this change, the headers copyin is moved down into the cycle, after
  the sbspace() check.  The uio size is trimmed by socket space there,
  which fixes the overcommit problem and its consequences.
o The compatibility handling for FreeBSD 4 sendfile headers API is pushed
  up the stack to syscall wrappers.  This required a copy and paste of the
  code, but in turn this allowed to remove extra stack carried parameter
  from fo_sendfile_t, and embrace entire compat code into #ifdef.  If in
  future we got more fo_sendfile_t function, the copy and paste level would
  even reduce.

Reviewed by:	emax, gallatin, Maxim Dounin <mdounin mdounin.ru>
Tested by:	Vitalij Satanivskij <satan ukr.net>
Sponsored by:	Netflix
2016-03-29 19:57:11 +00:00
..
amd64 Type of the interrupt handlers on x86 cannot be expressed in C. 2016-03-29 19:56:48 +00:00
arm Add the SPI driver for am335x. 2016-03-29 19:11:04 +00:00
arm64 Read the CPU ID for the current CPU from the GIC. The GIC may have a 2016-03-29 13:51:26 +00:00
boot Do not prompt for GELI passphrase is encrypted with keys only 2016-03-26 15:39:48 +00:00
bsm
cam CAM: Generalize 4k quirk to all Samsung MZ7* SSDs 2016-03-29 06:56:46 +00:00
cddl Modify "4958 zdb trips assert on pools with ashift >= 0xe". 2016-03-29 19:18:34 +00:00
compat The sendfile(2) allows to send extra data from userspace before the file 2016-03-29 19:57:11 +00:00
conf Reduce OFW PCI code duplication - involves ARM, PPC and SPARC64 2016-03-29 15:19:56 +00:00
contrib krping wasn't designed to take more than one client. Fail any connect 2016-03-29 01:41:07 +00:00
crypto
ddb Add td_swinvoltick to track last involuntary context switch 2016-03-25 19:35:29 +00:00
dev Reduce OFW PCI code duplication - involves ARM, PPC and SPARC64 2016-03-29 15:19:56 +00:00
fs Update superblock and inode structs for ext4. 2016-03-28 07:44:55 +00:00
gdb
geom
gnu
i386 Type of the interrupt handlers on x86 cannot be expressed in C. 2016-03-29 19:56:48 +00:00
isa Fix the resource_list_print_type() calls to use uintmax_t. 2016-03-22 22:25:08 +00:00
kern The sendfile(2) allows to send extra data from userspace before the file 2016-03-29 19:57:11 +00:00
kgssapi
libkern
mips Fix the resource_list_print_type() calls to use uintmax_t. 2016-03-22 22:25:08 +00:00
modules Use proper kern.opts.mk rather than src.opts.mk from r297058. 2016-03-29 15:26:53 +00:00
net Remove some NULL checks for M_WAITOK allocations. 2016-03-29 13:56:59 +00:00
net80211 net80211: fix panic for DWDS vaps 2016-03-26 08:59:56 +00:00
netgraph
netinet Remove some NULL checks for M_WAITOK allocations. 2016-03-29 13:56:59 +00:00
netinet6 Modify nd6_llinfo_timer() to acquire the nd6 lock before the LLE lock. 2016-03-29 19:23:00 +00:00
netipsec
netnatm
netpfil
netsmb
nfs Do not try to install a default route for each interface found, because 2016-03-27 23:16:37 +00:00
nfsclient
nfsserver
nlm
ofed
opencrypto
pc98 Fix the resource_list_print_type() calls to use uintmax_t. 2016-03-22 22:25:08 +00:00
powerpc Reduce OFW PCI code duplication - involves ARM, PPC and SPARC64 2016-03-29 15:19:56 +00:00
riscv
rpc Remove some NULL checks for M_WAITOK allocations. 2016-03-29 13:56:59 +00:00
security
sparc64 Fix the resource_list_print_type() calls to use uintmax_t. 2016-03-22 22:25:08 +00:00
sys The sendfile(2) allows to send extra data from userspace before the file 2016-03-29 19:57:11 +00:00
teken
tests
tools
ufs Remove some NULL checks for M_WAITOK allocations. 2016-03-29 13:56:59 +00:00
vm
x86 Type of the interrupt handlers on x86 cannot be expressed in C. 2016-03-29 19:56:48 +00:00
xdr
xen
Makefile