[PATCH v1 2/4] mm: fix error handling for map_deny_write_exec

From: Joey Gouly
Date: Wed Mar 08 2023 - 14:07:20 EST


Commit 4a18419f71cd ("mm/mprotect: use mmu_gather") changed 'goto out;'
to 'break' in the loop.
This wasn't noticed while rebasing the MDWE patches, so fix it now.

Fixes: b507808ebce2 ("mm: implement memory-deny-write-execute as a prctl")
Reported-by: Alexey Izbyshev <izbyshev@xxxxxxxxx>
Link: https://lore.kernel.org/linux-arm-kernel/8408d8901e9d7ee6b78db4c6cba04b78@xxxxxxxxx/
Signed-off-by: Joey Gouly <joey.gouly@xxxxxxx>
Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---
mm/mprotect.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mprotect.c b/mm/mprotect.c
index 231929f119d9..13e84d8c0797 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -805,7 +805,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,

if (map_deny_write_exec(vma, newflags)) {
error = -EACCES;
- goto out;
+ break;
}

/* Allow architectures to sanity-check the new flags */
--
2.17.1