Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jinjie Ruan" <ruanjinjie@huawei.com>
Cc: robh@kernel.org, devicetree@vger.kernel.org, conor+dt@kernel.org,
	krzk+dt@kernel.org
Subject: Re: [PATCH v13 08/15] crash: Add crash_prepare_headers() to exclude crash kernel memory
Date: Tue, 12 May 2026 04:23:18 +0000	[thread overview]
Message-ID: <20260512042318.C0660C2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260511030454.1730881-9-ruanjinjie@huawei.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Calling `get_online_mems()` inside `crash_prepare_headers()` creates an AA self-deadlock when executed from the memory hotplug notifier path.
--

commit 40b18d3ef2c2d34f758c8077fa6b20ad0d951107
Author: Jinjie Ruan <ruanjinjie@huawei.com>

crash: Add crash_prepare_headers() to exclude crash kernel memory

This commit introduces a common crash_prepare_headers() helper to consolidate
crash memory allocation and exclusion logic across architectures. It adds
three new architecture-specific functions to gather memory ranges and builds
the ELF core headers for the crash kernel.

> diff --git a/kernel/crash_core.c b/kernel/crash_core.c
> index 2c1a3791e4101..c50c25937d7d4 100644
> --- a/kernel/crash_core.c
> +++ b/kernel/crash_core.c

[ ... ]

> +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;
> +
> +	get_online_mems();

Could this cause an AA self-deadlock when crash_prepare_headers() is used
by arch_crash_handle_hotplug_event() to handle memory hotplug events?

When memory is hotplugged, online_pages() or offline_pages() trigger the
memory_notify() chain. online_pages() is invoked with the mem_hotplug_lock
already held for write via mem_hotplug_begin() (which maps to
percpu_down_write(&mem_hotplug_lock)).

If the hotplug notifier invokes the crash handler to update the ELF headers,
the current thread attempts to acquire the same lock for read here in
get_online_mems().

Since the Linux percpu_rw_semaphore does not support recursive read-lock
acquisition by the active writer, will the thread fail the trylock and sleep
indefinitely in percpu_rwsem_wait(), causing a deadlock?

> +	max_nr_ranges = arch_get_system_nr_ranges();
> +	if (!max_nr_ranges) {
> +		put_online_mems();
> +		return -ENOMEM;
> +	}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260511030454.1730881-1-ruanjinjie@huawei.com?part=8

  reply	other threads:[~2026-05-12  4:23 UTC|newest]

Thread overview: 23+ 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 ` [PATCH v13 01/15] riscv: kexec_file: Fix crashk_low_res not exclude bug 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 ` [PATCH v13 03/15] x86/kexec: Fix potential buffer overflow in prepare_elf_headers() Jinjie Ruan
2026-05-12  0:18   ` sashiko-bot
2026-05-11  3:04 ` [PATCH v13 04/15] arm64: kexec_file: " Jinjie Ruan
2026-05-11  9:46   ` Breno Leitao
2026-05-11 11:30     ` Jinjie Ruan
2026-05-11 12:30       ` Breno Leitao
2026-05-12  0:45   ` sashiko-bot
2026-05-11  3:04 ` [PATCH v13 05/15] riscv: " Jinjie Ruan
2026-05-11  3:04 ` [PATCH v13 06/15] LoongArch: kexec: " 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 ` [PATCH v13 08/15] crash: Add crash_prepare_headers() to exclude crash kernel memory Jinjie Ruan
2026-05-12  4:23   ` sashiko-bot [this message]
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 ` [PATCH v13 10/15] x86/kexec: " 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 ` [PATCH v13 12/15] LoongArch: kexec: " 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 ` [PATCH v13 14/15] arm64: kexec: Add support for crashkernel CMA reservation Jinjie Ruan
2026-05-11  3:04 ` [PATCH v13 15/15] riscv: " 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=20260512042318.C0660C2BCB0@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox