Avoid the possibility of integer overflow in the calculation of

VM_KMEM_SIZE_MAX.  Specifically, if the user/kernel address space split
was changed such that the kernel address space was greater than or equal
to 2 GB, then overflow would occur.

PR:		161721
MFC after:	3 weeks
This commit is contained in:
Alan Cox 2011-12-10 18:42:00 +00:00
parent 4df6844ba3
commit c5ecbfb410

@ -186,11 +186,12 @@
#endif
/*
* Ceiling on amount of kmem_map kva space.
* Ceiling on the amount of kmem_map KVA space: 40% of the entire KVA space
* rounded to the nearest multiple of the superpage size.
*/
#ifndef VM_KMEM_SIZE_MAX
#define VM_KMEM_SIZE_MAX ((VM_MAX_KERNEL_ADDRESS - \
VM_MIN_KERNEL_ADDRESS) * 2 / 5)
#define VM_KMEM_SIZE_MAX (((((VM_MAX_KERNEL_ADDRESS - \
VM_MIN_KERNEL_ADDRESS) >> (PDRSHIFT - 2)) + 5) / 10) << PDRSHIFT)
#endif
/* initial pagein size of beginning of executable file */