linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/mprotect: Fix do_mprotect_pkey() return on error
@ 2023-04-06 19:30 Liam R. Howlett
  2023-04-06 21:53 ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Liam R. Howlett @ 2023-04-06 19:30 UTC (permalink / raw)
  To: linux-mm, linux-kernel, Andrew Morton, linux-next; +Cc: Liam R. Howlett, stable

When the loop over the VMA is terminated early due to an error, the
return code could be overwritten with ENOMEM.  Fix the return code by
only setting the error on early loop termination when the error is not
set.

Fixes: 2286a6914c77 ("mm: change mprotect_fixup to vma iterator")
Cc: <stable@vger.kernel.org>
Signed-off-by: Liam R. Howlett <Liam.Howlett@oracle.com>
---
 mm/mprotect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/mprotect.c b/mm/mprotect.c
index 13e84d8c0797..36351a00c0e8 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -838,7 +838,7 @@ static int do_mprotect_pkey(unsigned long start, size_t len,
 	}
 	tlb_finish_mmu(&tlb);
 
-	if (vma_iter_end(&vmi) < end)
+	if (!error && vma_iter_end(&vmi) < end)
 		error = -ENOMEM;
 
 out:
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/mprotect: Fix do_mprotect_pkey() return on error
  2023-04-06 19:30 [PATCH] mm/mprotect: Fix do_mprotect_pkey() return on error Liam R. Howlett
@ 2023-04-06 21:53 ` Andrew Morton
  2023-04-06 22:04   ` Liam R. Howlett
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2023-04-06 21:53 UTC (permalink / raw)
  To: Liam R. Howlett; +Cc: linux-mm, linux-kernel, linux-next, stable

On Thu,  6 Apr 2023 15:30:50 -0400 "Liam R. Howlett" <Liam.Howlett@oracle.com> wrote:

> When the loop over the VMA is terminated early due to an error, the
> return code could be overwritten with ENOMEM.  Fix the return code by
> only setting the error on early loop termination when the error is not
> set.
> 
> Fixes: 2286a6914c77 ("mm: change mprotect_fixup to vma iterator")
> Cc: <stable@vger.kernel.org>

I do think we should always describe the user-visible effects when
proposing a backport.

a) so the -stable maintainers understand why we're recommending the
   backport and

b) to help some poor soul who is looking at the patch wondering if
   it will fix his customer's bug report.

How's this?

: User-visible effects include: attempts to run mprotect() against a special
: mapping or with a poorly-aligned hugetlb address should return -EINVAL,
: but they presently return -ENOMEM.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] mm/mprotect: Fix do_mprotect_pkey() return on error
  2023-04-06 21:53 ` Andrew Morton
@ 2023-04-06 22:04   ` Liam R. Howlett
  0 siblings, 0 replies; 3+ messages in thread
From: Liam R. Howlett @ 2023-04-06 22:04 UTC (permalink / raw)
  To: Andrew Morton; +Cc: linux-mm, linux-kernel, linux-next, stable

* Andrew Morton <akpm@linux-foundation.org> [230406 17:53]:
> On Thu,  6 Apr 2023 15:30:50 -0400 "Liam R. Howlett" <Liam.Howlett@oracle.com> wrote:
> 
> > When the loop over the VMA is terminated early due to an error, the
> > return code could be overwritten with ENOMEM.  Fix the return code by
> > only setting the error on early loop termination when the error is not
> > set.
> > 
> > Fixes: 2286a6914c77 ("mm: change mprotect_fixup to vma iterator")
> > Cc: <stable@vger.kernel.org>
> 
> I do think we should always describe the user-visible effects when
> proposing a backport.
> 
> a) so the -stable maintainers understand why we're recommending the
>    backport and
> 
> b) to help some poor soul who is looking at the patch wondering if
>    it will fix his customer's bug report.

Thanks, I'll keep this in mind.

> 
> How's this?
> 
> : User-visible effects include: attempts to run mprotect() against a special
> : mapping or with a poorly-aligned hugetlb address should return -EINVAL,
> : but they presently return -ENOMEM.

That sounds reasonable, although this isn't an exhaustive list. It could
be an -EACCESS for multiple reasons, or anything the vm_ops returns.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-04-06 22:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 19:30 [PATCH] mm/mprotect: Fix do_mprotect_pkey() return on error Liam R. Howlett
2023-04-06 21:53 ` Andrew Morton
2023-04-06 22:04   ` Liam R. Howlett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).