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 v5 4/8] of: reserved_mem: mark /memreserve/ entries as MEMBLOCK_NODUMP
Date: Thu, 06 Aug 2026 09:57:00 +0000 [thread overview]
Message-ID: <20260806095702.ADFA11F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806093519.2907771-5-chenwandun1@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] 64-bit FDT memreserve base and size values bypass overlap checks due to type mismatch and implicit truncation to 32-bit.
- [High] The overlap check between the memreserve region and dumpable reserved memory regions fails due to 32-bit arithmetic overflow.
--
--- Patch [4]: [PATCH v5 4/8] of: reserved_mem: mark /memreserve/ entries as MEMBLOCK_NODUMP ---
commit 224ae2a2bcff895e0e857319035a55e95d869a02
Author: Wandun Chen <chenwandun@lixiang.com>
of: reserved_mem: mark /memreserve/ entries as MEMBLOCK_NODUMP
The /memreserve/ entries are memory reservations made by the bootloader
or firmware, their contents are not needed for kernel crash analysis,
so mark them MEMBLOCK_NODUMP to have kdump omit them from the vmcore.
Entries that overlap a dumpable region (such as CMA) are left unmarked,
because the pages of a dumpable region may carry crash-relevant data.
> diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c
> index f38d11df6f152..f0683b5d77b30 100644
> --- a/drivers/of/of_reserved_mem.c
> +++ b/drivers/of/of_reserved_mem.c
[ ... ]
> @@ -251,6 +251,38 @@ static void __init __rmem_check_for_overlap(void)
> }
> }
>
> +void __init fdt_mark_memreserve_nodump(void)
> +{
> + u64 base, size;
> + int n;
> + const void *fdt = initial_boot_params;
> +
> + if (!IS_ENABLED(CONFIG_CRASH_DUMP))
> + return;
> +
> + if (!fdt)
> + return;
> +
> + for (n = 0; ; n++) {
> + int i;
> +
> + if (fdt_get_mem_rsv(fdt, n, &base, &size))
> + break;
> + if (!size)
> + break;
> +
> + for (i = 0; i < reserved_mem_count; i++) {
> + struct reserved_mem *rmem = &reserved_mem[i];
> +
> + if (rmem->dumpable && base < rmem->base + rmem->size &&
> + rmem->base < base + size)
[Severity: High]
Does this overlap check suffer from a 32-bit arithmetic overflow?
Both rmem->base and rmem->size are phys_addr_t. On 32-bit systems, their
addition evaluates as a 32-bit operation. If a dumpable memory region extends
exactly to the end of the 32-bit address space, rmem->base + rmem->size could
overflow and wrap to 0.
The wrapped value 0 would then be zero-extended to u64 for the comparison
against the u64 base. The comparison base < 0ULL will always evaluate to false,
causing the overlap check to silently fail and incorrectly mark the memreserve
as MEMBLOCK_NODUMP.
> + break;
> + }
> + if (i == reserved_mem_count)
> + memblock_mark_nodump(base, size);
[Severity: High]
Could this implicitly truncate the 64-bit base and size values to 32-bit?
The base and size variables are u64, but memblock_mark_nodump() expects 32-bit
phys_addr_t parameters on 32-bit systems without PAE.
If an FDT contains a memory reservation with a base address above 4GB, the
64-bit value passes the overlap check above but gets implicitly truncated here.
This modifies the truncated 32-bit address instead, completely bypassing the
overlap check for the address actually being modified, and could erroneously
mark valid dumpable memory regions as MEMBLOCK_NODUMP.
> + }
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260806093519.2907771-1-chenwandun1@gmail.com?part=4
next prev parent reply other threads:[~2026-08-06 9:57 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20260806093541eucas1p169d6fcb31de09012bdfca326867e86d6@eucas1p1.samsung.com>
2026-08-06 9:35 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time Wandun Chen
2026-08-06 9:35 ` [PATCH v5 1/8] memblock: introduce MEMBLOCK_NODUMP flag Wandun Chen
2026-08-06 9:51 ` sashiko-bot
2026-08-06 11:43 ` Wandun
2026-08-06 9:35 ` [PATCH v5 2/8] of: reserved_mem: add dumpable flag to opt-in vmcore Wandun Chen
2026-08-06 9:47 ` sashiko-bot
2026-08-06 11:48 ` Wandun
2026-08-06 9:35 ` [PATCH v5 3/8] of: reserved_mem: mark /reserved-memory entries with MEMBLOCK_NODUMP Wandun Chen
2026-08-06 10:06 ` sashiko-bot
2026-08-06 9:35 ` [PATCH v5 4/8] of: reserved_mem: mark /memreserve/ entries as MEMBLOCK_NODUMP Wandun Chen
2026-08-06 9:57 ` sashiko-bot [this message]
2026-08-06 9:35 ` [PATCH v5 5/8] riscv: build crash_mem ranges from memblock instead of resource tree Wandun Chen
2026-08-06 10:10 ` sashiko-bot
2026-08-06 9:35 ` [PATCH v5 6/8] crash_core: fold duplicated memblock arch hooks into the weak default Wandun Chen
2026-08-06 9:56 ` sashiko-bot
2026-08-06 9:35 ` [PATCH v5 7/8] crash_core: replace for_each_mem_range() with for_each_mem_region() Wandun Chen
2026-08-06 10:07 ` sashiko-bot
2026-08-06 9:35 ` [PATCH v5 8/8] crash_core: skip MEMBLOCK_NODUMP regions when building vmcore ELF header Wandun Chen
2026-08-06 10:24 ` sashiko-bot
2026-08-06 10:11 ` [PATCH v5 0/8] kdump: reduce vmcore size and capture time 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=20260806095702.ADFA11F000E9@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