s390x/kdump: pass dm-crypt keys to kdump kernel
Subsystems (4)
RFC 1/1 s390x/kdump: pass dm-crypt keys to kdump kernel
CONFIG_CRASH_DM_CRYPT has been introduced to support LUKS-encrypted device dump target by addressing two challenges [1][2],
- Kdump kernel may not be able to decrypt the LUKS partition. For some machines, a system administrator may not have a chance to enter the password to decrypt the device in kdump initramfs after the 1st kernel crashes
- LUKS2 by default use the memory-hard Argon2 key derivation function which is quite memory-consuming compared to the limited memory reserved for kdump.
To also enable this feature for s390X, we only need to build up the kernel command parameter dmcryptkeys=<addr> to pass the memory address of the stored info of dm-crypt keys to kdump kernel. Unlike other architectures e.g. x86_64, the memory storing the dm-crypt keys won't be reserved automatically. So also pass the dmcryptkeys_size kernel parameter to kdump kernel so the memory can be reserved.
Since dm-crypt keys are sensitive data, it will be more secure to place them in a random way. However the only two ways I can find so far is to put the keys inside the following two regions,
1. [crashk_res.start + SZ_64M, crashk_res.start + SZ_64M + SZ_32M]
2. [data->memsz + SZ_64M, data->memsz + SZ_64M + SZ_4M]
Placing the keys in other regions randomly as bellow can crash the KVM machine immediately after triggering a kernel panic,
[data->memsz, data->memsz + SZ_4M]
[crashk_res.end - SZ_32M, crashk_res.end]And calling kexec_add_buffer/ipl_report_add_component after loading kernel image and initramfs doesn't help either.
So obviously I miss something about how kexec_add_buffer/ipl_report_add_component work in S390. Any advice will be appreciated! Thanks!
[1] https://lore.kernel.org/all/[email protected]/T/#u
[2] "Write the dump file to encrypted disk volume", Documentation/admin-guide/kdump/kdump.rst
--- arch/s390/kernel/crash_dump.c | 9 ++++ arch/s390/kernel/machine_kexec_file.c | 68 +++++++++++++++++++++++++-- kernel/crash_dump_dm_crypt.c | 54 +++++++++++++++------ 3 files changed, 114 insertions(+), 17 deletions(-)
arch/s390/kernel/crash_dump.c +9 -0
@@ -705,3 +705,12 @@ ssize_t elfcorehdr_read_notes(char *buf, size_t count, u64 *ppos) *ppos += count;return count; } + +ssize_t dm_crypt_keys_read (char *buf,size_t count,u64 *ppos) +{ +void *src =__va ((phys_addr_t )dm_crypt_keys_addr); + +memcpy (buf, src, count); + *ppos += count; +return count; +}
arch/s390/kernel/machine_kexec_file.c +65 -3
86 lines not on this page · raw message
kernel/crash_dump_dm_crypt.c +40 -14
74 lines not on this page · raw message
base-commit: 7f98ab9da046865d57c102fd3ca9669a29845f67
Signature · 1 line
2.52.0
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Coiby,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build warnings:
[auto build test WARNING on 7f98ab9da046865d57c102fd3ca9669a29845f67]
url: https://github.com/intel-lab-lkp/linux/commits/Coiby-Xu/s390x-kdump-pass-dm-crypt-keys-to-kdump-kernel/20260116-183709 base: 7f98ab9da046865d57c102fd3ca9669a29845f67 patch link: https://lore.kernel.org/r/20260116103347.523747-1-coxu%40redhat.com patch subject: [RFC] s390x/kdump: pass dm-crypt keys to kdump kernel config: s390-defconfig (https://download.01.org/0day-ci/archive/20260118/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260118/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> kernel/crash_dump_dm_crypt.c:55:6: warning: variable 'ret' set but not used [-Wunused-but-set-variable]
55 | int ret;
| ^
>> kernel/crash_dump_dm_crypt.c:432:6: warning: variable 'r' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
432 | if (!is_dm_key_reused) {
| ^~~~~~~~~~~~~~~~~
kernel/crash_dump_dm_crypt.c:461:9: note: uninitialized use occurs here
461 | return r;
| ^
kernel/crash_dump_dm_crypt.c:432:2: note: remove the 'if' if its condition is always true
432 | if (!is_dm_key_reused) {
| ^~~~~~~~~~~~~~~~~~~~~~
kernel/crash_dump_dm_crypt.c:424:7: note: initialize the variable 'r' to silence this warning
424 | int r;
| ^
| = 02 warnings generated.
vim +/ret +55 kernel/crash_dump_dm_crypt.c
51
52 static int __init setup_dmcryptkeys_size(char *arg)
53 {
54 size_t keys_size;
> 55 int ret;
56
57 if (dm_crypt_keys_addr == 0) {
58 pr_warn("dmcryptkeys=0\n");
59 return -EINVAL;
60 }
61
62 if (!arg)
63 return -EINVAL;
64
65 ret = kstrtoul(arg, 0, &keys_size);
66 memblock_reserve((phys_addr_t)dm_crypt_keys_addr, keys_size);
67 return 0;
68 }
69 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Coiby,
[This is a private test report for your RFC patch.] kernel test robot noticed the following build errors:
[auto build test ERROR on 7f98ab9da046865d57c102fd3ca9669a29845f67]
url: https://github.com/intel-lab-lkp/linux/commits/Coiby-Xu/s390x-kdump-pass-dm-crypt-keys-to-kdump-kernel/20260116-183709 base: 7f98ab9da046865d57c102fd3ca9669a29845f67 patch link: https://lore.kernel.org/r/20260116103347.523747-1-coxu%40redhat.com patch subject: [RFC] s390x/kdump: pass dm-crypt keys to kdump kernel config: s390-randconfig-002-20260118 (https://download.01.org/0day-ci/archive/20260118/[email protected]/config) compiler: clang version 22.0.0git (https://github.com/llvm/llvm-project 9b8addffa70cee5b2acc5454712d9cf78ce45710) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260118/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
>> ld.lld: error: undefined symbol: dm_crypt_keys_addr >>> referenced by crash_dump.c:0 (arch/s390/kernel/crash_dump.c:0) >>> arch/s390/kernel/crash_dump.o:(dm_crypt_keys_read) in archive vmlinux.a
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki