Skip to content

Commit 77795f9

Browse files
howlettakpm00
authored andcommitted
mm/mprotect: fix do_mprotect_pkey() limit check
The return of do_mprotect_pkey() can still be incorrectly returned as success if there is a gap that spans to or beyond the end address passed in. Update the check to ensure that the end address has indeed been seen. Link: https://lore.kernel.org/all/CABi2SkXjN+5iFoBhxk71t3cmunTk-s=rB4T7qo0UQRh17s49PQ@mail.gmail.com/ Link: https://lkml.kernel.org/r/[email protected] Fixes: 82f9513 ("mm/mprotect: fix do_mprotect_pkey() return on error") Signed-off-by: Liam R. Howlett <[email protected]> Reported-by: Jeff Xu <[email protected]> Reviewed-by: Lorenzo Stoakes <[email protected]> Acked-by: David Hildenbrand <[email protected]> Acked-by: Vlastimil Babka <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 54abe19 commit 77795f9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

mm/mprotect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
867867
}
868868
tlb_finish_mmu(&tlb);
869869

870-
if (!error && vma_iter_end(&vmi) < end)
870+
if (!error && tmp < end)
871871
error = -ENOMEM;
872872

873873
out:

0 commit comments

Comments
 (0)