freebsd-dev/sys
Xin LI 9053fe148b Fix a buffer overrun which may lead to data corruption, introduced in
r286951 by reinstating changes in r274628.

In l2arc_compress_buf(), we allocate a buffer to stash away the compressed
data in 'cdata', allocated of l2hdr->b_asize bytes.

We then ask zio_compress_data() to compress the buffer, b_l1hdr.b_tmp_cdata,
which is of l2hdr->b_asize bytes, and have the compressed size (or original
size, if compress didn't gain enough) stored in csize.

To pad the buffer to fit the optimal write size, we round up the compressed
size to L2 device's vdev_ashift.

Illumos code rounds up the size by at most SPA_MINBLOCKSIZE.  Because we
know csize <= b_asize, and b_asize is integer multiple of SPA_MINBLOCKSIZE,
we are guaranteed that the rounded up csize would be <= b_asize. However,
this is not necessarily true when we round up to 1 << vdev_ashift, because
it could be larger than SPA_MINBLOCKSIZE.

So, in the worst case scenario, we are overwriting at most

	(1 << vdev_ashift - SPA_MINBLOCKSIZE)

bytes of memory next to the compressed data buffer.

Andriy's original change in r274628 reorganized the code a little bit,
by moving the padding to after we determined that the compression was
beneficial.  At which point, we would check rounded size against the
allocated buffer size, and the buffer overrun would not be possible.
2015-08-29 09:22:32 +00:00
..
amd64 Remove an unneeded instruction. 2015-08-28 00:17:21 +00:00
arm Leave hypervisor mode upon startup on ARMv7 2015-08-25 14:49:11 +00:00
arm64 Add the SOC_HISI_HI6220 option. This will be used to enable drivers for 2015-08-26 18:09:17 +00:00
boot Add back missing -m32 for amd64 and powerpc64 that was lost 2015-08-28 14:50:36 +00:00
bsm
cam Fix type bug introduced at r286811. 2015-08-27 21:16:24 +00:00
cddl Fix a buffer overrun which may lead to data corruption, introduced in 2015-08-29 09:22:32 +00:00
compat Decompose linkat()/renameat() rights to source and target. 2015-08-27 15:16:41 +00:00
conf Comment out cleaning files, since it cleans too much. 2015-08-28 16:29:38 +00:00
contrib Merge ACPICA 20150818. 2015-08-26 17:13:47 +00:00
crypto const'ify an arg that we don't update... 2015-07-29 23:37:15 +00:00
ddb Make kstack_pages a tunable on arm, x86, and powepc. On i386, the 2015-08-10 17:18:21 +00:00
dev Mark ValleyView/Bay Trail as not supported 2015-08-29 00:05:39 +00:00
fs Fix an NFS server bug that manifested in "ls -al" displaying a plus 2015-08-28 14:26:11 +00:00
gdb CALLOUT_MPSAFE has lost its meaning since r141428, i.e., for more than ten 2015-05-22 17:05:21 +00:00
geom Create a RouterBoard platform and use it to create a flash map 2015-08-22 05:50:18 +00:00
gnu Using consistent coding style to deal with error inside the loop. 2015-08-18 13:16:23 +00:00
i386 preload_search_info: make sure mod is set 2015-08-21 15:57:57 +00:00
isa Remove vestiges of knowing the ISA bus, which we gave up on around 20 2014-03-19 21:03:04 +00:00
kern Remove now obsolete comment. 2015-08-28 20:06:58 +00:00
kgssapi
libkern Remove checks for __ARM_EABI__, we only build for EABI now. 2015-07-09 21:02:40 +00:00
mips Enable hardfloat for assembly generation. 2015-08-24 19:09:56 +00:00
modules New 1-Wire bus implementation. 1-Wire controller is abstracted, though 2015-08-27 23:33:38 +00:00
net Remove now unused (and #if 0'ed out) headers. 2015-08-29 04:33:31 +00:00
net80211 Replay r286410. Change KPI of how device drivers that provide wireless 2015-08-27 08:56:39 +00:00
netgraph * Address review (and add a bit myself). 2015-07-12 18:14:38 +00:00
netinet Fix the exporting of SCTP association states to userland. Without this, 2015-08-29 09:14:32 +00:00
netinet6 Implement RSS hashing/re-hashing for IPv6 ingress packets. 2015-08-29 07:14:29 +00:00
netipsec Make IPsec work with AES-GCM and AES-ICM (aka CTR) in OCF... IPsec 2015-08-04 17:47:11 +00:00
netnatm
netpfil pf: Remove support for 'scrub fragment crop|drop-ovl' 2015-08-27 21:27:47 +00:00
netsmb Remove redundant unlock. 2014-04-17 12:22:08 +00:00
nfs
nfsclient Remove some oldnfs remnants. 2015-04-18 16:08:06 +00:00
nfsserver
nlm
ofed Reinstate unify_tcp_port_space and associated code that was lost during 2015-08-12 22:09:58 +00:00
opencrypto Make IPsec work with AES-GCM and AES-ICM (aka CTR) in OCF... IPsec 2015-08-04 17:47:11 +00:00
pc98 Add missing ofw_machdep.h. Make x86 ofw_machdep.h work pc98 too. 2015-08-28 15:41:09 +00:00
powerpc The TLB1 TSIZE is a multiple of 4, not 2, so shift 2 bits, not 1. 2015-08-29 06:52:14 +00:00
rpc Set curvnet context inside the RPC code in more places. 2015-08-18 18:12:46 +00:00
security fd: make 'rights' a manadatory argument to fget* functions 2015-07-05 19:05:16 +00:00
sparc64 Rationalize BSD license on sys/*/include/in_cksum.h 2015-08-05 19:05:12 +00:00
sys Add underscores to attributes when checking for __has_attribute. 2015-08-28 15:36:05 +00:00
teken Sync HPA and VPA implementations with CUP. 2015-08-24 07:49:27 +00:00
tools
ufs - Make 'struct buf *buf' private to vfs_bio.c. Having a global variable 2015-07-29 02:26:57 +00:00
vm Remove weighted page handling from vm_page_advise(). 2015-08-28 00:44:17 +00:00
x86 Add missing ofw_machdep.h. Make x86 ofw_machdep.h work pc98 too. 2015-08-28 15:41:09 +00:00
xdr
xen xen: allow disabling PV disks and nics 2015-08-21 15:53:08 +00:00
Makefile Kill EoL whitespace. 2015-05-29 14:03:07 +00:00