freebsd-dev/sys
Lawrence Stewart 9a61faf67d An off-by-one error exists in sbuf_vprintf()'s use of SBUF_HASROOM() when an
sbuf is filled to capacity by vsnprintf(), the loop exits without error, and
the sbuf is not marked as auto-extendable.

SBUF_HASROOM() evaluates true if there is room for one or more non-NULL
characters, but in the case that the sbuf was filled exactly to capacity,
SBUF_HASROOM() evaluates false. Consequently, sbuf_vprintf() incorrectly
assigns an ENOMEM error to the sbuf when in fact everything is fine, in turn
poisoning the buffer for all subsequent operations.

Correct by moving the ENOMEM assignment into the loop where it can be made
unambiguously.

As a related safety net change, explicitly check for the zero bytes drained
case in sbuf_drain() and set EDEADLK as the error. This avoids an infinite loop
in sbuf_vprintf() if a drain function were to inadvertently return a value of
zero to sbuf_drain().

Reviewed by:	cem, jtl, gallatin
MFC after:	2 weeks
Sponsored by:	Netflix, Inc.
Differential Revision:	https://reviews.freebsd.org/D8535
2017-08-18 02:06:28 +00:00
..
amd64 x86: Add dynamic interrupt rebalancing 2017-08-16 18:48:53 +00:00
arm Add back the drivers for Dallas/Maxim ds13xx and Seiko S35390x now that 2017-08-14 00:12:14 +00:00
arm64 arm64: return error instead of panic in unimplemented ptrace ops 2017-08-17 19:16:23 +00:00
boot Fix BSD label partition end sector calculation. 2017-08-17 19:39:42 +00:00
bsm Commit the 64-bit inode project. 2017-05-23 09:29:05 +00:00
cam Do not loose CCB flags after r320493. 2017-08-09 09:13:15 +00:00
cddl Mark ZFS ABD inline functions static. 2017-08-16 23:40:32 +00:00
compat Add device resource management fields to struct device. 2017-08-16 06:33:48 +00:00
conf Quote ${MAKE} when passing in env in case it contains spaces. 2017-08-16 17:54:24 +00:00
contrib Fix matchcing of NATed ICMP queries (resolving NATed MTU discovery). 2017-08-05 00:28:42 +00:00
crypto aesni: quiet -Wcast-qual 2017-08-16 22:54:35 +00:00
ddb Include opt files in the kernel with "" instead of <>. 2017-07-10 05:08:01 +00:00
dev Undeprecate the CONS_CURSORTYPE ioctl. It was "deprecated" in 2001, 2017-08-16 10:59:37 +00:00
fs Bump the maximum file name length in pseudofs filesystems to 48. 2017-08-03 21:35:53 +00:00
gdb
geom When read requests are sent from a filesystem running above g_journal, 2017-08-13 18:09:22 +00:00
gnu Update DTS files from Linux 4.12 2017-07-09 13:53:32 +00:00
i386 x86: Add dynamic interrupt rebalancing 2017-08-16 18:48:53 +00:00
isa Stop calling atrtc_set() from the xen timer clock_settime() method. That 2017-08-11 19:02:11 +00:00
kern An off-by-one error exists in sbuf_vprintf()'s use of SBUF_HASROOM() when an 2017-08-18 02:06:28 +00:00
kgssapi
libkern x86/crc32_sse42.c: quiet unused function warning 2017-08-11 17:05:31 +00:00
mips Plug memory leak in arge_encap(). 2017-08-15 06:01:36 +00:00
modules Add support for Intel Software Guard Extensions (Intel SGX). 2017-08-16 10:38:06 +00:00
net bpf: Fix incorrect cleanup 2017-08-16 19:40:07 +00:00
net80211 sys/net8021: Add missing braces in setcurchan(). 2017-08-01 03:13:43 +00:00
netgraph Check return value from soaccept(). 2017-06-14 16:13:20 +00:00
netinet Fix comment typo. 2017-08-09 10:46:34 +00:00
netinet6 After inpcb route caching was put back in place there is no need for 2017-07-27 13:03:36 +00:00
netipsec Make user supplied data checks a bit stricter. 2017-08-09 19:58:38 +00:00
netpfil pf_get_sport(): Prevent possible endless loop when searching for an unused nat port 2017-08-08 21:09:26 +00:00
netsmb
nfs Improve FHA locality control for NFS read/write requests. 2017-07-31 15:23:19 +00:00
nfsclient Add an NFSv4.1 mount option for "use one openowner". 2017-04-13 21:54:19 +00:00
nfsserver
nlm Commit the 64-bit inode project. 2017-05-23 09:29:05 +00:00
ofed Change reject message type when destroying cm_id in ibore. 2017-08-03 09:31:10 +00:00
opencrypto Use const with some read-only buffers in opencrypto APIs. 2017-05-09 18:28:42 +00:00
powerpc Add cpufreq support for P1022 and MPC8536 2017-07-21 03:40:05 +00:00
riscv Support for v1.10 (latest) of RISC-V privilege specification. 2017-08-10 14:18:09 +00:00
rpc Listening sockets improvements. 2017-06-08 21:30:34 +00:00
security Correct bitwise test in mac_bsdextended ugidfw_rule_valid() 2017-06-13 01:17:58 +00:00
sparc64 Modify vm_page_grab_pages() to handle VM_ALLOC_NOWAIT. 2017-08-11 16:29:22 +00:00
sys Implement simple record boundary tracking in sbuf(9) to avoid record splitting 2017-08-17 07:20:09 +00:00
teken Oops, my fix for bright colors broke bright black some more (in cases 2017-03-27 10:48:28 +00:00
tests style(9): sort headers 2017-05-09 05:08:47 +00:00
tools make.conf: Add the possibility to use another DTC 2017-06-17 23:34:53 +00:00
ufs Since the switch to GPT disk labels, fsck for UFS/FFS has been 2017-08-09 05:17:21 +00:00
vm Add OBJ_PG_DTOR flag to VM object. 2017-08-16 08:49:11 +00:00
x86 Discover CPU topology on multi-die AMD Zen systems 2017-08-17 16:54:37 +00:00
xdr * limit size of buffers to RPC_MAXDATASIZE 2017-06-01 06:12:25 +00:00
xen
Makefile Remove glimpse make target added in r181432 2017-05-22 15:53:30 +00:00