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: <63a38733-974f-9032-1980-9a8289d72d21@intel.com>
Date:   Mon, 23 Sep 2019 14:19:46 -0700
From:   Dave Hansen <dave.hansen@...el.com>
To:     Steve Wahl <steve.wahl@....com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        "H. Peter Anvin" <hpa@...or.com>, x86@...nel.org,
        Juergen Gross <jgross@...e.com>,
        "Kirill A. Shutemov" <kirill@...temov.name>,
        Brijesh Singh <brijesh.singh@....com>,
        Jordan Borgner <mail@...dan-borgner.de>,
        Feng Tang <feng.tang@...el.com>, linux-kernel@...r.kernel.org,
        Chao Fan <fanc.fnst@...fujitsu.com>,
        Zhenzhong Duan <zhenzhong.duan@...cle.com>
Cc:     Baoquan He <bhe@...hat.com>, russ.anderson@....com,
        dimitri.sivanich@....com, mike.travis@....com
Subject: Re: [PATCH v2 1/2] x86/boot/64: Make level2_kernel_pgt pages invalid
 outside kernel area.

On 9/23/19 11:15 AM, Steve Wahl wrote:
>  	pmd = fixup_pointer(level2_kernel_pgt, physaddr);
> -	for (i = 0; i < PTRS_PER_PMD; i++) {
> +	for (i = 0; i < pmd_index((unsigned long)_text); i++)
> +		pmd[i] &= ~_PAGE_PRESENT;
> +
> +	for (; i <= pmd_index((unsigned long)_end); i++)
>  		if (pmd[i] & _PAGE_PRESENT)
>  			pmd[i] += load_delta;
> -	}
> +
> +	for (; i < PTRS_PER_PMD; i++)
> +		pmd[i] &= ~_PAGE_PRESENT;

This is looking a bunch better.  The broken-up loop could probably use
some comments, or you could combine it back to a single loop like this:

	int text_start_pmd_index = pmd_index((unsigned long)_text);
	int text_end_pmd_index   = pmd_index((unsigned long)_end);

	for (i = 0; i < PTRS_PER_PMD; i++) {
		if ((i < text_start_pmd_index) ||
		    (i > text_end_pmd_index)) {
			/* Unmap entries not mapping the kernel image */
			pmd[i] &= ~_PAGE_PRESENT;
		} else if (pmd[i] & _PAGE_PRESENT)
 			pmd[i] += load_delta;
		}
	}

Although I'd prefer it get commented or rewritten, it's passable like
this, so:

Reviewed-by: Dave Hansen <dave.hansen@...ux.intel.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ