All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: mm-commits@vger.kernel.org,vbabka@kernel.org,surenb@google.com,
	sj@kernel.org,shakeel.butt@linux.dev,pfalcato@suse.de,mawupeng1@huawei.com,
	liam@infradead.org,jannh@google.com,dingf3ng@gmail.com,david@kernel.org,
	ljs@kernel.org,akpm@linux-foundation.org
Subject: + mm-msync-return-enomem-if-page-aligned-length-overflows.patch added to mm-hotfixes-unstable branch
Date: Mon, 23 Nov 2026 16:56:57 -0800	[thread overview]
Message-ID: <20261124005657.D22ED1F000C0@smtp.kernel.org> (raw)
In-Reply-To: <20261120-msync-enomem-fix-v1-1-80282c8c5beb@kernel.org>


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


  parent reply	other threads:[~2026-11-24  0:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Andrew Morton [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124005657.D22ED1F000C0@smtp.kernel.org \
    --to=akpm@linux-foundation.org \
    --cc=david@kernel.org \
    --cc=dingf3ng@gmail.com \
    --cc=jannh@google.com \
    --cc=liam@infradead.org \
    --cc=ljs@kernel.org \
    --cc=mawupeng1@huawei.com \
    --cc=mm-commits@vger.kernel.org \
    --cc=pfalcato@suse.de \
    --cc=shakeel.butt@linux.dev \
    --cc=sj@kernel.org \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.