From: Mel Gorman <mgorman@techsingularity.net>
To: Dave Jones <davej@codemonkey.org.uk>,
Andrew Morton <akpm@linux-foundation.org>,
Dan Carpenter <dan.carpenter@oracle.com>,
Jesper Dangaard Brouer <brouer@redhat.com>,
Vlastimil Babka <vbabka@suse.cz>, Linux-MM <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] mm/page_alloc: do bulk array bounds check after checking populated elements
Date: Mon, 28 Jun 2021 12:53:23 +0100 [thread overview]
Message-ID: <20210628115322.GA3840@techsingularity.net> (raw)
In-Reply-To: <20210628042759.GA19686@codemonkey.org.uk>
On Mon, Jun 28, 2021 at 12:27:59AM -0400, Dave Jones wrote:
> On Fri, Jun 18, 2021 at 01:51:02PM +0100, Mel Gorman wrote:
> > Dan Carpenter reported the following
> >
> > The patch 0f87d9d30f21: "mm/page_alloc: add an array-based interface
> > to the bulk page allocator" from Apr 29, 2021, leads to the following
> > static checker warning:
> >
> > mm/page_alloc.c:5338 __alloc_pages_bulk()
> > warn: potentially one past the end of array 'page_array[nr_populated]'
> >
> > The problem can occur if an array is passed in that is fully populated. That
> > potentially ends up allocating a single page and storing it past the end of
> > the array. This patch returns 0 if the array is fully populated.
> >
> > Fixes: 0f87d9d30f21 ("mm/page_alloc: add an array-based interface to the bulk page allocator")
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Mel Gorman <mgorman@techsinguliarity.net>
> > ---
> > mm/page_alloc.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > index 7124bb00219d..ef2265f86b91 100644
> > --- a/mm/page_alloc.c
> > +++ b/mm/page_alloc.c
> > @@ -5056,6 +5056,10 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid,
> > while (page_array && nr_populated < nr_pages && page_array[nr_populated])
> > nr_populated++;
> >
> > + /* Already populated array? */
> > + if (unlikely(page_array && nr_pages - nr_populated == 0))
> > + return 0;
> > +
> > /* Use the single page allocator for one page. */
> > if (nr_pages - nr_populated == 1)
> > goto failed;
>
>
> This made it into 5.13 final, and completely breaks NFSD for me (Serving tcp v3 mounts).
> Existing mounts on clients hang, as do new mounts from new clients.
> Rebooting the server back to rc7 everything recovers. Bisect lands on
> this commit.
>
Thanks Dave, can you try this?
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ef2265f86b91..04220581579c 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5058,7 +5058,7 @@ unsigned long __alloc_pages_bulk(gfp_t gfp, int preferred_nid,
/* Already populated array? */
if (unlikely(page_array && nr_pages - nr_populated == 0))
- return 0;
+ return nr_populated;
/* Use the single page allocator for one page. */
if (nr_pages - nr_populated == 1)
next prev parent reply other threads:[~2021-06-28 11:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-18 12:51 [PATCH] mm/page_alloc: do bulk array bounds check after checking populated elements Mel Gorman
2021-06-28 4:27 ` Dave Jones
2021-06-28 4:59 ` Dave Jones
2021-06-28 11:53 ` Mel Gorman [this message]
2021-06-28 14:48 ` Dave Jones
2021-06-28 15:03 ` Mel Gorman
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=20210628115322.GA3840@techsingularity.net \
--to=mgorman@techsingularity.net \
--cc=akpm@linux-foundation.org \
--cc=brouer@redhat.com \
--cc=dan.carpenter@oracle.com \
--cc=davej@codemonkey.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=torvalds@linux-foundation.org \
--cc=vbabka@suse.cz \
/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 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).