From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 44129C63697 for ; Fri, 13 Nov 2020 10:41:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id ADB412224B for ; Fri, 13 Nov 2020 10:41:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org ADB412224B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5B9C36B009B; Fri, 13 Nov 2020 05:40:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 51E726B009C; Fri, 13 Nov 2020 05:40:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 25C7C6B009D; Fri, 13 Nov 2020 05:40:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0025.hostedemail.com [216.40.44.25]) by kanga.kvack.org (Postfix) with ESMTP id E29D96B009B for ; Fri, 13 Nov 2020 05:40:51 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 7F8B0181AEF0B for ; Fri, 13 Nov 2020 10:40:51 +0000 (UTC) X-FDA: 77479051902.17.cow50_3612a6e2730e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 5A87B180D0184 for ; Fri, 13 Nov 2020 10:40:51 +0000 (UTC) X-HE-Tag: cow50_3612a6e2730e X-Filterd-Recvd-Size: 5123 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 13 Nov 2020 10:40:50 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 777D9AF0B; Fri, 13 Nov 2020 10:40:48 +0000 (UTC) From: Vlastimil Babka To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Alexander Potapenko , Kees Cook , Michal Hocko , David Hildenbrand , Mateusz Nosek , Laura Abbott , Vlastimil Babka Subject: [PATCH v3 5/5] mm, page_poison: remove CONFIG_PAGE_POISONING_ZERO Date: Fri, 13 Nov 2020 11:40:33 +0100 Message-Id: <20201113104033.22907-6-vbabka@suse.cz> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201113104033.22907-1-vbabka@suse.cz> References: <20201113104033.22907-1-vbabka@suse.cz> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: CONFIG_PAGE_POISONING_ZERO uses the zero pattern instead of 0xAA. It was introduced by commit 1414c7f4f7d7 ("mm/page_poisoning.c: allow for zero poisoning"), noting that using zeroes retains the benefit of sanitizing c= ontent of freed pages, with the benefit of not having to zero them again on allo= c, and the downside of making some forms of corruption (stray writes of NULLs) h= arder to detect than with the 0xAA pattern. Together with CONFIG_PAGE_POISONING_NO_SANITY it made possible to sanitize the contents= on free without checking it back on alloc. These days we have the init_on_free() option to achieve sanitization with zeroes and to save clearing on alloc (and without checking on alloc). Arg= uably if someone does choose to check the poison for corruption on alloc, the s= avings of not clearing the page are secondary, and it makes sense to always use = the 0xAA poison pattern. Thus, remove the CONFIG_PAGE_POISONING_ZERO option f= or being redundant. Signed-off-by: Vlastimil Babka Acked-by: David Hildenbrand --- include/linux/poison.h | 4 ---- mm/Kconfig.debug | 12 ------------ mm/page_alloc.c | 8 +------- tools/include/linux/poison.h | 6 +----- 4 files changed, 2 insertions(+), 28 deletions(-) diff --git a/include/linux/poison.h b/include/linux/poison.h index dc8ae5d8db03..aff1c9250c82 100644 --- a/include/linux/poison.h +++ b/include/linux/poison.h @@ -27,11 +27,7 @@ #define TIMER_ENTRY_STATIC ((void *) 0x300 + POISON_POINTER_DELTA) =20 /********** mm/page_poison.c **********/ -#ifdef CONFIG_PAGE_POISONING_ZERO -#define PAGE_POISON 0x00 -#else #define PAGE_POISON 0xaa -#endif =20 /********** mm/page_alloc.c ************/ =20 diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index 14e29fe5bfa6..1e73717802f8 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -80,18 +80,6 @@ config PAGE_POISONING =20 If unsure, say N =20 -config PAGE_POISONING_ZERO - bool "Use zero for poisoning instead of debugging value" - depends on PAGE_POISONING - help - Instead of using the existing poison value, fill the pages with - zeros. This makes it harder to detect when errors are occurring - due to sanitization but the zeroing at free means that it is - no longer necessary to write zeros when GFP_ZERO is used on - allocation. - - If unsure, say N - config DEBUG_PAGE_REF bool "Enable tracepoint to track down page reference manipulation" depends on DEBUG_KERNEL diff --git a/mm/page_alloc.c b/mm/page_alloc.c index cd966829bed3..e80d5ce1b292 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -2226,12 +2226,6 @@ static inline int check_new_page(struct page *page= ) return 1; } =20 -static inline bool free_pages_prezeroed(void) -{ - return (IS_ENABLED(CONFIG_PAGE_POISONING_ZERO) && - page_poisoning_enabled_static()) || want_init_on_free(); -} - #ifdef CONFIG_DEBUG_VM /* * With DEBUG_VM enabled, order-0 pages are checked for expected state w= hen @@ -2300,7 +2294,7 @@ static void prep_new_page(struct page *page, unsign= ed int order, gfp_t gfp_flags { post_alloc_hook(page, order, gfp_flags); =20 - if (!free_pages_prezeroed() && want_init_on_alloc(gfp_flags)) + if (!want_init_on_free() && want_init_on_alloc(gfp_flags)) kernel_init_free_pages(page, 1 << order); =20 if (order && (gfp_flags & __GFP_COMP)) diff --git a/tools/include/linux/poison.h b/tools/include/linux/poison.h index d29725769107..2e6338ac5eed 100644 --- a/tools/include/linux/poison.h +++ b/tools/include/linux/poison.h @@ -35,12 +35,8 @@ */ #define TIMER_ENTRY_STATIC ((void *) 0x300 + POISON_POINTER_DELTA) =20 -/********** mm/debug-pagealloc.c **********/ -#ifdef CONFIG_PAGE_POISONING_ZERO -#define PAGE_POISON 0x00 -#else +/********** mm/page_poison.c **********/ #define PAGE_POISON 0xaa -#endif =20 /********** mm/page_alloc.c ************/ =20 --=20 2.29.2