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 183D5C4742C for ; Fri, 13 Nov 2020 10:40:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 96DD92224C for ; Fri, 13 Nov 2020 10:40:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 96DD92224C 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 F00BA6B0092; Fri, 13 Nov 2020 05:40:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D31196B0098; Fri, 13 Nov 2020 05:40:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ABEB56B0099; Fri, 13 Nov 2020 05:40:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0093.hostedemail.com [216.40.44.93]) by kanga.kvack.org (Postfix) with ESMTP id 7E5BB6B0096 for ; Fri, 13 Nov 2020 05:40:50 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 1C26A8249980 for ; Fri, 13 Nov 2020 10:40:50 +0000 (UTC) X-FDA: 77479051860.25.sugar84_0e0f8aa2730e Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin25.hostedemail.com (Postfix) with ESMTP id E6FEA1804E3A0 for ; Fri, 13 Nov 2020 10:40:49 +0000 (UTC) X-HE-Tag: sugar84_0e0f8aa2730e X-Filterd-Recvd-Size: 4353 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Fri, 13 Nov 2020 10:40:49 +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 57F99AF06; 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 4/5] mm, page_poison: remove CONFIG_PAGE_POISONING_NO_SANITY Date: Fri, 13 Nov 2020 11:40:32 +0100 Message-Id: <20201113104033.22907-5-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_NO_SANITY skips the check on page alloc whether the poison pattern was corrupted, suggesting a use-after-free. The motivation= to introduce it in commit 8823b1dbc05f ("mm/page_poison.c: enable PAGE_POISO= NING as a separate option") was to simply sanitize freed pages, optimally toge= ther with CONFIG_PAGE_POISONING_ZERO. These days we have an init_on_free=3D1 boot option, which makes this use = case of page poisoning redundant. For sanitizing, writing zeroes is sufficient, t= here is pretty much no benefit from writing the 0xAA poison pattern to freed p= ages, without checking it back on alloc. Thus, remove this option and suggest init_on_free instead in the main config's help. Signed-off-by: Vlastimil Babka Acked-by: David Hildenbrand --- drivers/virtio/virtio_balloon.c | 4 +--- mm/Kconfig.debug | 15 ++++----------- mm/page_poison.c | 3 --- 3 files changed, 5 insertions(+), 17 deletions(-) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_ball= oon.c index e53faed6ba93..8985fc2cea86 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -1114,9 +1114,7 @@ static int virtballoon_validate(struct virtio_devic= e *vdev) * page reporting as it could potentially change the contents * of our free pages. */ - if (!want_init_on_free() && - (IS_ENABLED(CONFIG_PAGE_POISONING_NO_SANITY) || - !page_poisoning_enabled_static())) + if (!want_init_on_free() && !page_poisoning_enabled_static()) __virtio_clear_bit(vdev, VIRTIO_BALLOON_F_PAGE_POISON); else if (!virtio_has_feature(vdev, VIRTIO_BALLOON_F_PAGE_POISON)) __virtio_clear_bit(vdev, VIRTIO_BALLOON_F_REPORTING); diff --git a/mm/Kconfig.debug b/mm/Kconfig.debug index c57786ad5be9..14e29fe5bfa6 100644 --- a/mm/Kconfig.debug +++ b/mm/Kconfig.debug @@ -74,18 +74,11 @@ config PAGE_POISONING Note that "poison" here is not the same thing as the "HWPoison" for CONFIG_MEMORY_FAILURE. This is software poisoning only. =20 - If unsure, say N + If you are only interested in sanitization of freed pages without + checking the poison pattern on alloc, you can boot the kernel with + "init_on_free=3D1" instead of enabling this. =20 -config PAGE_POISONING_NO_SANITY - depends on PAGE_POISONING - bool "Only poison, don't sanity check" - help - Skip the sanity checking on alloc, only fill the pages with - poison on free. This reduces some of the overhead of the - poisoning feature. - - If you are only interested in sanitization, say Y. Otherwise - say N. + If unsure, say N =20 config PAGE_POISONING_ZERO bool "Use zero for poisoning instead of debugging value" diff --git a/mm/page_poison.c b/mm/page_poison.c index 0d899a01d107..65cdf844c8ad 100644 --- a/mm/page_poison.c +++ b/mm/page_poison.c @@ -51,9 +51,6 @@ static void check_poison_mem(unsigned char *mem, size_t= bytes) unsigned char *start; unsigned char *end; =20 - if (IS_ENABLED(CONFIG_PAGE_POISONING_NO_SANITY)) - return; - start =3D memchr_inv(mem, PAGE_POISON, bytes); if (!start) return; --=20 2.29.2