From: sashiko-bot@kernel.org
To: "Jinjie Ruan" <ruanjinjie@huawei.com>
Cc: conor+dt@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH v13 03/15] x86/kexec: Fix potential buffer overflow in prepare_elf_headers()
Date: Tue, 12 May 2026 00:18:52 +0000 [thread overview]
Message-ID: <20260512001853.10D95C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260511030454.1730881-4-ruanjinjie@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Spurious -ENOMEM failure to userspace and false architectural assumption regarding hotplug correction (fixed later in series).
--
commit a014be7b4b0eecc06de944b08ad83662babd2b5d
Author: Jinjie Ruan <ruanjinjie@huawei.com>
x86/kexec: Fix potential buffer overflow in prepare_elf_headers()
This commit adds a boundary check in prepare_elf64_ram_headers_callback()
to prevent a buffer overflow if memory hotplug increases the number of
memory regions between the counting and population passes.
> Since x86 supports crash hotplug, any data inconsistency caused by
> a race during the initial load will be corrected by the subsequent
> hotplug update. However, we must prevent a buffer overflow if the
> number of memory regions increases between the two passes.
Is this description of the hotplug update accurate?
The initial load syscall actively holds the atomic kexec_trylock() for its
entire duration. If a hotplug event occurs concurrently, wouldn't the
hotplug notifier (crash_handle_hotplug_event()) fail to acquire the lock,
log a lock failure, and permanently drop the update?
> diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
> --- a/arch/x86/kernel/crash.c
> +++ b/arch/x86/kernel/crash.c
> @@ -225,6 +225,9 @@ static int prepare_elf64_ram_headers_callback(struct resource *res, void *arg)
> {
> struct crash_mem *cmem = arg;
>
> + if (cmem->nr_ranges >= cmem->max_nr_ranges)
> + return -ENOMEM;
> +
Does returning -ENOMEM here abort the sys_kexec_file_load() syscall,
propagating a spurious error to userspace and leaving the system without a
loaded crash kernel?
Commit a0b7fe2dc98fe ("crash: Add crash_prepare_headers() to exclude crash
kernel memory") later in the series resolves this spurious error by adding
get_online_mems() to serialize the memory passes.
However, if the hotplug update is dropped due to the kexec_trylock()
contention mentioned above, and the race occurs in a way that does not
trigger this bounds check (such as memory regions decreasing), does the
kdump image still remain permanently out of sync with the actual memory
layout?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260511030454.1730881-1-ruanjinjie@huawei.com?part=3
next prev parent reply other threads:[~2026-05-12 0:18 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-11 3:04 [PATCH v13 00/15] arm64/riscv: Add support for crashkernel CMA reservation Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 01/15] riscv: kexec_file: Fix crashk_low_res not exclude bug Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 02/15] powerpc/crash: Fix possible memory leak in update_crash_elfcorehdr() Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 03/15] x86/kexec: Fix potential buffer overflow in prepare_elf_headers() Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-12 0:18 ` sashiko-bot [this message]
2026-05-11 3:04 ` [PATCH v13 04/15] arm64: kexec_file: " Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 9:46 ` Breno Leitao
2026-05-11 9:46 ` Breno Leitao
2026-05-11 11:30 ` Jinjie Ruan
2026-05-11 11:30 ` Jinjie Ruan
2026-05-11 12:30 ` Breno Leitao
2026-05-11 12:30 ` Breno Leitao
2026-05-19 12:42 ` Jinjie Ruan
2026-05-19 12:42 ` Jinjie Ruan
2026-05-12 0:45 ` sashiko-bot
2026-05-19 12:33 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 05/15] riscv: " Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 06/15] LoongArch: kexec: " Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 07/15] powerpc/crash: sort crash memory ranges before preparing elfcorehdr Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 08/15] crash: Add crash_prepare_headers() to exclude crash kernel memory Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-12 4:23 ` sashiko-bot
2026-05-11 3:04 ` [PATCH v13 09/15] arm64: kexec_file: Use crash_prepare_headers() helper to simplify code Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 10/15] x86/kexec: " Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-12 5:48 ` sashiko-bot
2026-05-11 3:04 ` [PATCH v13 11/15] riscv: kexec_file: " Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 12/15] LoongArch: kexec: " Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 13/15] crash: Use crash_exclude_core_ranges() on powerpc Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 14/15] arm64: kexec: Add support for crashkernel CMA reservation Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
2026-05-11 3:04 ` [PATCH v13 15/15] riscv: " Jinjie Ruan
2026-05-11 3:04 ` Jinjie Ruan
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=20260512001853.10D95C2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=robh@kernel.org \
--cc=ruanjinjie@huawei.com \
--cc=sashiko@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.