From: Andrew Morton <akpm@linux-foundation.org>
To: Sourav Panda <souravpanda@google.com>
Cc: Muchun Song <muchun.song@linux.dev>,
osalvador@suse.de, usama.arif@linux.dev, shakeel.butt@linux.dev,
wangkefeng.wang@huawei.com, anshuman.khandual@arm.com,
david@kernel.org, surenb@google.com, fvdl@google.com,
gthelen@google.com, hannes@cmpxchg.org, riel@surriel.com,
sj@kernel.org, vbabka@suse.cz, mhocko@suse.com,
bjackman@google.com, zi.yan@sent.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5] mm/hugetlb_cma: Fix null nodemask dereference in hugetlb_cma_alloc_frozen_folio
Date: Mon, 10 Aug 2026 15:36:28 -0700 [thread overview]
Message-ID: <20260810153628.c4049163bd92b5ce3d3d7d99@linux-foundation.org> (raw)
In-Reply-To: <CANruzcQ_1533umf4ym-t5EVm_WX5rrYtCbCqaTdvNr6EgOYR=w@mail.gmail.com>
On Sun, 9 Aug 2026 23:39:22 -0700 Sourav Panda <souravpanda@google.com> wrote:
> > That way, we can remove the 'if (!page)' check here.
>
> Sure thing! Thanks! I shall send this tomorrow noon (PST) since I am
> OOO starting Thursday.
Sashiko said a thing - I don't think it reported this against previous
iterations:
https://sashiko.dev/#/patchset/20260726072935.3513996-1-souravpanda@google.com
I'll add this v4->v5 update to mm-hotfixes-unstable, assuming it gets
us a bit closer to the final version.
--- a/mm/hugetlb_cma.c~mm-hugetlb_cma-fix-null-nodemask-dereference-in-hugetlb_cma_alloc_frozen_folio-v5
+++ a/mm/hugetlb_cma.c
@@ -3,6 +3,7 @@
#include <linux/mm.h>
#include <linux/cma.h>
#include <linux/compiler.h>
+#include <linux/cpuset.h>
#include <linux/mm_inline.h>
#include <asm/page.h>
@@ -30,12 +31,21 @@ struct folio *hugetlb_cma_alloc_frozen_f
int node;
struct folio *folio;
struct page *page = NULL;
+ nodemask_t local_node_mask;
if (!hugetlb_cma_size)
return NULL;
- if (!nodemask)
- nodemask = &node_states[N_MEMORY];
+ if (!nodemask) {
+ unsigned int cpuset_mems_cookie;
+
+ do {
+ cpuset_mems_cookie = read_mems_allowed_begin();
+ local_node_mask = cpuset_current_mems_allowed;
+ } while (read_mems_allowed_retry(cpuset_mems_cookie));
+
+ nodemask = &local_node_mask;
+ }
if (hugetlb_cma[nid] && node_isset(nid, *nodemask))
page = cma_alloc_frozen_compound(hugetlb_cma[nid], order);
_
next prev parent reply other threads:[~2026-08-10 22:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-09 4:32 [PATCH v5] mm/hugetlb_cma: Fix null nodemask dereference in hugetlb_cma_alloc_frozen_folio Sourav Panda
2026-08-09 6:58 ` Muchun Song
2026-08-09 20:11 ` Sourav Panda
2026-08-10 2:23 ` Muchun Song
2026-08-10 6:39 ` Sourav Panda
2026-08-10 22:36 ` Andrew Morton [this message]
2026-08-10 23:06 ` Sourav Panda
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=20260810153628.c4049163bd92b5ce3d3d7d99@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=anshuman.khandual@arm.com \
--cc=bjackman@google.com \
--cc=david@kernel.org \
--cc=fvdl@google.com \
--cc=gthelen@google.com \
--cc=hannes@cmpxchg.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--cc=riel@surriel.com \
--cc=shakeel.butt@linux.dev \
--cc=sj@kernel.org \
--cc=souravpanda@google.com \
--cc=surenb@google.com \
--cc=usama.arif@linux.dev \
--cc=vbabka@suse.cz \
--cc=wangkefeng.wang@huawei.com \
--cc=zi.yan@sent.com \
/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