From: sashiko-bot@kernel.org
To: "Jinjie Ruan" <ruanjinjie@huawei.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v17 03/10] crash: Add crash_prepare_headers() to exclude crash kernel memory
Date: Mon, 29 Jun 2026 10:19:59 +0000 [thread overview]
Message-ID: <20260629102000.0BBFD1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260629094746.191843-4-ruanjinjie@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] crash_prepare_headers() delegates array sizing to architectures but performs memory exclusions in generic code, forcing implicit padding to avoid -ENOMEM.
--
commit 7701a27578ff768dd0a4b481af66ec228b7e613f
Author: Jinjie Ruan <ruanjinjie@huawei.com>
crash: Add crash_prepare_headers() to exclude crash kernel memory
This patch introduces a generic crash_prepare_headers() helper to consolidate
crash memory allocation and exclusions across architectures. It adds
architecture-specific hooks for pre-counting memory ranges, populating the
ranges, and performing any additional exclusions.
> diff --git a/kernel/crash_core.c b/kernel/crash_core.c
> index 4f21fc3b108b8..481babc291310 100644
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c
[ ... ]
> @@ -272,6 +269,85 @@ int crash_prepare_elf64_headers(struct crash_mem *mem, int need_kernel_map,
> return 0;
> }
>
[ ... ]
> +int crash_prepare_headers(int need_kernel_map, void **addr, unsigned long *sz,
> + unsigned long *nr_mem_ranges)
> +{
> + unsigned int max_nr_ranges;
> + struct crash_mem *cmem;
> + int ret;
> +
> + max_nr_ranges = arch_get_system_nr_ranges();
> + if (!max_nr_ranges)
> + return -ENOMEM;
> +
> + cmem = alloc_cmem(max_nr_ranges);
> + if (!cmem)
> + return -ENOMEM;
> +
> + ret = arch_crash_populate_cmem(cmem);
> + if (ret)
> + goto out;
> +
> + ret = crash_exclude_core_ranges(cmem);
[Severity: Medium]
Will this return -ENOMEM if the generic exclusion splits memory ranges, unless
architectures implicitly pad the count returned by arch_get_system_nr_ranges()?
crash_exclude_core_ranges() calls crash_exclude_mem_range() for crashk_res,
crashk_low_res, and crashk_cma_ranges. If these exclusions split existing
ranges, crash_exclude_mem_range() will attempt to grow cmem->nr_ranges.
Since cmem is allocated exactly to the max_nr_ranges provided by the
architecture, if the architecture doesn't artificially inflate its count to
account for these generic splits, won't the split operations hit the
cmem->nr_ranges >= cmem->max_nr_ranges check and fail with -ENOMEM?
> + if (ret)
> + goto out;
> +
> + ret = arch_crash_exclude_ranges(cmem);
> + if (ret)
> + goto out;
> +
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260629094746.191843-1-ruanjinjie@huawei.com?part=3
next prev parent reply other threads:[~2026-06-29 10:20 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 9:47 [PATCH v17 00/10] arm64/riscv: Add support for crashkernel CMA reservation Jinjie Ruan
2026-06-29 9:47 ` [PATCH v17 01/10] riscv: kexec_file: Fix crashk_low_res not exclude bug Jinjie Ruan
2026-06-29 9:58 ` sashiko-bot
2026-06-29 9:47 ` [PATCH v17 02/10] powerpc/crash: sort crash memory ranges before preparing elfcorehdr Jinjie Ruan
2026-06-29 9:47 ` [PATCH v17 03/10] crash: Add crash_prepare_headers() to exclude crash kernel memory Jinjie Ruan
2026-06-29 10:19 ` sashiko-bot [this message]
2026-06-29 9:47 ` [PATCH v17 04/10] arm64: kexec_file: Use crash_prepare_headers() helper to simplify code Jinjie Ruan
2026-06-29 10:31 ` sashiko-bot
2026-06-29 9:47 ` [PATCH v17 05/10] x86/crash: " Jinjie Ruan
2026-06-29 10:41 ` sashiko-bot
2026-06-29 9:47 ` [PATCH v17 06/10] riscv: kexec_file: " Jinjie Ruan
2026-06-29 10:53 ` sashiko-bot
2026-06-29 11:28 ` Guo Ren
2026-06-29 9:47 ` [PATCH v17 07/10] LoongArch: " Jinjie Ruan
2026-06-29 11:06 ` sashiko-bot
2026-06-29 9:47 ` [PATCH v17 08/10] powerpc/kexec_file: Use crash_exclude_core_ranges() helper Jinjie Ruan
2026-06-29 9:47 ` [PATCH v17 09/10] arm64: kexec_file: Add support for crashkernel CMA reservation Jinjie Ruan
2026-06-29 9:47 ` [PATCH v17 10/10] riscv: " Jinjie Ruan
2026-06-29 11:33 ` sashiko-bot
2026-06-30 15:49 ` [PATCH v17 00/10] arm64/riscv: " Mike Rapoport
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=20260629102000.0BBFD1F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.org \
--cc=ruanjinjie@huawei.com \
--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