[PATCH v6 3/7] crash_dump: store dm crypt keys in kdump reserved memory
Baoquan He
bhe at redhat.com
Wed Dec 11 04:58:27 PST 2024
On 10/29/24 at 01:52pm, Coiby Xu wrote:
......
> +int crash_load_dm_crypt_keys(struct kimage *image)
> +{
> + struct kexec_buf kbuf = {
> + .image = image,
> + .buf_min = 0,
> + .buf_max = ULONG_MAX,
> + .top_down = false,
> + .random = true,
> + };
> + int r;
> +
> +
> + if (key_count <= 0) {
> + kexec_dprintk("No dm-crypt keys\n");
> + return -EINVAL;
> + }
> +
> + image->dm_crypt_keys_addr = 0;
> + r = build_keys_header();
> + if (r)
> + return r;
> +
> + kbuf.buffer = keys_header;
> + kbuf.bufsz = get_keys_header_size(key_count);
> +
> + kbuf.memsz = kbuf.bufsz;
> + kbuf.buf_align = ELF_CORE_HEADER_ALIGN;
> + kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
> + r = kexec_add_buffer(&kbuf);
> + if (r) {
> + kvfree((void *)kbuf.buffer);
> + return r;
> + }
> + image->dm_crypt_keys_addr = kbuf.mem;
> + image->dm_crypt_keys_sz = kbuf.bufsz;
Wondering why not assigning kbuf.memsz, but bufsz.
> + kexec_dprintk(
> + "Loaded dm crypt keys to kexec_buffer bufsz=0x%lx memsz=0x%lx\n",
> + kbuf.bufsz, kbuf.bufsz);
> +
> + return r;
> +}
> +
> +
> static int __init configfs_dmcrypt_keys_init(void)
> {
> int ret;
> --
> 2.47.0
>
More information about the kexec
mailing list