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: <alpine.DEB.2.21.1809141414390.10480@nanos.tec.linutronix.de>
Date:   Fri, 14 Sep 2018 14:17:05 +0200 (CEST)
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Brijesh Singh <brijesh.singh@....com>
cc:     Borislav Petkov <bp@...e.de>, x86@...nel.org,
        linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
        Tom Lendacky <thomas.lendacky@....com>,
        "H. Peter Anvin" <hpa@...or.com>,
        Paolo Bonzini <pbonzini@...hat.com>,
        Sean Christopherson <sean.j.christopherson@...el.com>,
        Radim Krčmář <rkrcmar@...hat.com>
Subject: Re: [PATCH v8 1/2] x86/mm: add .bss..decrypted section to hold shared
 variables

On Fri, 14 Sep 2018, Brijesh Singh wrote:
> On 9/14/18 2:10 AM, Borislav Petkov wrote:
> >>  	/*
> >> +	 * Clear the memory encryption mask from the .bss..decrypted section.
> >> +	 * The bss section will be memset to zero later in the initialization so
> >> +	 * there is no need to zero it after changing the memory encryption
> >> +	 * attribute.
> >> +	 */
> >> +	if (mem_encrypt_active()) {
> >> +		vaddr = (unsigned long)__start_bss_decrypted;
> >> +		vaddr_end = (unsigned long)__end_bss_decrypted;
> >> +		for (; vaddr < vaddr_end; vaddr += PMD_SIZE) {
> >> +			i = pmd_index(vaddr);
> >> +			pmd[i] -= sme_get_me_mask();
> >> +		}
> >> +	}
> > Why isn't this chunk at the end of sme_encrypt_kernel() instead of here?
> 
> The sme_encrypt_kernel() does not have access to pmd (after pointer
> fixup is applied). You can extend the sme_encrypt_kernel() to pass an
> additional arguments but then we start getting in include hell. The pmd
> is defined as "pmdval_t". If we extend the sme_encrypt_kernel() then 
> asm/mem_encrypt.h need to include the header file which defines
> "pmdval_t". Adding the 'asm/pgtable_type.h' was causing all kind of
> compilation errors. I didn't spend much time on it. IMO, we really don't
> need to go in this path unless we see some value from doing this.

Keep it here then.

> >> @@ -345,6 +363,7 @@ SECTIONS
> >>  		__bss_start = .;
> >>  		*(.bss..page_aligned)
> >>  		*(.bss)
> >> +		BSS_DECRYPTED
> >>  		. = ALIGN(PAGE_SIZE);
> >>  		__bss_stop = .;
> > Putting it in the BSS would need a bit of care in the future as it poses
> > a certain ordering on the calls in x86_64_start_kernel() (not that there
> > isn't any now :)):
> 
> 
> Hmm, I thought since we are explicitly saying that attribute will add
> the variables in the bss section so caller should not be using the
> variable before bss is ready. If you are concerns that clear_bss() may
> get called after the variable is used then we could memset(0) when while
> clearing the C-bit. I did try to add some comments when we are clearing
> the C-bit. I can include some verbatim in BSS_DECRYPTED section as well.

Nah. It's clearly marked __bss_decrypted and anything which stores data in
a BSS location is busted whether thats .bss or .bss..decrypted. If someone
is not aware about the BSS constraints in general, i.e. don't use it before
clear_bss(), then I really can't help it.

Thanks,

	tglx


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ