All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows
@ 2026-11-20 10:59 Lorenzo Stoakes (ARM)
  2026-11-20 11:06 ` David Hildenbrand (Arm)
                   ` (6 more replies)
  0 siblings, 7 replies; 9+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-20 10:59 UTC (permalink / raw)
  To: Liam R. Howlett, Suren Baghdasaryan, Vlastimil Babka,
	Shakeel Butt, Pedro Falcato, David Hildenbrand, Jann Horn,
	Andrew Morton
  Cc: linux-mm, Wupeng Ma, Ding Feng, ljs

Currently the msync() system call will simply return 0 if you provide a
length parameter which, when page-aligned (rounding up) overflows (i.e.
SIZE_MAX - n, where n is in the range [0, PAGE_SIZE - 1).)

This requires broken input, and nobody has complained about this, but for
correctness this should really return -ENOMEM, so do so.

Also, since error is assigned within the following loop, remove the
unnecessary assignments prior to it.

Link: https://lore.kernel.org/linux-mm/20230321074035.1526157-5-mawupeng1@huawei.com/
Reported-by: Ding Feng <dingf3ng@gmail.com>
Closes: https://lore.kernel.org/linux-mm/20261120051413.46167-1-dingf3ng@gmail.com/
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
---
 mm/msync.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/mm/msync.c b/mm/msync.c
index 90b491a27a14..ced41d3c2903 100644
--- a/mm/msync.c
+++ b/mm/msync.c
@@ -46,14 +46,12 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
 		goto out;
 	if ((flags & MS_ASYNC) && (flags & MS_SYNC))
 		goto out;
-	error = -ENOMEM;
+	if (!len)
+		return 0;
 	len = (len + ~PAGE_MASK) & PAGE_MASK;
 	end = start + len;
-	if (end < start)
-		goto out;
-	error = 0;
-	if (end == start)
-		goto out;
+	if (end <= start)
+		return -ENOMEM;
 	/*
 	 * If the interval [start,end) covers some unmapped address ranges,
 	 * just ignore them, but return -ENOMEM at the end. Besides, if the

---
base-commit: d12eccbcb79a4fa35c3aa588eb79056af62eb859
change-id: 20261120-msync-enomem-fix-95f830e305dd

Cheers,
-- 
Lorenzo Stoakes (ARM) <ljs@kernel.org>



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

* Re: [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows
  2026-11-20 10:59 [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Lorenzo Stoakes (ARM)
@ 2026-11-20 11:06 ` David Hildenbrand (Arm)
  2026-11-20 11:09 ` Vlastimil Babka (SUSE)
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: David Hildenbrand (Arm) @ 2026-11-20 11:06 UTC (permalink / raw)
  To: Lorenzo Stoakes (ARM), Liam R. Howlett, Suren Baghdasaryan,
	Vlastimil Babka, Shakeel Butt, Pedro Falcato, Jann Horn,
	Andrew Morton
  Cc: linux-mm, Wupeng Ma, Ding Feng

On 11/20/26 11:59, Lorenzo Stoakes (ARM) wrote:
> Currently the msync() system call will simply return 0 if you provide a
> length parameter which, when page-aligned (rounding up) overflows (i.e.
> SIZE_MAX - n, where n is in the range [0, PAGE_SIZE - 1).)
> 
> This requires broken input, and nobody has complained about this, but for
> correctness this should really return -ENOMEM, so do so.
> 
> Also, since error is assigned within the following loop, remove the
> unnecessary assignments prior to it.
> 
> Link: https://lore.kernel.org/linux-mm/20230321074035.1526157-5-mawupeng1@huawei.com/
> Reported-by: Ding Feng <dingf3ng@gmail.com>
> Closes: https://lore.kernel.org/linux-mm/20261120051413.46167-1-dingf3ng@gmail.com/
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David


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

* Re: [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows
  2026-11-20 10:59 [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Lorenzo Stoakes (ARM)
  2026-11-20 11:06 ` David Hildenbrand (Arm)
@ 2026-11-20 11:09 ` Vlastimil Babka (SUSE)
  2026-11-20 11:15   ` Lorenzo Stoakes (ARM)
  2026-11-21  0:53 ` mawupeng
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 9+ messages in thread
From: Vlastimil Babka (SUSE) @ 2026-11-20 11:09 UTC (permalink / raw)
  To: Lorenzo Stoakes (ARM), Liam R. Howlett, Suren Baghdasaryan,
	Shakeel Butt, Pedro Falcato, David Hildenbrand, Jann Horn,
	Andrew Morton
  Cc: linux-mm, Wupeng Ma, Ding Feng, Linux API

+cc linux-api

On 11/20/26 11:59, Lorenzo Stoakes (ARM) wrote:
> Currently the msync() system call will simply return 0 if you provide a
> length parameter which, when page-aligned (rounding up) overflows (i.e.
> SIZE_MAX - n, where n is in the range [0, PAGE_SIZE - 1).)

Weird, as if it was intended, but seems to be pre-git, so who knows why.

> This requires broken input, and nobody has complained about this, but for
> correctness this should really return -ENOMEM, so do so.

Right.

> Also, since error is assigned within the following loop, remove the
> unnecessary assignments prior to it.
> 
> Link: https://lore.kernel.org/linux-mm/20230321074035.1526157-5-mawupeng1@huawei.com/
> Reported-by: Ding Feng <dingf3ng@gmail.com>
> Closes: https://lore.kernel.org/linux-mm/20261120051413.46167-1-dingf3ng@gmail.com/
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>

> ---
>  mm/msync.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)
> 
> diff --git a/mm/msync.c b/mm/msync.c
> index 90b491a27a14..ced41d3c2903 100644
> --- a/mm/msync.c
> +++ b/mm/msync.c
> @@ -46,14 +46,12 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
>  		goto out;
>  	if ((flags & MS_ASYNC) && (flags & MS_SYNC))
>  		goto out;
> -	error = -ENOMEM;
> +	if (!len)
> +		return 0;
>  	len = (len + ~PAGE_MASK) & PAGE_MASK;

ALIGN(PAGE_SIZE) or something?
But fair if out of scope.

>  	end = start + len;
> -	if (end < start)
> -		goto out;
> -	error = 0;
> -	if (end == start)
> -		goto out;
> +	if (end <= start)
> +		return -ENOMEM;
>  	/*
>  	 * If the interval [start,end) covers some unmapped address ranges,
>  	 * just ignore them, but return -ENOMEM at the end. Besides, if the
> 
> ---
> base-commit: d12eccbcb79a4fa35c3aa588eb79056af62eb859
> change-id: 20261120-msync-enomem-fix-95f830e305dd
> 
> Cheers,


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

* Re: [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows
  2026-11-20 11:09 ` Vlastimil Babka (SUSE)
@ 2026-11-20 11:15   ` Lorenzo Stoakes (ARM)
  0 siblings, 0 replies; 9+ messages in thread
From: Lorenzo Stoakes (ARM) @ 2026-11-20 11:15 UTC (permalink / raw)
  To: Vlastimil Babka (SUSE)
  Cc: Liam R. Howlett, Suren Baghdasaryan, Shakeel Butt, Pedro Falcato,
	David Hildenbrand, Jann Horn, Andrew Morton, linux-mm, Wupeng Ma,
	Ding Feng, Linux API

On Fri, Nov 20, 2026 at 12:09:07PM +0100, Vlastimil Babka (SUSE) wrote:
> +cc linux-api
>
> On 11/20/26 11:59, Lorenzo Stoakes (ARM) wrote:
> > Currently the msync() system call will simply return 0 if you provide a
> > length parameter which, when page-aligned (rounding up) overflows (i.e.
> > SIZE_MAX - n, where n is in the range [0, PAGE_SIZE - 1).)
>
> Weird, as if it was intended, but seems to be pre-git, so who knows why.

Yeah, likely unintended but doesn't really matter.

I'd like us to completely centralise these kinds of checks for mm syscalls
but on the laterbase...

>
> > This requires broken input, and nobody has complained about this, but for
> > correctness this should really return -ENOMEM, so do so.
>
> Right.
>
> > Also, since error is assigned within the following loop, remove the
> > unnecessary assignments prior to it.
> >
> > Link: https://lore.kernel.org/linux-mm/20230321074035.1526157-5-mawupeng1@huawei.com/
> > Reported-by: Ding Feng <dingf3ng@gmail.com>
> > Closes: https://lore.kernel.org/linux-mm/20261120051413.46167-1-dingf3ng@gmail.com/
> > Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
>
> Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>

Thanks!

>
> > ---
> >  mm/msync.c | 10 ++++------
> >  1 file changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/mm/msync.c b/mm/msync.c
> > index 90b491a27a14..ced41d3c2903 100644
> > --- a/mm/msync.c
> > +++ b/mm/msync.c
> > @@ -46,14 +46,12 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
> >  		goto out;
> >  	if ((flags & MS_ASYNC) && (flags & MS_SYNC))
> >  		goto out;
> > -	error = -ENOMEM;
> > +	if (!len)
> > +		return 0;
> >  	len = (len + ~PAGE_MASK) & PAGE_MASK;
>
> ALIGN(PAGE_SIZE) or something?
> But fair if out of scope.

Yeah can do on respin if needed, but right now I have more deletions than
insertions which is rare for me so :P (maybe not the best reasoning, but
still ;)

>
> >  	end = start + len;
> > -	if (end < start)
> > -		goto out;
> > -	error = 0;
> > -	if (end == start)
> > -		goto out;
> > +	if (end <= start)
> > +		return -ENOMEM;
> >  	/*
> >  	 * If the interval [start,end) covers some unmapped address ranges,
> >  	 * just ignore them, but return -ENOMEM at the end. Besides, if the
> >
> > ---
> > base-commit: d12eccbcb79a4fa35c3aa588eb79056af62eb859
> > change-id: 20261120-msync-enomem-fix-95f830e305dd
> >
> > Cheers,
>

--
Cheers, Lorenzo


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

* Re: [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows
  2026-11-20 10:59 [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Lorenzo Stoakes (ARM)
  2026-11-20 11:06 ` David Hildenbrand (Arm)
  2026-11-20 11:09 ` Vlastimil Babka (SUSE)
@ 2026-11-21  0:53 ` mawupeng
  2026-11-21  1:07 ` SJ Park
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: mawupeng @ 2026-11-21  0:53 UTC (permalink / raw)
  To: ljs, liam, surenb, vbabka, shakeel.butt, pfalcato, david, jannh,
	akpm
  Cc: mawupeng1, linux-mm, dingf3ng



On 周五 2026-11-20 18:59, Lorenzo Stoakes (ARM) wrote:
> Currently the msync() system call will simply return 0 if you provide a
> length parameter which, when page-aligned (rounding up) overflows (i.e.
> SIZE_MAX - n, where n is in the range [0, PAGE_SIZE - 1).)
> 
> This requires broken input, and nobody has complained about this, but for
> correctness this should really return -ENOMEM, so do so.
> 
> Also, since error is assigned within the following loop, remove the
> unnecessary assignments prior to it.
> 
> Link: https://lore.kernel.org/linux-mm/20230321074035.1526157-5-mawupeng1@huawei.com/
> Reported-by: Ding Feng <dingf3ng@gmail.com>
> Closes: https://lore.kernel.org/linux-mm/20261120051413.46167-1-dingf3ng@gmail.com/
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
> ---
>  mm/msync.c | 10 ++++------
>  1 file changed, 4 insertions(+), 6 deletions(-)

Thanks for your work;
Reviewed-by: Wupeng Ma <mawupeng1@huawei.com>

> 
> diff --git a/mm/msync.c b/mm/msync.c
> index 90b491a27a14..ced41d3c2903 100644
> --- a/mm/msync.c
> +++ b/mm/msync.c
> @@ -46,14 +46,12 @@ SYSCALL_DEFINE3(msync, unsigned long, start, size_t, len, int, flags)
>  		goto out;
>  	if ((flags & MS_ASYNC) && (flags & MS_SYNC))
>  		goto out;
> -	error = -ENOMEM;
> +	if (!len)
> +		return 0;
>  	len = (len + ~PAGE_MASK) & PAGE_MASK;
>  	end = start + len;
> -	if (end < start)
> -		goto out;
> -	error = 0;
> -	if (end == start)
> -		goto out;
> +	if (end <= start)
> +		return -ENOMEM;
>  	/*
>  	 * If the interval [start,end) covers some unmapped address ranges,
>  	 * just ignore them, but return -ENOMEM at the end. Besides, if the
> 
> ---
> base-commit: d12eccbcb79a4fa35c3aa588eb79056af62eb859
> change-id: 20261120-msync-enomem-fix-95f830e305dd
> 
> Cheers,



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

* Re: [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows
  2026-11-20 10:59 [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Lorenzo Stoakes (ARM)
                   ` (2 preceding siblings ...)
  2026-11-21  0:53 ` mawupeng
@ 2026-11-21  1:07 ` SJ Park
  2026-11-24  0:56 ` + mm-msync-return-enomem-if-page-aligned-length-overflows.patch added to mm-hotfixes-unstable branch Andrew Morton
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 9+ messages in thread
From: SJ Park @ 2026-11-21  1:07 UTC (permalink / raw)
  To: Lorenzo Stoakes (ARM)
  Cc: SJ Park, Liam R. Howlett, Suren Baghdasaryan, Vlastimil Babka,
	Shakeel Butt, Pedro Falcato, David Hildenbrand, Jann Horn,
	Andrew Morton, linux-mm, Wupeng Ma, Ding Feng

On Fri, 20 Nov 2026 10:59:56 +0000 "Lorenzo Stoakes (ARM)" <ljs@kernel.org> wrote:

> Currently the msync() system call will simply return 0 if you provide a
> length parameter which, when page-aligned (rounding up) overflows (i.e.
> SIZE_MAX - n, where n is in the range [0, PAGE_SIZE - 1).)
> 
> This requires broken input, and nobody has complained about this, but for
> correctness this should really return -ENOMEM, so do so.
> 
> Also, since error is assigned within the following loop, remove the
> unnecessary assignments prior to it.

Looks all correct and make sense to me.

> 
> Link: https://lore.kernel.org/linux-mm/20230321074035.1526157-5-mawupeng1@huawei.com/
> Reported-by: Ding Feng <dingf3ng@gmail.com>
> Closes: https://lore.kernel.org/linux-mm/20261120051413.46167-1-dingf3ng@gmail.com/
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

Reviewed-by: SJ Park <sj@kernel.org>


Thanks,
SJ

[...]


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

* + mm-msync-return-enomem-if-page-aligned-length-overflows.patch added to mm-hotfixes-unstable branch
  2026-11-20 10:59 [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Lorenzo Stoakes (ARM)
                   ` (3 preceding siblings ...)
  2026-11-21  1:07 ` SJ Park
@ 2026-11-24  0:56 ` Andrew Morton
  2026-11-24 13:13 ` [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Pedro Falcato
  2026-12-02  3:47 ` [merged mm-hotfixes-stable] mm-msync-return-enomem-if-page-aligned-length-overflows.patch removed from -mm tree Andrew Morton
  6 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-11-24  0:56 UTC (permalink / raw)
  To: mm-commits, vbabka, surenb, sj, shakeel.butt, pfalcato, mawupeng1,
	liam, jannh, dingf3ng, david, ljs, akpm


The patch titled
     Subject: mm/msync: return -ENOMEM if page-aligned length overflows
has been added to the -mm mm-hotfixes-unstable branch.  Its filename is
     mm-msync-return-enomem-if-page-aligned-length-overflows.patch

This patch will shortly appear at
     https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-msync-return-enomem-if-page-aligned-length-overflows.patch

This patch will later appear in the mm-hotfixes-unstable branch at
    git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days

------------------------------------------------------
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Subject: mm/msync: return -ENOMEM if page-aligned length overflows
Date: Fri, 20 Nov 2026 10:59:56 +0000

Currently the msync() system call will simply return 0 if you provide a
length parameter which, when page-aligned (rounding up) overflows (i.e.
SIZE_MAX - n, where n is in the range [0, PAGE_SIZE - 1).)

This requires broken input, and nobody has complained about this, but for
correctness this should really return -ENOMEM, so do so.

Also, since error is assigned within the following loop, remove the
unnecessary assignments prior to it.

Link: https://patch.msgid.link/20261120-msync-enomem-fix-v1-1-80282c8c5beb@kernel.org
Link: https://lore.kernel.org/linux-mm/20230321074035.1526157-5-mawupeng1@huawei.com/
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Ding Feng <dingf3ng@gmail.com>
Closes: https://lore.kernel.org/linux-mm/20261120051413.46167-1-dingf3ng@gmail.com/
Reviewed-by: SJ Park <sj@kernel.org>
Reviewed-by: Wupeng Ma <mawupeng1@huawei.com>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Pedro Falcato <pfalcato@suse.de>
Cc: Jann Horn <jannh@google.com>

 mm/msync.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

--- a/mm/msync.c~mm-msync-return-enomem-if-page-aligned-length-overflows
+++ a/mm/msync.c
@@ -46,14 +46,12 @@ SYSCALL_DEFINE3(msync, unsigned long, st
 		goto out;
 	if ((flags & MS_ASYNC) && (flags & MS_SYNC))
 		goto out;
-	error = -ENOMEM;
+	if (!len)
+		return 0;
 	len = (len + ~PAGE_MASK) & PAGE_MASK;
 	end = start + len;
-	if (end < start)
-		goto out;
-	error = 0;
-	if (end == start)
-		goto out;
+	if (end <= start)
+		return -ENOMEM;
 	/*
 	 * If the interval [start,end) covers some unmapped address ranges,
 	 * just ignore them, but return -ENOMEM at the end. Besides, if the
_

Patches currently in -mm which might be from ljs@kernel.org are

mm-msync-return-enomem-if-page-aligned-length-overflows.patch
mm-vma-predicate-vma_assert_stabilised-on-config_debug_vm.patch
mm-only-assert-mmap-locks-if-config_debug_vm-or-lockdep-is-set.patch
mm-only-assert-vma-locks-if-config_debug_vm-is-set.patch
mm-convert-warn_on_onces-to-vm_warn_on_once-in-vma-lock-code.patch
mm-madvise-zap-markers-from-guard-regions.patch


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

* Re: [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows
  2026-11-20 10:59 [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Lorenzo Stoakes (ARM)
                   ` (4 preceding siblings ...)
  2026-11-24  0:56 ` + mm-msync-return-enomem-if-page-aligned-length-overflows.patch added to mm-hotfixes-unstable branch Andrew Morton
@ 2026-11-24 13:13 ` Pedro Falcato
  2026-12-02  3:47 ` [merged mm-hotfixes-stable] mm-msync-return-enomem-if-page-aligned-length-overflows.patch removed from -mm tree Andrew Morton
  6 siblings, 0 replies; 9+ messages in thread
From: Pedro Falcato @ 2026-11-24 13:13 UTC (permalink / raw)
  To: Lorenzo Stoakes (ARM)
  Cc: Liam R. Howlett, Suren Baghdasaryan, Vlastimil Babka,
	Shakeel Butt, David Hildenbrand, Jann Horn, Andrew Morton,
	linux-mm, Wupeng Ma, Ding Feng

On Fri, Nov 20, 2026 at 10:59:56AM +0000, Lorenzo Stoakes (ARM) wrote:
> Currently the msync() system call will simply return 0 if you provide a
> length parameter which, when page-aligned (rounding up) overflows (i.e.
> SIZE_MAX - n, where n is in the range [0, PAGE_SIZE - 1).)
> 
> This requires broken input, and nobody has complained about this, but for
> correctness this should really return -ENOMEM, so do so.
> 
> Also, since error is assigned within the following loop, remove the
> unnecessary assignments prior to it.
> 
> Link: https://lore.kernel.org/linux-mm/20230321074035.1526157-5-mawupeng1@huawei.com/
> Reported-by: Ding Feng <dingf3ng@gmail.com>
> Closes: https://lore.kernel.org/linux-mm/20261120051413.46167-1-dingf3ng@gmail.com/
> Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>

Reviewed-by: Pedro Falcato <pfalcato@suse.de>

-- 
Pedro


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

* [merged mm-hotfixes-stable] mm-msync-return-enomem-if-page-aligned-length-overflows.patch removed from -mm tree
  2026-11-20 10:59 [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Lorenzo Stoakes (ARM)
                   ` (5 preceding siblings ...)
  2026-11-24 13:13 ` [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Pedro Falcato
@ 2026-12-02  3:47 ` Andrew Morton
  6 siblings, 0 replies; 9+ messages in thread
From: Andrew Morton @ 2026-12-02  3:47 UTC (permalink / raw)
  To: mm-commits, vbabka, surenb, sj, shakeel.butt, pfalcato, mawupeng1,
	liam, jannh, dingf3ng, david, ljs, akpm


The quilt patch titled
     Subject: mm/msync: return -ENOMEM if page-aligned length overflows
has been removed from the -mm tree.  Its filename was
     mm-msync-return-enomem-if-page-aligned-length-overflows.patch

This patch was dropped because it was merged into the mm-hotfixes-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Subject: mm/msync: return -ENOMEM if page-aligned length overflows
Date: Fri, 20 Nov 2026 10:59:56 +0000

Currently the msync() system call will simply return 0 if you provide a
length parameter which, when page-aligned (rounding up) overflows (i.e.
SIZE_MAX - n, where n is in the range [0, PAGE_SIZE - 1).)

This requires broken input, and nobody has complained about this, but for
correctness this should really return -ENOMEM, so do so.

Also, since error is assigned within the following loop, remove the
unnecessary assignments prior to it.

Link: https://patch.msgid.link/20261120-msync-enomem-fix-v1-1-80282c8c5beb@kernel.org
Link: https://lore.kernel.org/linux-mm/20230321074035.1526157-5-mawupeng1@huawei.com/
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Reported-by: Ding Feng <dingf3ng@gmail.com>
Closes: https://lore.kernel.org/linux-mm/20261120051413.46167-1-dingf3ng@gmail.com/
Reviewed-by: SJ Park <sj@kernel.org>
Reviewed-by: Wupeng Ma <mawupeng1@huawei.com>
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Shakeel Butt <shakeel.butt@linux.dev>
Cc: Jann Horn <jannh@google.com>

 mm/msync.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

--- a/mm/msync.c~mm-msync-return-enomem-if-page-aligned-length-overflows
+++ a/mm/msync.c
@@ -46,14 +46,12 @@ SYSCALL_DEFINE3(msync, unsigned long, st
 		goto out;
 	if ((flags & MS_ASYNC) && (flags & MS_SYNC))
 		goto out;
-	error = -ENOMEM;
+	if (!len)
+		return 0;
 	len = (len + ~PAGE_MASK) & PAGE_MASK;
 	end = start + len;
-	if (end < start)
-		goto out;
-	error = 0;
-	if (end == start)
-		goto out;
+	if (end <= start)
+		return -ENOMEM;
 	/*
 	 * If the interval [start,end) covers some unmapped address ranges,
 	 * just ignore them, but return -ENOMEM at the end. Besides, if the
_

Patches currently in -mm which might be from ljs@kernel.org are

mm-vma-predicate-vma_assert_stabilised-on-config_debug_vm.patch
mm-only-assert-mmap-locks-if-config_debug_vm-or-lockdep-is-set.patch
mm-only-assert-vma-locks-if-config_debug_vm-is-set.patch
mm-convert-warn_on_onces-to-vm_warn_on_once-in-vma-lock-code.patch
mm-madvise-zap-markers-from-guard-regions.patch
mm-mmap-free-gathered-pages-before-mmf_oom_skip.patch
percpu-fix-contig-hints-that-are-too-low.patch
percpu-search-the-whole-reserved-chunk.patch
xen-privcmd-convert-mmap-hook-to-mmap_prepare.patch
kvm-ppc-book3s-convert-spapr-tce-mmap-hook-to-mmap_prepare.patch
mshv_vtl-convert-mmap-hooks-to-mmap_prepare.patch
x86-sgx-convert-vepc-mmap-hook-to-mmap_prepare.patch
udf-convert-mmap-hook-to-mmap_prepare.patch
selinuxfs-convert-mmap-hooks-to-mmap_prepare.patch
xen-convert-xenstore-interface-mmap-hooks-to-mmap_prepare.patch
soc-aspeed-convert-lpc-and-p2a-control-mmap-hooks-to-mmap_prepare.patch
soc-qcom-rmtfs_mem-convert-mmap-hook-to-mmap_prepare.patch
tee-convert-shm-mmap-hook-to-mmap_prepare.patch
misc-bcm-vk-convert-mmap-hook-to-mmap_prepare.patch
ptp-vmclock-convert-mmap-hook-to-mmap_prepare.patch
vhost-vdpa-convert-mmap-hook-to-mmap_prepare.patch
mm-vma-error-out-on-invalid-bounds-in-unmapped_area_topdown.patch
mm-vma-lock-vmas-before-taking-mm_all_locks_mutex.patch
mm-filemap-convert-fault-and-readahead-logic-to-use-vma_flags_t.patch
mm-madvise-convert-madvise_vma_behavior-to-use-vma_flags_t.patch
mm-convert-miscellaneous-vma-flag-tests-to-use-vma_flags_t.patch
fs-proc-task_mmu-convert-vma-flag-tests-to-use-vma_flags_t.patch
fs-coredump-convert-vma_dump_size-to-use-vma_flags_t.patch
uprobes-convert-vma-flag-tests-to-use-vma_flags_t.patch
perf-convert-vma-flag-tests-to-use-vma_flags_t.patch
selinux-convert-vma-flag-tests-to-use-vma_flags_t.patch
apparmor-convert-vma-flag-tests-to-use-vma_flags_t.patch
ima-convert-vma-flag-tests-to-use-vma_flags_t.patch
ipe-convert-vma-flag-tests-to-use-vma_flags_t.patch
coda-never-point-a-files-f_mapping-at-a-containers-mapping.patch
fs-proc-task_mmu-write-protect-only-with-ptrace-attach.patch


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

end of thread, other threads:[~2026-12-02  3:47 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 10:59 [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Lorenzo Stoakes (ARM)
2026-11-20 11:06 ` David Hildenbrand (Arm)
2026-11-20 11:09 ` Vlastimil Babka (SUSE)
2026-11-20 11:15   ` Lorenzo Stoakes (ARM)
2026-11-21  0:53 ` mawupeng
2026-11-21  1:07 ` SJ Park
2026-11-24  0:56 ` + mm-msync-return-enomem-if-page-aligned-length-overflows.patch added to mm-hotfixes-unstable branch Andrew Morton
2026-11-24 13:13 ` [PATCH] mm/msync: return -ENOMEM if page-aligned length overflows Pedro Falcato
2026-12-02  3:47 ` [merged mm-hotfixes-stable] mm-msync-return-enomem-if-page-aligned-length-overflows.patch removed from -mm tree Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.