From patchwork Tue Dec 15 03:13:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 11973955 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=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 E171CC2BB40 for ; Tue, 15 Dec 2020 03:13:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8D6C8223C8 for ; Tue, 15 Dec 2020 03:13:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8D6C8223C8 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux-foundation.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 27D958D0076; Mon, 14 Dec 2020 22:13:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 22E7F8D001C; Mon, 14 Dec 2020 22:13:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16CAB8D0076; Mon, 14 Dec 2020 22:13:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id F2D338D001C for ; Mon, 14 Dec 2020 22:13:44 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id C39E68249980 for ; Tue, 15 Dec 2020 03:13:44 +0000 (UTC) X-FDA: 77594046768.18.clam74_4d1532b27420 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id AAB6A100ED3B2 for ; Tue, 15 Dec 2020 03:13:44 +0000 (UTC) X-HE-Tag: clam74_4d1532b27420 X-Filterd-Recvd-Size: 4757 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf38.hostedemail.com (Postfix) with ESMTP for ; Tue, 15 Dec 2020 03:13:44 +0000 (UTC) Date: Mon, 14 Dec 2020 19:13:41 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1608002023; bh=qGt8F2fqaDvZFHC17GJMmOy1PWyjSbcWQR4KVvWIuM4=; h=From:To:Subject:In-Reply-To:From; b=wqGYwKbKeNQzN/6MtHDW6kfRds2kryBbH1bbzJNp/sZmWBQgZhkOWfI0Bw0oe7Btv r5OTIm3vROVsQCyl6X8NjEdzcs5Rxb+RlproTIFCt9p7nmDQB2DQesKzKPuz4YIY0X EmoSjd0wwVwVsmdwyzffpMwWdGu3QNTX+ODJNLps= From: Andrew Morton To: akpm@linux-foundation.org, david@redhat.com, glider@google.com, keescook@chromium.org, labbott@kernel.org, linux-mm@kvack.org, mateusznosek0@gmail.com, mhocko@kernel.org, mm-commits@vger.kernel.org, rafael.j.wysocki@intel.com, rppt@linux.ibm.com, torvalds@linux-foundation.org, vbabka@suse.cz Subject: [patch 177/200] mm, page_poison: remove CONFIG_PAGE_POISONING_NO_SANITY Message-ID: <20201215031341.0XN-lrX23%akpm@linux-foundation.org> In-Reply-To: <20201214190237.a17b70ae14f129e2dca3d204@linux-foundation.org> User-Agent: s-nail v14.8.16 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: From: Vlastimil Babka Subject: mm, page_poison: remove CONFIG_PAGE_POISONING_NO_SANITY 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_POISONING as a separate option") was to simply sanitize freed pages, optimally together with CONFIG_PAGE_POISONING_ZERO. These days we have an init_on_free=1 boot option, which makes this use case of page poisoning redundant. For sanitizing, writing zeroes is sufficient, there is pretty much no benefit from writing the 0xAA poison pattern to freed pages, without checking it back on alloc. Thus, remove this option and suggest init_on_free instead in the main config's help. Link: https://lkml.kernel.org/r/20201113104033.22907-5-vbabka@suse.cz Signed-off-by: Vlastimil Babka Acked-by: David Hildenbrand Cc: Mike Rapoport Cc: Rafael J. Wysocki Cc: Alexander Potapenko Cc: Kees Cook Cc: Laura Abbott Cc: Mateusz Nosek Cc: Michal Hocko Signed-off-by: Andrew Morton --- drivers/virtio/virtio_balloon.c | 4 +--- mm/Kconfig.debug | 15 ++++----------- mm/page_poison.c | 3 --- 3 files changed, 5 insertions(+), 17 deletions(-) --- a/drivers/virtio/virtio_balloon.c~mm-page_poison-remove-config_page_poisoning_no_sanity +++ a/drivers/virtio/virtio_balloon.c @@ -1114,9 +1114,7 @@ static int virtballoon_validate(struct v * 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); --- a/mm/Kconfig.debug~mm-page_poison-remove-config_page_poisoning_no_sanity +++ a/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. - If unsure, say N - -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 of freed pages without + checking the poison pattern on alloc, you can boot the kernel with + "init_on_free=1" instead of enabling this. - If you are only interested in sanitization, say Y. Otherwise - say N. + If unsure, say N config PAGE_POISONING_ZERO bool "Use zero for poisoning instead of debugging value" --- a/mm/page_poison.c~mm-page_poison-remove-config_page_poisoning_no_sanity +++ a/mm/page_poison.c @@ -51,9 +51,6 @@ static void check_poison_mem(unsigned ch unsigned char *start; unsigned char *end; - if (IS_ENABLED(CONFIG_PAGE_POISONING_NO_SANITY)) - return; - start = memchr_inv(mem, PAGE_POISON, bytes); if (!start) return;