freebsd-nq/sys/compat
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
..
cloudabi Replace the CloudABI system call table by a machine generated version. 2016-03-24 21:47:15 +00:00
cloudabi64 Regenerate system call table after r297247. 2016-03-24 21:49:39 +00:00
freebsd32 The sendfile(2) allows to send extra data from userspace before the file 2016-03-29 19:57:11 +00:00
ia32 Implement vsyscall hack. Prior to 2.13 glibc uses vsyscall 2016-01-09 20:18:53 +00:00
linprocfs Implement /proc/$$/limits. 2016-02-21 14:56:05 +00:00
linsysfs Add support to the jail framework to be able to mount linsysfs(5) and 2015-07-19 08:52:35 +00:00
linux Revert r297310 as the SOL_XXX are equal to the IPPROTO_XX except SOL_SOCKET. 2016-03-27 10:09:10 +00:00
linuxkpi/common Run the LinuxKPI PCI shutdown handler free of the Giant mutex. 2016-03-07 14:35:31 +00:00
ndis Use uintmax_t (typedef'd to rman_res_t type) for rman ranges. 2016-03-18 01:28:41 +00:00
netbsd
svr4 As <machine/vmparam.h> is included from <vm/vm_param.h>, there is no 2016-02-22 09:08:04 +00:00
x86bios Silence VPS-Studio errors (V512). These buffer underflows are intentional. 2016-02-18 19:37:39 +00:00