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: <20150811164010.GJ23307@e104818-lin.cambridge.arm.com>
Date:	Tue, 11 Aug 2015 17:40:11 +0100
From:	Catalin Marinas <catalin.marinas@....com>
To:	Andrey Ryabinin <ryabinin.a.a@...il.com>
Cc:	"H. Peter Anvin" <hpa@...or.com>, Yury <yury.norov@...il.com>,
	Arnd Bergmann <arnd@...db.de>, linux-mm@...ck.org,
	Linus Walleij <linus.walleij@...aro.org>, x86@...nel.org,
	Will Deacon <will.deacon@....com>,
	linux-kernel@...r.kernel.org,
	Alexey Klimov <klimov.linux@...il.com>,
	Ingo Molnar <mingo@...hat.com>,
	Alexander Potapenko <glider@...gle.com>,
	"Aneesh Kumar K.V" <aneesh.kumar@...ux.vnet.ibm.com>,
	David Keitel <dkeitel@...eaurora.org>,
	Dmitry Vyukov <dvyukov@...gle.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v5 2/6] x86/kasan, mm: introduce generic
 kasan_populate_zero_shadow()

On Tue, Aug 11, 2015 at 07:25:12PM +0300, Andrey Ryabinin wrote:
> On 08/11/2015 06:41 PM, Catalin Marinas wrote:
> > On Tue, Aug 11, 2015 at 05:18:15AM +0300, Andrey Ryabinin wrote:
> >> --- /dev/null
> >> +++ b/mm/kasan/kasan_init.c
> > [...]
> >> +#if CONFIG_PGTABLE_LEVELS > 3
> >> +pud_t kasan_zero_pud[PTRS_PER_PUD] __page_aligned_bss;
> >> +#endif
> >> +#if CONFIG_PGTABLE_LEVELS > 2
> >> +pmd_t kasan_zero_pmd[PTRS_PER_PMD] __page_aligned_bss;
> >> +#endif
> >> +pte_t kasan_zero_pte[PTRS_PER_PTE] __page_aligned_bss;
> > 
> > Is there any problem if you don't add the #ifs here? Wouldn't the linker
> > remove them if they are not used?
> 
> > Original hunk copied here for easy comparison:
> > 
> >> -static int __init zero_pte_populate(pmd_t *pmd, unsigned long addr,
> >> -				unsigned long end)
> >> -{
> >> -	pte_t *pte = pte_offset_kernel(pmd, addr);
> >> -
> >> -	while (addr + PAGE_SIZE <= end) {
> >> -		WARN_ON(!pte_none(*pte));
> >> -		set_pte(pte, __pte(__pa_nodebug(kasan_zero_page)
> >> -					| __PAGE_KERNEL_RO));
> >> -		addr += PAGE_SIZE;
> >> -		pte = pte_offset_kernel(pmd, addr);
> >> -	}
> >> -	return 0;
> >> -}
> > [...]
> >> +static void __init zero_pte_populate(pmd_t *pmd, unsigned long addr,
> >> +				unsigned long end)
> >> +{
> >> +	pte_t *pte = pte_offset_kernel(pmd, addr);
> >> +	pte_t zero_pte;
> >> +
> >> +	zero_pte = pfn_pte(PFN_DOWN(__pa(kasan_zero_page)), PAGE_KERNEL);
> >> +	zero_pte = pte_wrprotect(zero_pte);
> >> +
> >> +	while (addr + PAGE_SIZE <= end) {
> >> +		set_pte_at(&init_mm, addr, pte, zero_pte);
> >> +		addr += PAGE_SIZE;
> >> +		pte = pte_offset_kernel(pmd, addr);
> >> +	}
> >> +}
> > 
> > I think there are some differences with the original x86 code. The first
> > one is the use of __pa_nodebug, does it cause any problems if
> > CONFIG_DEBUG_VIRTUAL is enabled?
> 
> __pa_nodebug() should be used before kasan_early_init(), this piece of code
> executed far later, so it's ok to use __pa() here.
> This was actually a mistake in original code to use __pa_nodebug().

OK. So please add a comment in the commit log.

> > The second is the use of a read-only attribute when mapping
> > kasan_zero_page on x86. Can it cope with a writable mapping?
> > 
> 
> Did you miss this line:
> 
> +	zero_pte = pte_wrprotect(zero_pte);

Ah, yes, I missed this.

Anyway, for this patch:

Acked-by: Catalin Marinas <catalin.marinas@....com>

Not sure how you plan to merge it though since there are x86
dependencies. I could send the whole series via tip or the mm tree (and
I guess it's pretty late for 4.3).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ