Devicetree
 help / color / mirror / Atom feed
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 1/8] memblock: introduce MEMBLOCK_NODUMP flag
Date: Thu, 06 Aug 2026 09:51:12 +0000	[thread overview]
Message-ID: <20260806095112.DC81E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806093519.2907771-2-chenwandun1@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] The patch completely omits the filtering logic required to exclude MEMBLOCK_NODUMP regions from kdump vmcores.
- [Medium] The MEMBLOCK_NODUMP flag extends the flagname array but leaves an uninitialized hole for MEMBLOCK_RSRV_HUGETLB, leading to a NULL format argument.
--

--- Patch [1]: [PATCH v5 1/8] memblock: introduce MEMBLOCK_NODUMP flag ---
commit b30a0bfd2a4e00657ccc3f49bdfa4a7ca5fdfa1d
Author: Wandun Chen <chenwandun@lixiang.com>

memblock: introduce MEMBLOCK_NODUMP flag

Add MEMBLOCK_NODUMP to mark regions that should be excluded from kdump vmcores.
The flag is meant for reserved memory that carries no data useful for crash
analysis. Subsequent patches wire this up for /reserved-memory and
/memreserve/ entries.

> diff --git a/mm/memblock.c b/mm/memblock.c
> index 9ce86349a29fa..79231634c25b0 100644
> --- a/mm/memblock.c
> +++ b/mm/memblock.c
> @@ -1204,6 +1204,21 @@ __init int memblock_clear_kho_scratch(phys_addr_t base, phys_addr_t size)
>  				    MEMBLOCK_KHO_SCRATCH);
>  }
>  
> +/**
> + * memblock_mark_nodump - Mark a memory region with flag MEMBLOCK_NODUMP.
> + * @base: the base phys addr of the region
> + * @size: the size of the region
> + *
> + * Mark the region as not to be included in crash dumps.
> + *
> + * Return: 0 on success, -errno on failure.
> + */
> +int __init_memblock memblock_mark_nodump(phys_addr_t base, phys_addr_t size)
> +{
> +	return memblock_setclr_flag(&memblock.memory, base, size, 1,
> +				    MEMBLOCK_NODUMP);
> +}
> +

[Severity: High]
Is it intentional that the filtering logic for this new flag was omitted?

Without updating should_skip_region() in this file to filter out regions
marked with MEMBLOCK_NODUMP, the flag appears to have no functional effect.

When architecture kdump setup iterates over memory ranges (e.g., using
for_each_mem_range()) to build the crash dump list, these regions will still
be included because should_skip_region() does not know to skip them.

[ ... ]

> @@ -2886,6 +2901,7 @@ static const char * const flagname[] = {
>  	[ilog2(MEMBLOCK_RSRV_NOINIT)] = "RSV_NIT",
>  	[ilog2(MEMBLOCK_RSRV_KERN)] = "RSV_KERN",
>  	[ilog2(MEMBLOCK_KHO_SCRATCH)] = "KHO_SCRATCH",
> +	[ilog2(MEMBLOCK_NODUMP)] = "NODUMP",
>  };
>  
>  static int memblock_debug_show(struct seq_file *m, void *private)

[Severity: Medium]
Will this expansion of the array leave a NULL pointer hole for the
MEMBLOCK_RSRV_HUGETLB flag?

Prior to this patch, the max index was 6. MEMBLOCK_RSRV_HUGETLB is bit 7,
which safely fell back to printing "UNKNOWN". 

Adding MEMBLOCK_NODUMP (bit 8) expands the array size to 9. Due to designated
initialization, index 7 becomes NULL.

When memblock_debug_show() prints a region with MEMBLOCK_RSRV_HUGETLB set,
it will read the NULL pointer and pass it to seq_printf():

    if (reg->flags & (1U << j)) {
        seq_printf(m, "%s\n", flagname[j]);
        break;
    }

While seq_printf() will safely print "(null)", this will break out of the
printing loop early and omit any other flags. Could MEMBLOCK_RSRV_HUGETLB
be added to the array as well to avoid this hole?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806093519.2907771-1-chenwandun1@gmail.com?part=1

  reply	other threads:[~2026-08-06  9:51 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 [this message]
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
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=20260806095112.DC81E1F000E9@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