From: Bryam Vargas <hexlabsecurity@proton.me>
To: David Laight <david.laight.linux@gmail.com>,
Dan Williams <djbw@kernel.org>,
Vishal Verma <vishal.l.verma@intel.com>,
Dave Jiang <dave.jiang@intel.com>,
Ira Weiny <ira.weiny@intel.com>
Cc: nvdimm@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] libnvdimm/labels: Prevent integer overflow in __nd_label_validate()
Date: Mon, 22 Jun 2026 08:14:00 +0000 [thread overview]
Message-ID: <20260622081353.57531-1-hexlabsecurity@proton.me> (raw)
In-Reply-To: <20260621112357.56a290bc@pumpkin>
On 2026-06-21, David Laight wrote:
> Is this enough and/or a sane way to stop the overflow.
For the overflow, yes. In 64-bit the product no longer wraps, so the bound
rejects exactly the nslot values that don't fit config_size. Minimal change,
backports cleanly.
> AFAICT label_size is either 128 or 258.
128 or 256. nd_label_validate() probes label_size[] = { 128, 256 } (v1.1 / v1.2)
and sets ndd->nslabel_size from that.
> But I can't see where nsarea.config_size is set.
A u32 filled by nvdimm_init_nsarea() from ND_CMD_GET_CONFIG_SIZE -- reported by
the dimm provider's ->ndctl (firmware/_DSM on NFIT), not a user ioctl. No sanity
cap today.
> The same could be done for nslot - any value above 64k is pretty much
> guaranteed to be garbage
Agreed. The largest legitimate nslot is config_size / label_size: a few hundred
on a real ~128K area, ~1024 at most. The exact bound already ties nslot to
config_size; a ceiling still helps for the gap you point at: config_size is
firmware-reported and uncapped, so a bogus large config_size would otherwise
admit a large nslot and kvzalloc.
I'd keep the (u64) cast as the targeted fix here (Fixes:/stable) and add the
nslot and config_size bounds as a follow-up hardening patch, or fold them into a
v2 if you'd rather see them together. Either way I'll send it.
Bryam
next prev parent reply other threads:[~2026-06-22 8:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-20 20:54 Bryam Vargas via B4 Relay
2026-06-21 10:23 ` David Laight
2026-06-22 8:14 ` Bryam Vargas [this message]
2026-06-24 5:45 ` Bryam Vargas
2026-06-24 0:38 ` Alison Schofield
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=20260622081353.57531-1-hexlabsecurity@proton.me \
--to=hexlabsecurity@proton.me \
--cc=dave.jiang@intel.com \
--cc=david.laight.linux@gmail.com \
--cc=djbw@kernel.org \
--cc=ira.weiny@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--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®