[PATCH v4 3/7] crash_dump: store dm keys in kdump reserved memory

Coiby Xu posted 7 patches 1 year, 8 months ago
There is a newer version of this series
[PATCH v4 3/7] crash_dump: store dm keys in kdump reserved memory
Posted by Coiby Xu 1 year, 8 months ago
When the kdump kernel image and initrd are loaded, the dm crypts keys
will be read from keyring and then stored in kdump reserved memory.

Signed-off-by: Coiby Xu <coxu@redhat.com>
---
 include/linux/crash_core.h   |  3 ++
 include/linux/crash_dump.h   |  2 +
 include/linux/kexec.h        |  4 ++
 kernel/crash_dump_dm_crypt.c | 87 ++++++++++++++++++++++++++++++++++++
 4 files changed, 96 insertions(+)

diff --git a/include/linux/crash_core.h b/include/linux/crash_core.h
index 6bff1c24efa3..ab20829d0bc9 100644
--- a/include/linux/crash_core.h
+++ b/include/linux/crash_core.h
@@ -37,6 +37,9 @@ static inline void arch_kexec_unprotect_crashkres(void) { }
 #ifdef CONFIG_CRASH_DM_CRYPT
 int crash_sysfs_dm_crypt_keys_read(char *buf);
 int crash_sysfs_dm_crypt_keys_write(const char *buf, size_t count);
+int crash_load_dm_crypt_keys(struct kimage *image);
+#else
+static inline int crash_load_dm_crypt_keys(struct kimage *image) {return 0; }
 #endif
 
 #ifndef arch_crash_handle_hotplug_event
diff --git a/include/linux/crash_dump.h b/include/linux/crash_dump.h
index acc55626afdc..dfd8e4fe6129 100644
--- a/include/linux/crash_dump.h
+++ b/include/linux/crash_dump.h
@@ -15,6 +15,8 @@
 extern unsigned long long elfcorehdr_addr;
 extern unsigned long long elfcorehdr_size;
 
+extern unsigned long long dm_crypt_keys_addr;
+
 #ifdef CONFIG_CRASH_DUMP
 extern int elfcorehdr_alloc(unsigned long long *addr, unsigned long long *size);
 extern void elfcorehdr_free(unsigned long long addr);
diff --git a/include/linux/kexec.h b/include/linux/kexec.h
index cc81b8a903ab..bd40f4208e1f 100644
--- a/include/linux/kexec.h
+++ b/include/linux/kexec.h
@@ -370,6 +370,10 @@ struct kimage {
 	void *elf_headers;
 	unsigned long elf_headers_sz;
 	unsigned long elf_load_addr;
+
+	/* dm crypt keys buffer */
+	unsigned long dm_crypt_keys_addr;
+	unsigned long dm_crypt_keys_sz;
 };
 
 /* kexec interface functions */
diff --git a/kernel/crash_dump_dm_crypt.c b/kernel/crash_dump_dm_crypt.c
index 78809189084a..89fec768fba8 100644
--- a/kernel/crash_dump_dm_crypt.c
+++ b/kernel/crash_dump_dm_crypt.c
@@ -1,4 +1,6 @@
 // SPDX-License-Identifier: GPL-2.0-only
+#include <linux/key.h>
+#include <linux/keyctl.h>
 #include <keys/user-type.h>
 #include <linux/crash_dump.h>
 
@@ -111,3 +113,88 @@ int crash_sysfs_dm_crypt_keys_read(char *buf)
 	return sprintf(buf, "%s\n", STATE_STR[state]);
 }
 EXPORT_SYMBOL(crash_sysfs_dm_crypt_keys_read);
+
+static int read_key_from_user_keying(struct dm_crypt_key *dm_key)
+{
+	const struct user_key_payload *ukp;
+	struct key *key;
+
+	pr_debug("Requesting key %s", dm_key->key_desc);
+	key = request_key(&key_type_logon, dm_key->key_desc, NULL);
+
+	if (IS_ERR(key)) {
+		pr_warn("No such key %s\n", dm_key->key_desc);
+		return PTR_ERR(key);
+	}
+
+	ukp = user_key_payload_locked(key);
+	if (!ukp)
+		return -EKEYREVOKED;
+
+	memcpy(dm_key->data, ukp->data, ukp->datalen);
+	dm_key->key_size = ukp->datalen;
+	pr_debug("Get dm crypt key (size=%u) %s: %8ph\n", dm_key->key_size,
+		 dm_key->key_desc, dm_key->data);
+	return 0;
+}
+
+static int build_keys_header(void)
+{
+	int i, r;
+
+	for (i = 0; i < key_count; i++) {
+		r = read_key_from_user_keying(&keys_header->keys[i]);
+		if (r != 0) {
+			pr_err("Failed to read key %s\n", keys_header->keys[i].key_desc);
+			return r;
+		}
+	}
+
+	return 0;
+}
+
+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 (state == FRESH)
+		return 0;
+
+	if (key_count != keys_header->key_count) {
+		pr_err("Only record %u keys (%u in total)\n", key_count,
+		       keys_header->key_count);
+		return -EINVAL;
+	}
+
+	image->dm_crypt_keys_addr = 0;
+	r = build_keys_header();
+	if (r)
+		return r;
+
+	kbuf.buffer = keys_header;
+	kbuf.bufsz = keys_header_size;
+
+	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;
+	}
+	state = LOADED;
+	image->dm_crypt_keys_addr = kbuf.mem;
+	image->dm_crypt_keys_sz = kbuf.bufsz;
+	pr_debug("Loaded dm crypt keys at 0x%lx bufsz=0x%lx memsz=0x%lx\n",
+		 image->dm_crypt_keys_addr, kbuf.bufsz, kbuf.bufsz);
+
+	return r;
+}
-- 
2.45.0
Re: [PATCH v4 3/7] crash_dump: store dm keys in kdump reserved memory
Posted by kernel test robot 1 year, 8 months ago
Hi Coiby,

kernel test robot noticed the following build errors:

[auto build test ERROR on de7e71ef8bed222dd144d8878091ecb6d5dfd208]

url:    https://github.com/intel-lab-lkp/linux/commits/Coiby-Xu/kexec_file-allow-to-place-kexec_buf-randomly/20240523-130727
base:   de7e71ef8bed222dd144d8878091ecb6d5dfd208
patch link:    https://lore.kernel.org/r/20240523050451.788754-4-coxu%40redhat.com
patch subject: [PATCH v4 3/7] crash_dump: store dm keys in kdump reserved memory
config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20240524/202405241012.KlmCbp77-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240524/202405241012.KlmCbp77-lkp@intel.com/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 <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405241012.KlmCbp77-lkp@intel.com/

All errors (new ones prefixed by >>):

   kernel/crash_dump_dm_crypt.c: In function 'crash_load_dm_crypt_keys':
>> kernel/crash_dump_dm_crypt.c:158:16: error: variable 'kbuf' has initializer but incomplete type
     158 |         struct kexec_buf kbuf = {
         |                ^~~~~~~~~
>> kernel/crash_dump_dm_crypt.c:159:18: error: 'struct kexec_buf' has no member named 'image'
     159 |                 .image = image,
         |                  ^~~~~
   kernel/crash_dump_dm_crypt.c:159:26: warning: excess elements in struct initializer
     159 |                 .image = image,
         |                          ^~~~~
   kernel/crash_dump_dm_crypt.c:159:26: note: (near initialization for 'kbuf')
>> kernel/crash_dump_dm_crypt.c:160:18: error: 'struct kexec_buf' has no member named 'buf_min'
     160 |                 .buf_min = 0,
         |                  ^~~~~~~
   kernel/crash_dump_dm_crypt.c:160:28: warning: excess elements in struct initializer
     160 |                 .buf_min = 0,
         |                            ^
   kernel/crash_dump_dm_crypt.c:160:28: note: (near initialization for 'kbuf')
>> kernel/crash_dump_dm_crypt.c:161:18: error: 'struct kexec_buf' has no member named 'buf_max'
     161 |                 .buf_max = ULONG_MAX,
         |                  ^~~~~~~
   In file included from include/linux/limits.h:7,
                    from include/linux/thread_info.h:12,
                    from include/asm-generic/preempt.h:5,
                    from ./arch/arm/include/generated/asm/preempt.h:1,
                    from include/linux/preempt.h:79,
                    from include/linux/rcupdate.h:27,
                    from include/linux/rbtree.h:24,
                    from include/linux/key.h:15,
                    from kernel/crash_dump_dm_crypt.c:2:
   include/vdso/limits.h:13:25: warning: excess elements in struct initializer
      13 | #define ULONG_MAX       (~0UL)
         |                         ^
   kernel/crash_dump_dm_crypt.c:161:28: note: in expansion of macro 'ULONG_MAX'
     161 |                 .buf_max = ULONG_MAX,
         |                            ^~~~~~~~~
   include/vdso/limits.h:13:25: note: (near initialization for 'kbuf')
      13 | #define ULONG_MAX       (~0UL)
         |                         ^
   kernel/crash_dump_dm_crypt.c:161:28: note: in expansion of macro 'ULONG_MAX'
     161 |                 .buf_max = ULONG_MAX,
         |                            ^~~~~~~~~
>> kernel/crash_dump_dm_crypt.c:162:18: error: 'struct kexec_buf' has no member named 'top_down'
     162 |                 .top_down = false,
         |                  ^~~~~~~~
   kernel/crash_dump_dm_crypt.c:162:29: warning: excess elements in struct initializer
     162 |                 .top_down = false,
         |                             ^~~~~
   kernel/crash_dump_dm_crypt.c:162:29: note: (near initialization for 'kbuf')
>> kernel/crash_dump_dm_crypt.c:163:18: error: 'struct kexec_buf' has no member named 'random'
     163 |                 .random = true,
         |                  ^~~~~~
   kernel/crash_dump_dm_crypt.c:163:27: warning: excess elements in struct initializer
     163 |                 .random = true,
         |                           ^~~~
   kernel/crash_dump_dm_crypt.c:163:27: note: (near initialization for 'kbuf')
>> kernel/crash_dump_dm_crypt.c:158:26: error: storage size of 'kbuf' isn't known
     158 |         struct kexec_buf kbuf = {
         |                          ^~~~
>> kernel/crash_dump_dm_crypt.c:187:20: error: 'KEXEC_BUF_MEM_UNKNOWN' undeclared (first use in this function)
     187 |         kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
         |                    ^~~~~~~~~~~~~~~~~~~~~
   kernel/crash_dump_dm_crypt.c:187:20: note: each undeclared identifier is reported only once for each function it appears in
>> kernel/crash_dump_dm_crypt.c:188:13: error: implicit declaration of function 'kexec_add_buffer' [-Werror=implicit-function-declaration]
     188 |         r = kexec_add_buffer(&kbuf);
         |             ^~~~~~~~~~~~~~~~
   kernel/crash_dump_dm_crypt.c:158:26: warning: unused variable 'kbuf' [-Wunused-variable]
     158 |         struct kexec_buf kbuf = {
         |                          ^~~~
   cc1: some warnings being treated as errors


vim +/kbuf +158 kernel/crash_dump_dm_crypt.c

   155	
   156	int crash_load_dm_crypt_keys(struct kimage *image)
   157	{
 > 158		struct kexec_buf kbuf = {
 > 159			.image = image,
 > 160			.buf_min = 0,
 > 161			.buf_max = ULONG_MAX,
 > 162			.top_down = false,
 > 163			.random = true,
   164		};
   165	
   166		int r;
   167	
   168		if (state == FRESH)
   169			return 0;
   170	
   171		if (key_count != keys_header->key_count) {
   172			pr_err("Only record %u keys (%u in total)\n", key_count,
   173			       keys_header->key_count);
   174			return -EINVAL;
   175		}
   176	
   177		image->dm_crypt_keys_addr = 0;
   178		r = build_keys_header();
   179		if (r)
   180			return r;
   181	
   182		kbuf.buffer = keys_header;
   183		kbuf.bufsz = keys_header_size;
   184	
   185		kbuf.memsz = kbuf.bufsz;
   186		kbuf.buf_align = ELF_CORE_HEADER_ALIGN;
 > 187		kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
 > 188		r = kexec_add_buffer(&kbuf);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
Re: [PATCH v4 3/7] crash_dump: store dm keys in kdump reserved memory
Posted by Baoquan He 1 year, 8 months ago
Hi Coiby,

On 05/24/24 at 11:17am, kernel test robot wrote:
> Hi Coiby,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on de7e71ef8bed222dd144d8878091ecb6d5dfd208]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Coiby-Xu/kexec_file-allow-to-place-kexec_buf-randomly/20240523-130727
> base:   de7e71ef8bed222dd144d8878091ecb6d5dfd208
> patch link:    https://lore.kernel.org/r/20240523050451.788754-4-coxu%40redhat.com
> patch subject: [PATCH v4 3/7] crash_dump: store dm keys in kdump reserved memory
> config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20240524/202405241012.KlmCbp77-lkp@intel.com/config)
> compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240524/202405241012.KlmCbp77-lkp@intel.com/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 <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202405241012.KlmCbp77-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):

Please respond to lkp report sooner, otherwise the reproducer link could
be unavailable.

> 
>    kernel/crash_dump_dm_crypt.c: In function 'crash_load_dm_crypt_keys':
> >> kernel/crash_dump_dm_crypt.c:158:16: error: variable 'kbuf' has initializer but incomplete type
>      158 |         struct kexec_buf kbuf = {
>          |                ^~~~~~~~~
> >> kernel/crash_dump_dm_crypt.c:159:18: error: 'struct kexec_buf' has no member named 'image'
>      159 |                 .image = image,
>          |                  ^~~~~
>    kernel/crash_dump_dm_crypt.c:159:26: warning: excess elements in struct initializer
>      159 |                 .image = image,
>          |                          ^~~~~
>    kernel/crash_dump_dm_crypt.c:159:26: note: (near initialization for 'kbuf')
> >> kernel/crash_dump_dm_crypt.c:160:18: error: 'struct kexec_buf' has no member named 'buf_min'
>      160 |                 .buf_min = 0,
>          |                  ^~~~~~~
>    kernel/crash_dump_dm_crypt.c:160:28: warning: excess elements in struct initializer
>      160 |                 .buf_min = 0,
>          |                            ^
>    kernel/crash_dump_dm_crypt.c:160:28: note: (near initialization for 'kbuf')
> >> kernel/crash_dump_dm_crypt.c:161:18: error: 'struct kexec_buf' has no member named 'buf_max'
>      161 |                 .buf_max = ULONG_MAX,
>          |                  ^~~~~~~
>    In file included from include/linux/limits.h:7,
>                     from include/linux/thread_info.h:12,
>                     from include/asm-generic/preempt.h:5,
>                     from ./arch/arm/include/generated/asm/preempt.h:1,
>                     from include/linux/preempt.h:79,
>                     from include/linux/rcupdate.h:27,
>                     from include/linux/rbtree.h:24,
>                     from include/linux/key.h:15,
>                     from kernel/crash_dump_dm_crypt.c:2:
>    include/vdso/limits.h:13:25: warning: excess elements in struct initializer
>       13 | #define ULONG_MAX       (~0UL)
>          |                         ^
>    kernel/crash_dump_dm_crypt.c:161:28: note: in expansion of macro 'ULONG_MAX'
>      161 |                 .buf_max = ULONG_MAX,
>          |                            ^~~~~~~~~
>    include/vdso/limits.h:13:25: note: (near initialization for 'kbuf')
>       13 | #define ULONG_MAX       (~0UL)
>          |                         ^
>    kernel/crash_dump_dm_crypt.c:161:28: note: in expansion of macro 'ULONG_MAX'
>      161 |                 .buf_max = ULONG_MAX,
>          |                            ^~~~~~~~~
> >> kernel/crash_dump_dm_crypt.c:162:18: error: 'struct kexec_buf' has no member named 'top_down'
>      162 |                 .top_down = false,
>          |                  ^~~~~~~~
>    kernel/crash_dump_dm_crypt.c:162:29: warning: excess elements in struct initializer
>      162 |                 .top_down = false,
>          |                             ^~~~~
>    kernel/crash_dump_dm_crypt.c:162:29: note: (near initialization for 'kbuf')
> >> kernel/crash_dump_dm_crypt.c:163:18: error: 'struct kexec_buf' has no member named 'random'
>      163 |                 .random = true,
>          |                  ^~~~~~
>    kernel/crash_dump_dm_crypt.c:163:27: warning: excess elements in struct initializer
>      163 |                 .random = true,
>          |                           ^~~~
>    kernel/crash_dump_dm_crypt.c:163:27: note: (near initialization for 'kbuf')
> >> kernel/crash_dump_dm_crypt.c:158:26: error: storage size of 'kbuf' isn't known
>      158 |         struct kexec_buf kbuf = {
>          |                          ^~~~
> >> kernel/crash_dump_dm_crypt.c:187:20: error: 'KEXEC_BUF_MEM_UNKNOWN' undeclared (first use in this function)
>      187 |         kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
>          |                    ^~~~~~~~~~~~~~~~~~~~~
>    kernel/crash_dump_dm_crypt.c:187:20: note: each undeclared identifier is reported only once for each function it appears in
> >> kernel/crash_dump_dm_crypt.c:188:13: error: implicit declaration of function 'kexec_add_buffer' [-Werror=implicit-function-declaration]
>      188 |         r = kexec_add_buffer(&kbuf);
>          |             ^~~~~~~~~~~~~~~~
>    kernel/crash_dump_dm_crypt.c:158:26: warning: unused variable 'kbuf' [-Wunused-variable]
>      158 |         struct kexec_buf kbuf = {
>          |                          ^~~~
>    cc1: some warnings being treated as errors
> 
> 
> vim +/kbuf +158 kernel/crash_dump_dm_crypt.c
> 
>    155	
>    156	int crash_load_dm_crypt_keys(struct kimage *image)
>    157	{
>  > 158		struct kexec_buf kbuf = {
>  > 159			.image = image,
>  > 160			.buf_min = 0,
>  > 161			.buf_max = ULONG_MAX,
>  > 162			.top_down = false,
>  > 163			.random = true,
>    164		};
>    165	
>    166		int r;
>    167	
>    168		if (state == FRESH)
>    169			return 0;
>    170	
>    171		if (key_count != keys_header->key_count) {
>    172			pr_err("Only record %u keys (%u in total)\n", key_count,
>    173			       keys_header->key_count);
>    174			return -EINVAL;
>    175		}
>    176	
>    177		image->dm_crypt_keys_addr = 0;
>    178		r = build_keys_header();
>    179		if (r)
>    180			return r;
>    181	
>    182		kbuf.buffer = keys_header;
>    183		kbuf.bufsz = keys_header_size;
>    184	
>    185		kbuf.memsz = kbuf.bufsz;
>    186		kbuf.buf_align = ELF_CORE_HEADER_ALIGN;
>  > 187		kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
>  > 188		r = kexec_add_buffer(&kbuf);
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
>
Re: [PATCH v4 3/7] crash_dump: store dm keys in kdump reserved memory
Posted by Coiby Xu 1 year, 8 months ago
On Tue, Jun 04, 2024 at 09:54:26PM +0800, Baoquan He wrote:
>Hi Coiby,

Hi Baoquan,

>
>On 05/24/24 at 11:17am, kernel test robot wrote:
>> Hi Coiby,
>>
>> kernel test robot noticed the following build errors:
>>
>> [auto build test ERROR on de7e71ef8bed222dd144d8878091ecb6d5dfd208]
>>
>> url:    https://github.com/intel-lab-lkp/linux/commits/Coiby-Xu/kexec_file-allow-to-place-kexec_buf-randomly/20240523-130727
>> base:   de7e71ef8bed222dd144d8878091ecb6d5dfd208
>> patch link:    https://lore.kernel.org/r/20240523050451.788754-4-coxu%40redhat.com
>> patch subject: [PATCH v4 3/7] crash_dump: store dm keys in kdump reserved memory
>> config: arm-allmodconfig (https://download.01.org/0day-ci/archive/20240524/202405241012.KlmCbp77-lkp@intel.com/config)
>> compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
>> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240524/202405241012.KlmCbp77-lkp@intel.com/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 <lkp@intel.com>
>> | Closes: https://lore.kernel.org/oe-kbuild-all/202405241012.KlmCbp77-lkp@intel.com/
>>
>> All errors (new ones prefixed by >>):
>
>Please respond to lkp report sooner, otherwise the reproducer link could
>be unavailable.

Thanks for the reminder! I believe these errors are false positives
because 1) include/linux/kexec.h is included after "#include <linux/crash_dump.h>"
and 2) similar errors are seen for kernel/kexec_file.c by 
"make ARCH=arm CROSS_COMPILE=arm-linux-gnu- kernel/kexec_file.o"

>
>>
>>    kernel/crash_dump_dm_crypt.c: In function 'crash_load_dm_crypt_keys':
>> >> kernel/crash_dump_dm_crypt.c:158:16: error: variable 'kbuf' has initializer but incomplete type
>>      158 |         struct kexec_buf kbuf = {
>>          |                ^~~~~~~~~
>> >> kernel/crash_dump_dm_crypt.c:159:18: error: 'struct kexec_buf' has no member named 'image'
>>      159 |                 .image = image,
>>          |                  ^~~~~
>>    kernel/crash_dump_dm_crypt.c:159:26: warning: excess elements in struct initializer
>>      159 |                 .image = image,
>>          |                          ^~~~~
>>    kernel/crash_dump_dm_crypt.c:159:26: note: (near initialization for 'kbuf')
>> >> kernel/crash_dump_dm_crypt.c:160:18: error: 'struct kexec_buf' has no member named 'buf_min'
>>      160 |                 .buf_min = 0,
>>          |                  ^~~~~~~
>>    kernel/crash_dump_dm_crypt.c:160:28: warning: excess elements in struct initializer
>>      160 |                 .buf_min = 0,
>>          |                            ^
>>    kernel/crash_dump_dm_crypt.c:160:28: note: (near initialization for 'kbuf')
>> >> kernel/crash_dump_dm_crypt.c:161:18: error: 'struct kexec_buf' has no member named 'buf_max'
>>      161 |                 .buf_max = ULONG_MAX,
>>          |                  ^~~~~~~
>>    In file included from include/linux/limits.h:7,
>>                     from include/linux/thread_info.h:12,
>>                     from include/asm-generic/preempt.h:5,
>>                     from ./arch/arm/include/generated/asm/preempt.h:1,
>>                     from include/linux/preempt.h:79,
>>                     from include/linux/rcupdate.h:27,
>>                     from include/linux/rbtree.h:24,
>>                     from include/linux/key.h:15,
>>                     from kernel/crash_dump_dm_crypt.c:2:
>>    include/vdso/limits.h:13:25: warning: excess elements in struct initializer
>>       13 | #define ULONG_MAX       (~0UL)
>>          |                         ^
>>    kernel/crash_dump_dm_crypt.c:161:28: note: in expansion of macro 'ULONG_MAX'
>>      161 |                 .buf_max = ULONG_MAX,
>>          |                            ^~~~~~~~~
>>    include/vdso/limits.h:13:25: note: (near initialization for 'kbuf')
>>       13 | #define ULONG_MAX       (~0UL)
>>          |                         ^
>>    kernel/crash_dump_dm_crypt.c:161:28: note: in expansion of macro 'ULONG_MAX'
>>      161 |                 .buf_max = ULONG_MAX,
>>          |                            ^~~~~~~~~
>> >> kernel/crash_dump_dm_crypt.c:162:18: error: 'struct kexec_buf' has no member named 'top_down'
>>      162 |                 .top_down = false,
>>          |                  ^~~~~~~~
>>    kernel/crash_dump_dm_crypt.c:162:29: warning: excess elements in struct initializer
>>      162 |                 .top_down = false,
>>          |                             ^~~~~
>>    kernel/crash_dump_dm_crypt.c:162:29: note: (near initialization for 'kbuf')
>> >> kernel/crash_dump_dm_crypt.c:163:18: error: 'struct kexec_buf' has no member named 'random'
>>      163 |                 .random = true,
>>          |                  ^~~~~~
>>    kernel/crash_dump_dm_crypt.c:163:27: warning: excess elements in struct initializer
>>      163 |                 .random = true,
>>          |                           ^~~~
>>    kernel/crash_dump_dm_crypt.c:163:27: note: (near initialization for 'kbuf')
>> >> kernel/crash_dump_dm_crypt.c:158:26: error: storage size of 'kbuf' isn't known
>>      158 |         struct kexec_buf kbuf = {
>>          |                          ^~~~
>> >> kernel/crash_dump_dm_crypt.c:187:20: error: 'KEXEC_BUF_MEM_UNKNOWN' undeclared (first use in this function)
>>      187 |         kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
>>          |                    ^~~~~~~~~~~~~~~~~~~~~
>>    kernel/crash_dump_dm_crypt.c:187:20: note: each undeclared identifier is reported only once for each function it appears in
>> >> kernel/crash_dump_dm_crypt.c:188:13: error: implicit declaration of function 'kexec_add_buffer' [-Werror=implicit-function-declaration]
>>      188 |         r = kexec_add_buffer(&kbuf);
>>          |             ^~~~~~~~~~~~~~~~
>>    kernel/crash_dump_dm_crypt.c:158:26: warning: unused variable 'kbuf' [-Wunused-variable]
>>      158 |         struct kexec_buf kbuf = {
>>          |                          ^~~~
>>    cc1: some warnings being treated as errors
>>
>>
>> vim +/kbuf +158 kernel/crash_dump_dm_crypt.c
>>
>>    155	
>>    156	int crash_load_dm_crypt_keys(struct kimage *image)
>>    157	{
>>  > 158		struct kexec_buf kbuf = {
>>  > 159			.image = image,
>>  > 160			.buf_min = 0,
>>  > 161			.buf_max = ULONG_MAX,
>>  > 162			.top_down = false,
>>  > 163			.random = true,
>>    164		};
>>    165	
>>    166		int r;
>>    167	
>>    168		if (state == FRESH)
>>    169			return 0;
>>    170	
>>    171		if (key_count != keys_header->key_count) {
>>    172			pr_err("Only record %u keys (%u in total)\n", key_count,
>>    173			       keys_header->key_count);
>>    174			return -EINVAL;
>>    175		}
>>    176	
>>    177		image->dm_crypt_keys_addr = 0;
>>    178		r = build_keys_header();
>>    179		if (r)
>>    180			return r;
>>    181	
>>    182		kbuf.buffer = keys_header;
>>    183		kbuf.bufsz = keys_header_size;
>>    184	
>>    185		kbuf.memsz = kbuf.bufsz;
>>    186		kbuf.buf_align = ELF_CORE_HEADER_ALIGN;
>>  > 187		kbuf.mem = KEXEC_BUF_MEM_UNKNOWN;
>>  > 188		r = kexec_add_buffer(&kbuf);
>>
>> --
>> 0-DAY CI Kernel Test Service
>> https://github.com/intel/lkp-tests/wiki
>>
>

-- 
Best regards,
Coiby