From: sashiko-bot@kernel.org
To: "Coiby Xu" <coiby.xu@gmail.com>
Cc: kexec@lists.infradead.org, "Will Deacon" <will@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Sourabh Jain" <sourabhjain@linux.ibm.com>,
"Jinjie Ruan" <ruanjinjie@huawei.com>,
"Dave Young" <ruirui.yang@linux.dev>,
"Baoquan He" <baoquan.he@linux.dev>,
"Pratyush Yadav" <pratyush@kernel.org>,
"Pasha Tatashin" <pasha.tatashin@soleen.com>,
linux-arm-kernel@lists.infradead.org,
"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v5 4/9] crash_dump: Free temporary dm-crypt keys_header buffer in kdump kernel
Date: Wed, 09 Sep 2026 00:46:05 +0000 [thread overview]
Message-ID: <20260909004606.2B4431F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260909003657.1570544-5-coiby.xu@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] Mixing goto-based cleanup labels with __free() scope-based cleanup in the same function.
Pre-existing issues:
- [High] Out-of-bounds memory read using kmap_local_page() for a multi-page buffer.
--
commit a9106b1595e8efc92f366f113d95f7f3216942f5
Author: Coiby Xu <coiby.xu@gmail.com>
crash_dump: Free temporary dm-crypt keys_header buffer in kdump kernel
Although we expect the system to reboot immediately after vmcore dumping
is finished, it's still good to free the temporary keys_header buffer.
Fixes: 62f17d9df692 ("crash_dump: retrieve dm crypt keys in kdump kernel")
Reported-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Reviewed-by: Sourabh Jain <sourabhjain@linux.ibm.com>
Signed-off-by: Coiby Xu <coiby.xu@gmail.com>
> diff --git a/kernel/crash_dump_dm_crypt.c b/kernel/crash_dump_dm_crypt.c
> index 580534d43b66e..ff6055a97a4b6 100644
> --- a/kernel/crash_dump_dm_crypt.c
> +++ b/kernel/crash_dump_dm_crypt.c
> @@ -118,6 +118,7 @@ static int get_keys_from_kdump_reserved_memory(void)
>
> static int restore_dm_crypt_keys_to_thread_keyring(void)
> {
> + struct keys_header *keys_header __free(kfree_sensitive) = NULL;
[Severity: Medium]
Does this code mix __free() scope-based cleanup with goto cleanup labels?
The function restore_dm_crypt_keys_to_thread_keyring() newly introduces
a __free() declaration for keys_header, but still contains a goto out block
at the end:
kernel/crash_dump_dm_crypt.c:restore_dm_crypt_keys_to_thread_keyring() {
...
out:
key_ref_put(keyring_ref);
return ret;
}
Mixing these two cleanup styles creates confusing ownership semantics and
increases the risk of double-frees or resource leaks when the code is
modified in the future.
[Severity: High]
This isn't a bug introduced by this patch, but does the adjacent function
get_keys_from_kdump_reserved_memory() read out-of-bounds?
It uses kmap_local_page() which only maps a single 4KB page, but memcpy()
copies keys_header_size bytes (which can be up to ~49KB) from it:
kernel/crash_dump_dm_crypt.c:get_keys_from_kdump_reserved_memory() {
...
keys_header_loaded = kmap_local_page(pfn_to_page(
kexec_crash_image->dm_crypt_keys_addr >> PAGE_SHIFT));
...
keys_header_size = get_keys_header_size(keys_header_loaded->total_keys);
...
memcpy(keys_header, keys_header_loaded, keys_header_size);
...
}
On high memory systems (e.g., 32-bit architectures), this will trigger a
kernel page fault or read garbage data if the total size of the keys exceeds
what fits in a single page.
> struct dm_crypt_key *key;
> size_t keys_header_size;
> key_ref_t keyring_ref;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260909003657.1570544-1-coiby.xu@gmail.com?part=4
next prev parent reply other threads:[~2026-09-09 0:46 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 0:36 [PATCH v5 0/9] Bug fixes and enhancements for kdump LUKS support Coiby Xu
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
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 [this message]
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=20260909004606.2B4431F00A3D@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 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.