Add a check that the requested protection bits do not exceed the maximum protection bits.
Signed-off-by: Amit Daniel Kachhap amitdaniel.kachhap@arm.com --- mm/mmap.c | 6 ++++++ 1 file changed, 6 insertions(+)
diff --git a/mm/mmap.c b/mm/mmap.c index c5ffa129ff72..464fa2d7b748 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -1457,11 +1457,17 @@ user_uintptr_t ksys_mmap_pgoff(user_uintptr_t user_ptr, unsigned long len, * Introduce checks for PCuABI: * - MAP_GROWSDOWN flag has no fixed bounds and hence is not supported * in the PCuABI reservation model. + * - PCuABI reservation model introduces the concept of maximum + * protection the mappings can have. Add a check to make sure the + * requested protection does not exceed the maximum protection. */ if (flags & MAP_GROWSDOWN) { retval = -EOPNOTSUPP; goto out_fput; } + if ((PROT_MAX_EXTRACT(prot) != 0) && + ((PROT_EXTRACT(prot) & PROT_MAX_EXTRACT(prot)) != PROT_EXTRACT(prot))) + goto out_fput;
if (user_ptr_is_valid((const void __user *)user_ptr)) { if (!(flags & MAP_FIXED) || !check_user_ptr_owning(user_ptr, addr, len))