From: sashiko-bot@kernel.org
To: "Coiby Xu" <coiby.xu@gmail.com>
Cc: "Baoquan He" <baoquan.he@linux.dev>,
"Sourabh Jain" <sourabhjain@linux.ibm.com>,
"Dave Young" <ruirui.yang@linux.dev>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Will Deacon" <will@kernel.org>,
linux-arm-kernel@lists.infradead.org,
"Jinjie Ruan" <ruanjinjie@huawei.com>,
"Pasha Tatashin" <pasha.tatashin@soleen.com>,
"open list" <linux-kernel@vger.kernel.org>,
"Pratyush Yadav" <pratyush@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
kexec@lists.infradead.org
Subject: Re: [PATCH v5 3/9] crash_dump: Disallow writing to dm-crypt configfs during kexec_file_load syscall
Date: Wed, 09 Sep 2026 00:47:21 +0000 [thread overview]
Message-ID: <20260909004722.649E21F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260909003657.1570544-4-coiby.xu@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Severe locking imbalance in `crash_load_dm_crypt_keys()` leads to a leaked mutex on the error path and unlocking an unacquired mutex on the success path.
Pre-existing issues:
- [High] Premature and unconditional reset of `is_dm_key_reused` to false breaks ARM64/LoongArch kexec load retries and defeats intended cleanup logic.
--
commit a9405cf8948ba39213612c61a1f3b10b23f437e4
Author: Coiby Xu <coiby.xu@gmail.com>
crash_dump: Disallow writing to dm-crypt configfs during kexec_file_load syscall
This commit prevents concurrent writes to the configfs group during the
kexec_file_load syscall by utilizing config_keys_subsys.su_mutex. It aims to
avoid buffer overflows, stale keys, or memory leaks caused by changes to
dm-crypt keys during iteration.
> diff --git a/kernel/crash_dump_dm_crypt.c b/kernel/crash_dump_dm_crypt.c
> index 3a416933979f8..580534d43b66e 100644
> --- a/kernel/crash_dump_dm_crypt.c
> +++ b/kernel/crash_dump_dm_crypt.c
[ ... ]
> @@ -478,6 +490,9 @@ int crash_load_dm_crypt_keys(struct kimage *image)
> "Loaded dm crypt keys to kexec_buffer bufsz=0x%lx memsz=0x%lx\n",
> kbuf.bufsz, kbuf.memsz);
>
> +unlock:
> + mutex_unlock(&config_keys_subsys.su_mutex);
> +
[Severity: High]
Looking at crash_load_dm_crypt_keys(), if kexec_add_buffer() fails earlier
in the function, it jumps to the out label, bypassing this unlock label.
Does this leak the config_keys_subsys.su_mutex if the lock was acquired?
Also, on the success path, mutex_unlock() is executed unconditionally. If
is_dm_key_reused was true at the top of the function, the mutex was never
acquired. Can this cause a kernel panic or corruption by unlocking an
unacquired mutex?
> out:
> - return r;
> + is_dm_key_reused = false;
> + return r;
> }
[Severity: High]
This is a pre-existing issue, but since the error and success paths
unconditionally reset is_dm_key_reused to false here, does this break
architectures like ARM64 that might retry segment loading?
If load_other_segments() retries the load sequence, the second pass
through crash_load_dm_crypt_keys() will see is_dm_key_reused as false,
find zero keys, and silently load nothing into the kdump kernel.
Additionally, crash_dm_crypt_cleanup() checks !is_dm_key_reused to determine
whether it should free keys_header. Since the flag is unconditionally cleared
here first, does this defeat the intended cleanup protection logic?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909003657.1570544-1-coiby.xu@gmail.com?part=3
next prev parent reply other threads:[~2026-09-09 0:47 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260909003657.1570544-1-coiby.xu@gmail.com>
2026-09-09 0:36 ` [PATCH v5 1/9] crash_dump: Fix potential double free and UAF of keys_header Coiby Xu
2026-09-09 0:53 ` sashiko-bot
2026-09-09 13:27 ` Coiby Xu
2026-09-09 0:36 ` [PATCH v5 2/9] crash_dump: Read the number of dm-crypt keys from reserved memory Coiby Xu
2026-09-09 0:52 ` sashiko-bot
2026-09-09 0:36 ` [PATCH v5 3/9] crash_dump: Disallow writing to dm-crypt configfs during kexec_file_load syscall Coiby Xu
2026-09-09 0:47 ` sashiko-bot [this message]
2026-09-09 13:29 ` Coiby Xu
2026-09-09 0:36 ` [PATCH v5 4/9] crash_dump: Free temporary dm-crypt keys_header buffer in kdump kernel Coiby Xu
2026-09-09 0:46 ` sashiko-bot
2026-09-09 0:36 ` [PATCH v5 5/9] crash_dump: Only use kexec_dprintk during the kexec_file_load syscall Coiby Xu
2026-09-09 0:47 ` sashiko-bot
2026-09-09 0:36 ` [PATCH v5 6/9] crash_dump: Improve readability of config_keys_restore_store Coiby Xu
2026-09-09 0:45 ` sashiko-bot
2026-09-09 0:36 ` [PATCH v5 7/9] crash_dump: Check the function return codes in restore_dm_crypt_keys_to_thread_keyring Coiby Xu
2026-09-09 0:49 ` sashiko-bot
2026-09-09 0:36 ` [PATCH v5 8/9] crash_dump: Disallow configfs/crash_dm_crypt_key/reuse if crash hotplug supported Coiby Xu
2026-09-09 0:53 ` sashiko-bot
2026-09-09 5:46 ` Randy Dunlap
2026-09-09 13:33 ` Coiby Xu
2026-09-09 0:36 ` [PATCH v5 9/9] Documentation: kdump: Add arm64 and ppc64le to encrypted dump target support list Coiby Xu
2026-09-09 0:38 ` sashiko-bot
2026-09-09 5:48 ` Randy Dunlap
2026-09-09 13:34 ` Coiby Xu
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=20260909004722.649E21F00A3A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=baoquan.he@linux.dev \
--cc=coiby.xu@gmail.com \
--cc=kexec@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pasha.tatashin@soleen.com \
--cc=pratyush@kernel.org \
--cc=rppt@kernel.org \
--cc=ruanjinjie@huawei.com \
--cc=ruirui.yang@linux.dev \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sourabhjain@linux.ibm.com \
--cc=will@kernel.org \
/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
all inboxes | Powered by JetHome®