freebsd-skq/sys
Konstantin Belousov 79e9552ebb Check for wrap-around in vm_phys_alloc_seg_contig().
It is possible to provide insane values for size in contigmalloc(9)
request, which usually not reaches the phys allocator due to failing
KVA allocation.  But with the forthcoming 4/4 i386, where 32bit
architecture has almost 4G KVA, contigmalloc(1G) is not unreasonable
outright and KVA might be available sometimes.

Then, the calculation of pa_end could wrap around, depending on the
physical address, and the checks in vm_phys_alloc_seg_contig() would
pass while the iteration in the loop after the 'done' label goes out
of the vm_page_array bounds.

Fix it by detecting the wrap.

Reported and tested by:	pho
Reviewed by:	alc, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D14767
2018-03-20 16:17:55 +00:00
..
amd64 Rename linuxulator functions with linux_ prefix 2018-03-19 21:26:32 +00:00
arm [ofw] fix errneous checks for OF_finddevice(9) return value 2018-03-20 00:03:49 +00:00
arm64 EFIRT: SetVirtualAddressMap with 1:1 mapping after exiting boot services 2018-03-13 17:10:52 +00:00
bsm sys: further adoption of SPDX licensing ID tags. 2017-11-20 19:43:44 +00:00
cam Kill assert I shouldn't have committed 2018-03-20 13:14:10 +00:00
cddl Fix an access of an uninitialized variable in dtrace_probe(). 2018-03-18 17:01:50 +00:00
compat linux_errno.c: add newer errno values 2018-03-16 14:51:47 +00:00
conf Add EFI to kernel options. 2018-03-17 17:18:29 +00:00
contrib lib(private)zstd: Fix riscv build 2018-03-18 03:42:57 +00:00
crypto Garbage collect unused chacha20 code 2018-03-16 07:11:53 +00:00
ddb db_script_exec: use a saved script name when reporting commands executed 2018-03-04 13:27:21 +00:00
dev Check if the gettime runtime service is valid. 2018-03-20 13:35:20 +00:00
dts sys/dts: Remove arm64 from subdir as it no longer exists. 2018-03-19 15:35:26 +00:00
fs Revert r313780 (UFS_ prefix) 2018-03-17 12:59:55 +00:00
gdb amd64: Protect the kernel text, data, and BSS by setting the RW/NX bits 2018-03-06 14:28:37 +00:00
geom Remove unneeded variable which was introduced in r328472. 2018-03-18 15:09:55 +00:00
gnu bwn(4): txpid2g/txpid5g[lh] are not defined after sromrev 7; the default 2018-02-13 17:43:54 +00:00
i386 Rationalize license text on Linuxolator files 2018-03-20 02:50:11 +00:00
isa Revert r330780, it was improperly tested and results in taking a spin 2018-03-11 20:13:15 +00:00
kern Drop KTR_CONTENTION. 2018-03-20 15:51:05 +00:00
kgssapi kgssapi: Remove trivial deadcode 2018-02-14 00:12:03 +00:00
libkern iconv uses strlen directly on user supplied memory 2018-02-26 18:23:36 +00:00
mips MIPS: Implement fue*word* and casueword* in assembly. 2018-03-12 22:10:06 +00:00
modules Use kern.opts.mk instead of bsd.own.mk (which includes src.opts.mk) 2018-03-17 17:18:46 +00:00
net Fix outgoing TCP/UDP packet drop on arp/ndp entry expiration. 2018-03-17 17:05:48 +00:00
net80211 net80211: wrap protection frame allocation into ieee80211_alloc_prot() 2018-03-09 11:33:56 +00:00
netgraph Correct pseudo misspelling in sys/ comments 2018-02-23 18:15:50 +00:00
netinet Add support for the experimental Internet-Draft "TCP Alternative Backoff with 2018-03-19 16:37:47 +00:00
netinet6 Fix outgoing TCP/UDP packet drop on arp/ndp entry expiration. 2018-03-17 17:05:48 +00:00
netipsec Rework key_sendup_mbuf() a bit: 2018-03-11 19:14:01 +00:00
netpfil pf: Fix memory leak in DIOCRADDTABLES 2018-03-19 21:13:25 +00:00
netsmb Unsign some values related to allocation. 2018-01-22 02:08:10 +00:00
nfs Modernize nfssvc(2) registartion. 2018-02-08 20:09:42 +00:00
nfsclient style: Remove remaining deprecated MALLOC/FREE macros 2018-01-25 22:25:13 +00:00
nfsserver sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
nlm Use syscall_helper_register() to register syscalls and initialize though 2018-02-10 01:09:22 +00:00
ofed Remove redundant integer cast in ibcore. The "ref_count" field already 2018-03-19 13:51:33 +00:00
opencrypto Move per-operation data out of the csession structure. 2018-01-26 23:21:50 +00:00
powerpc Fix powerpc Book-E build post-331018/331048. 2018-03-20 01:07:22 +00:00
riscv Unify bulk free operations in several pmaps. 2018-03-04 20:53:20 +00:00
rpc Do pass removing some write-only variables from the kernel. 2017-12-25 04:48:39 +00:00
security audit(4): fix a typo in a comment 2018-03-17 17:56:08 +00:00
sparc64 amd64: Protect the kernel text, data, and BSS by setting the RW/NX bits 2018-03-06 14:28:37 +00:00
sys Drop KTR_CONTENTION. 2018-03-20 15:51:05 +00:00
teken sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
tests
tools Avoid using \$. It's an unknown escape sequence. Some awks warn about 2018-01-28 05:13:08 +00:00
ufs Revert r313780 (UFS_ prefix) 2018-03-17 12:59:55 +00:00
vm Check for wrap-around in vm_phys_alloc_seg_contig(). 2018-03-20 16:17:55 +00:00
x86 Fix a typo. 2018-03-19 17:14:56 +00:00
xdr sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
xen sys: general adoption of SPDX licensing ID tags. 2017-11-27 15:23:17 +00:00
Makefile Move sys/boot to stand. Fix all references to new location 2017-11-14 23:02:19 +00:00