Eliminate the possibility of 32-bit arithmetic overflow in the calculation
of vm_kmem_size that may occur if the system administrator has specified a vm.vm_kmem_size tunable value that exceeds the hard cap. PR: 162741 Submitted by: Adam McDougall Reviewed by: bde@ MFC after: 3 weeks
This commit is contained in:
parent
f769e5b0fa
commit
c749c003b8
@ -740,11 +740,11 @@ kmeminit(void *dummy)
|
|||||||
/*
|
/*
|
||||||
* Limit kmem virtual size to twice the physical memory.
|
* Limit kmem virtual size to twice the physical memory.
|
||||||
* This allows for kmem map sparseness, but limits the size
|
* This allows for kmem map sparseness, but limits the size
|
||||||
* to something sane. Be careful to not overflow the 32bit
|
* to something sane. Be careful to not overflow the 32bit
|
||||||
* ints while doing the check.
|
* ints while doing the check or the adjustment.
|
||||||
*/
|
*/
|
||||||
if (((vm_kmem_size / 2) / PAGE_SIZE) > cnt.v_page_count)
|
if (vm_kmem_size / 2 / PAGE_SIZE > mem_size)
|
||||||
vm_kmem_size = 2 * cnt.v_page_count * PAGE_SIZE;
|
vm_kmem_size = 2 * mem_size * PAGE_SIZE;
|
||||||
|
|
||||||
#ifdef DEBUG_MEMGUARD
|
#ifdef DEBUG_MEMGUARD
|
||||||
tmp = memguard_fudge(vm_kmem_size, vm_kmem_size_max);
|
tmp = memguard_fudge(vm_kmem_size, vm_kmem_size_max);
|
||||||
|
Loading…
Reference in New Issue
Block a user