From: sashiko-bot@kernel.org
To: "Wandun Chen" <chenwandun1@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v3 5/5] of: reserved_mem: reject static mapped regions overlapping existing reservations
Date: Sun, 20 Sep 2026 10:13:33 +0000 [thread overview]
Message-ID: <20260920101334.5DE8A1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260920092852.614973-6-chenwandun1@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] of/reserved_mem: valid overlapping reservations are broken by unconditional rejection
--
commit f3ecc5d72c441ce7fd915e30544e07c69215f6c4
Author: Wandun Chen <chenwandun@lixiang.com>
of: reserved_mem: reject static mapped regions overlapping existing reservations
This commit modifies early_init_dt_reserve_memory() to reject static
reserved-memory regions that overlap with existing memblock reservations.
It aims to prevent memory corruption when initialization of a statically
placed region fails and memblock_phys_free() returns the overlap to the
buddy allocator.
Link: https://sashiko.dev/#/message/20260806100605.2C2C01F000E9%40smtp.kernel.org [1]
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index 8d2057f2ac12e..2d1e01c0f8867 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
> @@ -141,6 +141,10 @@ static int __init early_init_dt_reserve_memory(phys_addr_t base,
> return ret;
> }
>
> + if (memblock_is_region_reserved(base, size) ||
> + memblock_overlaps_nomap_region(base, size))
> + return -EBUSY;
> +
[Severity: High]
Does this code unconditionally reject reserved-memory nodes that perfectly
describe memory already reserved by the architecture or EFI setup?
If a bootloader (like U-Boot or EFI) reserves a memory region (e.g.
EFI_RESERVED_TYPE) and also passes a /reserved-memory DT node describing the
same region to ensure compatibility, it looks like
early_init_dt_reserve_memory() will now find the region already reserved in
memblock and return -EBUSY. This bypasses memblock_mark_rsrv_rmem().
Later in the boot process, fdt_scan_reserved_mem_late() checks for the
MEMBLOCK_RSRV_RMEM flag on the region:
drivers/of/of_reserved_mem.c:fdt_scan_reserved_mem_late() {
...
if (!memblock_is_region_rsrv_rmem(base, size, nomap))
continue;
...
}
If the flag is missing, it skips calling fdt_init_reserved_mem_node(). Could
this cause valid overlapping DT nodes to be silently discarded, causing
devices relying on these nodes (like DRM display drivers using an EFI
framebuffer) to fail to probe because of_reserved_mem_lookup() will return
NULL?
Additionally, does the existing check in the if (nomap) block earlier in
early_init_dt_reserve_memory() have the same effect? It appears to reject
no-map DT nodes if the region was already marked nomap by EFI, effectively
destroying those DT nodes as well.
> ret = memblock_reserve(base, size);
> if (!ret)
> memblock_mark_rsrv_rmem(base, size);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260920092852.614973-1-chenwandun1@gmail.com?part=5
next prev parent reply other threads:[~2026-09-20 10:13 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-20 9:28 [PATCH v3 0/5] of: reserved_mem: several fixes about reserved memory Wandun Chen
2026-09-20 9:28 ` [PATCH v3 1/5] of: reserved_mem: release dynamically allocated no-map region on init failure Wandun Chen
2026-09-20 9:28 ` [PATCH v3 2/5] of: reserved_mem: retain static no-map memory " Wandun Chen
2026-09-20 9:28 ` [PATCH v3 3/5] of: reserved_mem: skip init for regions whose early reservation failed Wandun Chen
2026-09-20 9:28 ` [PATCH v3 4/5] of: reserved_mem: reject static regions overlapping no-map memory Wandun Chen
2026-09-20 10:03 ` sashiko-bot
2026-09-20 9:28 ` [PATCH v3 5/5] of: reserved_mem: reject static mapped regions overlapping existing reservations Wandun Chen
2026-09-20 10:13 ` sashiko-bot [this message]
2026-09-22 8:48 ` [PATCH v3 0/5] of: reserved_mem: several fixes about reserved memory Mike Rapoport
2026-09-22 9:24 ` Wandun
2026-10-03 8:04 ` Mike Rapoport
2026-10-06 13:26 ` Marek Szyprowski
2026-10-08 6:38 ` Mike Rapoport
2026-10-08 9:43 ` Marek Szyprowski
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=20260920101334.5DE8A1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=chenwandun1@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--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