]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Handle overflow in calculating max kmem size.
authorkib <kib@FreeBSD.org>
Mon, 14 Jan 2019 07:31:19 +0000 (07:31 +0000)
committerkib <kib@FreeBSD.org>
Mon, 14 Jan 2019 07:31:19 +0000 (07:31 +0000)
commitdb6bffc60a0e14cd787465dea800911be80d40bb
treeb31e3a03b11e0f4f9f7e91fdd2e8bae65aa19f55
parent9bfb656b5bfaa8754fc65ebd7772293347d5c8be
Handle overflow in calculating max kmem size.

vm_kmem_size is u_long, and it might be not capable of holding page
count times PAGE_SIZE, even when scaled down by VM_KMEM_SIZE_SCALE.  As
bde reported, 12G PAE config ends up with zero for kmem size.

Explicitly check for overflow and clamp kmem size at vm_kmem_size_max.
If we end up at zero size because VM_KMEM_SIZE_MAX is not defined,
panic with clear explanation rather then failing in a way which is
hard to relate.

Reported by: bde, pho
Tested by: pho
Reviewed by: markj
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D18767
sys/kern/kern_malloc.c