From: Andrew Morton <akpm@linux-foundation.org>
To: Muchun Song <songmuchun@bytedance.com>
Cc: Dan Williams <djbw@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Alison Schofield <alison.schofield@intel.com>,
Joao Martins <joao.m.martins@oracle.com>,
nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org,
linux-kernel@vger.kernel.org, stable@vger.kernel.org,
Muchun Song <muchun.song@linux.dev>,
Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Subject: Re: [PATCH v5] dax/bus: Fix Device DAX range alignment validation
Date: Sat, 24 Oct 2026 18:38:53 -0700 [thread overview]
Message-ID: <20261024183853.6803ce81788636e94d8c16a4@linux-foundation.org> (raw)
In-Reply-To: <20261024112555.2476001-1-songmuchun@bytedance.com>
On Sat, 24 Oct 2026 19:25:55 +0800 Muchun Song <songmuchun@bytedance.com> wrote:
> Only range sizes are currently validated against dev_dax->align. A
> dynamic device can therefore select a large-page alignment and allocate a
> range whose start is not naturally aligned.
>
> Sashiko found that memmap_init_zone_device() could then initialize the
> struct pages with a large-page order for a physical range that is not
> naturally aligned. A subsequent write to a userspace mapping then
> triggered a kernel panic in testing.
>
> The automatic resize path can also split a size-aligned request across
> arbitrary free gaps. When devices with different alignments fragment a
> region, this can extend a range by less than the device alignment. A later
> allocation then fails, leaving the failed resize partially applied.
>
> Initialize the device alignment before its first allocation. Validate both
> the start and size of allocated and adjusted ranges. Use the same
> aligned-gap iterator for free-space accounting and range allocation so the
> pre-check and allocation path cannot diverge. Skip unusable gaps and
> serialize size validation with alignment updates.
>
> Static Device DAX already has a pre-populated pgmap whose full range was
> validated against memremap_compat_align(). Its usable data range may begin
> after namespace metadata, so require only dev_dax->align for static
> devices. Dynamic Device DAX builds its pgmap from the allocated ranges and
> must continue to satisfy both alignments.
Thanks. This is now a must-have for 7.4.
I suggest that the changelog mention that the bug becomes hittable once
your series "mm: Unify device DAX and HugeTLB vmemmap population paths"
exposes it. That's
4b77739fe789 ("mm/sparse-vmemmap: drop VMEMMAP_POPULATE_DAX").
I intend to send this to Linus next week.
Maybe also a Fixes: 4b77739fe789. That series didn't create the bug,
but this data provides notification to people who are backporting this
series (unlikely) "hey, you need to add this fix as well".
Also
Reported-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com>
Closes: https://lore.kernel.org/wlrkqqvg.ritesh.list@gmail.com
I don't believe that Ritesh has tested this? He wasn't cc'ed...
next prev parent reply other threads:[~2026-10-25 1:38 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-24 11:25 Muchun Song
2026-10-25 1:38 ` Andrew Morton [this message]
2026-10-25 2:10 ` Ritesh Harjani
2026-10-25 2:52 ` Muchun Song
2026-10-25 2:59 ` 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=20261024183853.6803ce81788636e94d8c16a4@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=alison.schofield@intel.com \
--cc=dave.jiang@intel.com \
--cc=djbw@kernel.org \
--cc=joao.m.martins@oracle.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=muchun.song@linux.dev \
--cc=nvdimm@lists.linux.dev \
--cc=ritesh.list@gmail.com \
--cc=songmuchun@bytedance.com \
--cc=stable@vger.kernel.org \
--cc=vishal.l.verma@intel.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
all inboxes | Powered by JetHome®