mm/mprotect: Fix do_mprotect_pkey() limit check
Subsystems (3)
PATCH 1/1 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.
--- mm/mprotect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/mprotect.c +1 -1
@@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, }tlb_finish_mmu (&tlb); -if (!error &&vma_iter_end (&vmi) < end) +if (!error && tmp < end) error = -ENOMEM ; out:
Signature · 1 line
2.39.2
Quoted 28 lines · Liam R. Howlett
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/ open hereFixes 82f951340f25 ("mm/mprotect: fix do_mprotect_pkey() return on error")Reported-by Jeff Xu <[email protected]>Cc <[email protected]>Signed-off-by Liam R. Howlett <[email protected]>--- mm/mprotect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/mprotect.c +1
-2@@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, }tlb_finish_mmu (&tlb); -if (!error &&vma_iter_end (&vmi) < end) +if (!error && tmp < end) error = -ENOMEM ; out: --
Quoted 2 lines
2.39.2
As discussed via irc, was able to confirm locally this fixes the reported issue, so have a quick:-
Quoted 19 lines · Liam R. Howlett
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/ open hereFixes 82f951340f25 ("mm/mprotect: fix do_mprotect_pkey() return on error")Reported-by Jeff Xu <[email protected]>Cc <[email protected]>Signed-off-by Liam R. Howlett <[email protected]>--- mm/mprotect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/mprotect.c +0
-0
mm/mprotect.c static int do_mprotect_pkey(unsigned long start, size_t len, · line 873
Quoted 8 lines
mm/mprotect.c +1
-1@@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, }tlb_finish_mmu (&tlb); -if (!error &&vma_iter_end (&vmi) < end) +if (!error && tmp < end) error = -ENOMEM ; out:
Signature · 3 lines
Cheers, David / dhildenb
Quoted 10 lines · Liam R. Howlett
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/ open hereFixes 82f951340f25 ("mm/mprotect: fix do_mprotect_pkey() return on error")Reported-by Jeff Xu <[email protected]>Cc <[email protected]>Signed-off-by Liam R. Howlett <[email protected]>
Quoted 17 lines
--- mm/mprotect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/mprotect.c +1
-1@@ -867,7 +867,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len, }tlb_finish_mmu (&tlb); -if (!error &&vma_iter_end (&vmi) < end) +if (!error && tmp < end) error = -ENOMEM ; out: