ANDROID: 16K: __PAGE_ALIGN randomize_page() address
In page-compat mode align randomize_page() address to a multiple of the emulated page size. Bug: 383389337 Bug: 315325080 Bug: 302403436 Change-Id: I0f46366fa9a1e4266087fdfb68cee608f235a35b Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
This commit is contained in:
committed by
Carlos Llamas
parent
81e0928547
commit
9ba9a0891b
@@ -23,6 +23,7 @@
|
|||||||
#include <linux/processor.h>
|
#include <linux/processor.h>
|
||||||
#include <linux/sizes.h>
|
#include <linux/sizes.h>
|
||||||
#include <linux/compat.h>
|
#include <linux/compat.h>
|
||||||
|
#include <linux/page_size_compat.h>
|
||||||
|
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
|
|
||||||
@@ -385,20 +386,20 @@ unsigned long randomize_stack_top(unsigned long stack_top)
|
|||||||
*/
|
*/
|
||||||
unsigned long randomize_page(unsigned long start, unsigned long range)
|
unsigned long randomize_page(unsigned long start, unsigned long range)
|
||||||
{
|
{
|
||||||
if (!PAGE_ALIGNED(start)) {
|
if (!__PAGE_ALIGNED(start)) {
|
||||||
range -= PAGE_ALIGN(start) - start;
|
range -= __PAGE_ALIGN(start) - start;
|
||||||
start = PAGE_ALIGN(start);
|
start = __PAGE_ALIGN(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (start > ULONG_MAX - range)
|
if (start > ULONG_MAX - range)
|
||||||
range = ULONG_MAX - start;
|
range = ULONG_MAX - start;
|
||||||
|
|
||||||
range >>= PAGE_SHIFT;
|
range >>= __PAGE_SHIFT;
|
||||||
|
|
||||||
if (range == 0)
|
if (range == 0)
|
||||||
return start;
|
return start;
|
||||||
|
|
||||||
return start + (get_random_long() % range << PAGE_SHIFT);
|
return start + (get_random_long() % range << __PAGE_SHIFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
|
#ifdef CONFIG_ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT
|
||||||
|
|||||||
Reference in New Issue
Block a user