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: <uuuwhh4rhq54owh52oudxirvkyxk2tfmej2dgbvdzq4refnofg@jf264hprcxal>
Date: Fri, 24 May 2024 15:43:23 +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>, 
	Thomas Gleixner <tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>, 
	Dave Hansen <dave.hansen@...ux.intel.com>, "H. Peter Anvin" <hpa@...or.com>
Subject: Re: [PATCH v3 7/7] x86/crash: make the page that stores the dm crypt
 keys inaccessible

On Tue, May 21, 2024 at 11:51:00AM +0800, Baoquan He wrote:
>On 04/25/24 at 06:04pm, Coiby Xu wrote:
>> This adds an addition layer of protection for the saved copy of dm
>> crypt key. Trying to access the saved copy will cause page fault.
>>
>> Suggested-by: Pingfan Liu <kernelfans@...il.com>
>> Signed-off-by: Coiby Xu <coxu@...hat.com>
>> ---
>>  arch/x86/kernel/machine_kexec_64.c | 21 +++++++++++++++++++++
>>  1 file changed, 21 insertions(+)
>>
>> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
>> index b180d8e497c3..fc0a80f4254e 100644
>> --- a/arch/x86/kernel/machine_kexec_64.c
>> +++ b/arch/x86/kernel/machine_kexec_64.c
>> @@ -545,13 +545,34 @@ static void kexec_mark_crashkres(bool protect)
>>  	kexec_mark_range(control, crashk_res.end, protect);
>>  }
>>
>> +static void kexec_mark_dm_crypt_keys(bool protect)
>> +{
>> +	unsigned long start_paddr, end_paddr;
>> +	unsigned int nr_pages;
>> +
>> +	if (kexec_crash_image->dm_crypt_keys_addr) {
>> +		start_paddr = kexec_crash_image->dm_crypt_keys_addr;
>> +		end_paddr = start_paddr + kexec_crash_image->dm_crypt_keys_sz - 1;
>> +		nr_pages = (PAGE_ALIGN(end_paddr) - PAGE_ALIGN_DOWN(start_paddr))/PAGE_SIZE;
>> +		if (protect)
>> +			set_memory_np((unsigned long)phys_to_virt(start_paddr), nr_pages);
>> +		else
>> +			__set_memory_prot(
>> +				(unsigned long)phys_to_virt(start_paddr),
>> +				nr_pages,
>> +				__pgprot(_PAGE_PRESENT | _PAGE_NX | _PAGE_RW));
>> +	}
>> +}
>> +
>>  void arch_kexec_protect_crashkres(void)
>>  {
>>  	kexec_mark_crashkres(true);
>> +	kexec_mark_dm_crypt_keys(true);
>
>Really? Are all x86 systems having this dm_crypt_keys and need be
>handled in kdump?

I'm not sure if I understand the above question correctly. But
kexec_mark_dm_crypt_keys will only take effect when there are
dm_crypt_keys because there is a check on
kexec_crash_image->dm_crypt_keys_addr.

-- 
Best regards,
Coiby


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ