lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <lzulibhdxvlhqdsszxcrejjcdbzwb4643nlqtd2hh6nbjb5mz4@ky2jhelzy4md>
Date: Mon, 23 Dec 2024 09:05:41 +0800
From: Coiby Xu <coxu@...hat.com>
To: Baoquan He <bhe@...hat.com>
Cc: kexec@...ts.infradead.org, Ondrej Kozina <okozina@...hat.com>, 
	Milan Broz <gmazyland@...il.com>, Thomas Staudt <tstaudt@...ibm.com>, 
	Daniel P . Berrangé <berrange@...hat.com>, Kairui Song <ryncsn@...il.com>, 
	Jan Pazdziora <jpazdziora@...hat.com>, Pingfan Liu <kernelfans@...il.com>, 
	Dave Young <dyoung@...hat.com>, linux-kernel@...r.kernel.org, x86@...nel.org, 
	Dave Hansen <dave.hansen@...el.com>, Vitaly Kuznetsov <vkuznets@...hat.com>, 
	Greg KH <gregkh@...uxfoundation.org>, Vivek Goyal <vgoyal@...hat.com>, 
	Eric Biederman <ebiederm@...ssion.com>, Kees Cook <kees@...nel.org>, 
	"Gustavo A. R. Silva" <gustavoars@...nel.org>, 
	"open list:KERNEL HARDENING (not covered by other areas):Keyword:b__counted_byb" <linux-hardening@...r.kernel.org>
Subject: Re: [PATCH v6 3/7] crash_dump: store dm crypt keys in kdump reserved
 memory

On Wed, Dec 11, 2024 at 08:58:27PM +0800, Baoquan He wrote:
>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.

Thanks for the question! I think there is no need to use kbuf.memsz
after reading the code on setting image->elf_headers_sz. Currently all
arches except for x86 CONFIG_CRASH_HOTPLUG assigns kbuf.bufsz to
image->elf_headers_sz. For x86 CONFIG_CRASH_HOTPLUG, if I understand it
correctly, it assigns kbuf.memsz to kbuf.memsz because elfcorehdr
changes when there is memory/CPU hot-plugging. For dm crypt keys, there
is no so such concern, so assigning kbuf.bufsz shall be OK.

-- 
Best regards,
Coiby


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ