Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932666AbbD0J5F (ORCPT ); Mon, 27 Apr 2015 05:57:05 -0400 Received: from r00tworld.com ([212.85.137.150]:34429 "EHLO r00tworld.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932345AbbD0J5D (ORCPT ); Mon, 27 Apr 2015 05:57:03 -0400 X-Greylist: delayed 1750 seconds by postgrey-1.27 at vger.kernel.org; Mon, 27 Apr 2015 05:57:03 EDT From: "PaX Team" To: Andi Kleen , Anisse Astier Date: Mon, 27 Apr 2015 11:25:57 +0200 MIME-Version: 1.0 Subject: Re: [PATCH 2/2] mm/page_alloc.c: add config option to sanitize freed pages Reply-to: pageexec@freemail.hu CC: Andrew Morton , Mel Gorman , "Kirill A. Shutemov" , David Rientjes , Alan Cox , Linus Torvalds , Peter Zijlstra , Brad Spengler , Kees Cook , linux-mm@kvack.org, Linux Kernel Mailing List Message-ID: <553E00A5.370.3E3700BE@pageexec.freemail.hu> In-reply-to: References: <1429909549-11726-1-git-send-email-anisse@astier.eu>, <87tww2ejit.fsf@tassilo.jf.intel.com>, X-mailer: Pegasus Mail for Windows (4.70) Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Content-description: Mail message body X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.12 (r00tworld.com [212.85.137.150]); Mon, 27 Apr 2015 11:26:06 +0200 (CEST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1461 Lines: 44 On 27 Apr 2015 at 10:11, Anisse Astier wrote: > >> +#ifdef CONFIG_SANITIZE_FREED_PAGES > >> + zero_pages(page, order); > >> +#endif > > > > And not removing the clear on __GFP_ZERO by remembering that? > > > > That means all clears would be done twice. > > > > That patch is far too simple. Clearing is commonly the most > > expensive kernel operation. > > > > I thought about this, but if you unconditionally remove the clear on > __GFP_ZERO, you wouldn't be guaranteed to have a zeroed page when > memory is first used (you would protect the kernel from its own info > leaks though); the PaX SANITIZE feature does exactly this in mm/page_alloc.c:prep_new_page: #ifndef CONFIG_PAX_MEMORY_SANITIZE if (gfp_flags & __GFP_ZERO) prep_zero_page(page, order, gfp_flags); #endif > you'd need to clear memory on boot for example. it happens automagically because on boot during the transition from the boot allocator to the buddy one each page gets freed which will then go through the page clearing path. however there's a known problem/conflict with HIBERNATION (see http://marc.info/?l=linux-pm&m=132871433416256&w=2) which i think would have to be resolved before upstream acceptance. cheers, PaX Team -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/