From: sashiko-bot@kernel.org
To: "Loic Poulain" <loic.poulain@oss.qualcomm.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v5 1/9] block: partitions: of: Skip child nodes without reg property
Date: Sat, 13 Jun 2026 13:21:38 +0000 [thread overview]
Message-ID: <20260613132138.6EBD21F00A3E@smtp.kernel.org> (raw)
In-Reply-To: <20260612-block-as-nvmem-v5-1-95e0b30fff90@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] The device node reference for `partitions_np` is acquired but leaked on both the success and incompatibility early-return paths.
- [High] Potential NULL pointer dereference in `strscpy()` if a partition node lacks both `label` and `name` properties.
- [High] Malicious device tree properties `#address-cells` and `#size-cells` can cause integer underflow, bypassing the length check and leading to massive out-of-bounds reads.
--
commit a6b306502d7065c56b83fd73a46be12067fb56e3
Author: Loic Poulain <loic.poulain@oss.qualcomm.com>
block: partitions: of: Skip child nodes without reg property
Child nodes of a fixed-partitions node are not necessarily partition
entries, for example an nvmem-layout node has no reg property. The
current code passes a NULL reg pointer and uninitialized len to the
length check, which can result in a kernel panic or silent failure to
register any partitions.
> diff --git a/block/partitions/of.c b/block/partitions/of.c
> index c22b606610981..534e02a9d85f6 100644
> --- a/block/partitions/of.c
> +++ b/block/partitions/of.c
> @@ -15,6 +15,10 @@ static int validate_of_partition(struct device_node *np, int slot)
> int a_cells = of_n_addr_cells(np);
> int s_cells = of_n_size_cells(np);
>
> + /* Skip nodes without a reg property (e.g. nvmem-layout) */
> + if (!reg)
> + return 1;
> +
> /* Make sure reg len match the expected addr and size cells */
> if (len / sizeof(*reg) != a_cells + s_cells)
> return -EINVAL;
[Severity: High]
This is a pre-existing issue, but could malicious device tree properties
cause an integer underflow here?
The functions of_n_addr_cells() and of_n_size_cells() return signed integers.
If a device tree specifies a large unsigned value like 0xffffffff, these
functions will return -1.
The validation check above can be bypassed if the sum of negative and positive
cell counts equals the length ratio.
When the negative size is later passed to of_read_number(reg, a_cells) in
add_of_partition(), the internal while (size--) loop underflows, causing a
massive out-of-bounds read and panic.
[ ... ]
> @@ -97,9 +102,10 @@ int of_partition(struct parsed_partitions *state)
> break;
> }
>
> - add_of_partition(state, slot, np);
> -
> - slot++;
> + if (of_property_present(np, "reg")) {
> + add_of_partition(state, slot, np);
[Severity: High]
This isn't a bug introduced by this patch, but does add_of_partition() have a
NULL pointer dereference risk?
Inside add_of_partition(), partname is populated by checking for "label"
and falling back to "name". If a node omits both properties, of_get_property()
returns NULL:
block/partitions/of.c:add_of_partition() {
...
partname = of_get_property(np, "label", &len);
if (!partname)
partname = of_get_property(np, "name", &len);
strscpy(info->volname, partname, sizeof(info->volname));
...
}
Will passing a NULL partname to strscpy() cause a kernel panic?
> + slot++;
> + }
> }
>
> seq_buf_puts(&state->pp_buf, "\n");
[Severity: High]
This is a pre-existing issue, but does this function leak the partitions_np
device node reference?
A reference is acquired via of_node_get(ddev->of_node) at the start of
of_partition().
If the node is not compatible with "fixed-partitions", the function returns 0
early without calling of_node_put(partitions_np).
Similarly, on this successful parsing path, it returns 1 without releasing
the reference.
Could this lead to memory exhaustion or block the release of dynamically
allocated device nodes every time partitions are rescanned?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260612-block-as-nvmem-v5-0-95e0b30fff90@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-06-13 13:21 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-12 13:20 [PATCH v5 0/9] Support for block device NVMEM providers Loic Poulain
2026-06-12 13:20 ` [PATCH v5 1/9] block: partitions: of: Skip child nodes without reg property Loic Poulain
2026-06-13 13:21 ` sashiko-bot [this message]
2026-06-12 13:20 ` [PATCH v5 2/9] dt-bindings: mmc: Document support for nvmem-layout Loic Poulain
2026-06-12 13:20 ` [PATCH v5 3/9] dt-bindings: net: wireless: qcom,ath10k: Document NVMEM cells Loic Poulain
2026-06-12 13:20 ` [PATCH v5 4/9] dt-bindings: bluetooth: qcom: Add NVMEM BD address cell Loic Poulain
2026-06-12 13:20 ` [PATCH v5 5/9] block: implement NVMEM provider Loic Poulain
2026-06-13 13:21 ` sashiko-bot
2026-06-12 13:20 ` [PATCH v5 6/9] net: of_net: Add of_get_nvmem_eui48() helper for EUI-48 lookup Loic Poulain
2026-06-12 13:20 ` [PATCH v5 7/9] Bluetooth: hci_sync: Add NVMEM-backed BD address retrieval Loic Poulain
2026-06-12 13:21 ` [PATCH v5 8/9] Bluetooth: qca: Set NVMEM BD address quirks when address is invalid Loic Poulain
2026-06-12 13:21 ` [PATCH v5 9/9] arm64: dts: qcom: arduino-imola: Describe NVMEM layout for WiFi/BT addresses Loic Poulain
2026-06-13 13:21 ` sashiko-bot
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=20260613132138.6EBD21F00A3E@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=loic.poulain@oss.qualcomm.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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