From patchwork Sun Sep 11 09:59:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12972821 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71E7BECAAA1 for ; Sun, 11 Sep 2022 09:59:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC46C8000B; Sun, 11 Sep 2022 05:59:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B72CF80008; Sun, 11 Sep 2022 05:59:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 94F578000B; Sun, 11 Sep 2022 05:59:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 8650D80008 for ; Sun, 11 Sep 2022 05:59:30 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5D2C01C6051 for ; Sun, 11 Sep 2022 09:59:30 +0000 (UTC) X-FDA: 79899357300.23.2ECA000 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf30.hostedemail.com (Postfix) with ESMTP id 22DED800B0 for ; Sun, 11 Sep 2022 09:59:30 +0000 (UTC) Received: by mail-qt1-f171.google.com with SMTP id s18so1350991qtx.6 for ; Sun, 11 Sep 2022 02:59:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=OPh2SoeDJ39bM1Jn5fFI8VsUd8dRA2153uVq4iTm5YA=; b=Cm/iwBj9qSxR6hNh4WkGnlY2rIhzISZ52M2GqSDfU7xNlfLTD1kDBK3GW4JyIWLpbF vFCNPAJLgXJtsglJR9PAeKY44F6cjvaw6tuS4MXxA20nHmxmD/wqzebHgdbHMGmAD61N ZV4Tr5DVsNuioBerAQQDoJ4+a5mniKGiZRxoUQiZlNMllJ4sclh03nAFz08cVB8ODhMT Skx+FX/f8czauTMll515ktdu7gVSZJA1f7251v/yIj0BzYslEFQQtKX5F2MkHK/8CwmU Hx7spxOmVfuUwec09wkdbVsfFyOD1wVjfc69FUWeWsnCvU5bgK+iVzVBPk9GSB7Lao7h VxvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=OPh2SoeDJ39bM1Jn5fFI8VsUd8dRA2153uVq4iTm5YA=; b=shzdpmtfF05M6JNU6Zie/vYB2m6+iNn0a86YBhN/o4CqEaMQYdGoNYszXkOoKBIBlU 0jEq2ZWvyfKqeAovjJ/XYwJ7O1rZ0S972ekoXdbAadqysg2dx264gYqKZ/mXdl7aEErv HYU7cgW7cWHyWuoJ8XVobRyIiHVcUE8OorhFkhLHpF8E5gBpcanbNQx2UlF+2C/j/kBf vX0GGfGO+CiSHg8koAc/gvQyvhPFpY0MjGjN0RspiOlciiJmRA/iS98wBTqRkcY7/a5c KX6odksxUnP6ncdEW14wfbrUhsxZrgbHf/OUkHnQCPvbWFz33pX/vnHAdd53Fr2dSLM/ H4Aw== X-Gm-Message-State: ACgBeo3N79LNUWEC5KRAN71YLR6E9leeqSX57wRtUKV/7QDbavLjDgyU j1jrY4gu/Y5ddfh82vJtOYI4dQ== X-Google-Smtp-Source: AA6agR5J3Cn9HvOjdYaL72tcgWTBN3wcKIFFTOLz4o2e2o7b+hMrlixH3K7CPiJSXhwkuBn1HYdkSA== X-Received: by 2002:a05:622a:609:b0:35b:acd0:21ff with SMTP id z9-20020a05622a060900b0035bacd021ffmr3764909qta.321.1662890369441; Sun, 11 Sep 2022 02:59:29 -0700 (PDT) Received: from soleen.c.googlers.com.com (240.157.150.34.bc.googleusercontent.com. [34.150.157.240]) by smtp.gmail.com with ESMTPSA id y29-20020a37f61d000000b006cbd60c14c9sm4625233qkj.35.2022.09.11.02.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 02:59:28 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, akpm@linux-foundation.org, corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, rick.p.edgecombe@intel.com Subject: [PATCH 1/3] mm/page_table_check: Check writable zero page in page table check Date: Sun, 11 Sep 2022 09:59:21 +0000 Message-Id: <20220911095923.3614387-2-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220911095923.3614387-1-pasha.tatashin@soleen.com> References: <20220911095923.3614387-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662890370; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=OPh2SoeDJ39bM1Jn5fFI8VsUd8dRA2153uVq4iTm5YA=; b=Fo99dHk8rDr44Axq50PAkvEuXZTfpseZO2CBkR1P84hY16Uzt0eQ3YQs86t0NLV3MXB6OL v2I85To/zpYkN1ZGaMqf87gNNFBlV4aZs4iiH7bMeXzFnLQoRfOQtViAyhLTIiHtRn8cO0 CA6uupI1c+oU0agnGilY6lG2JB09fKY= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="Cm/iwBj9"; spf=pass (imf30.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662890370; a=rsa-sha256; cv=none; b=lpVFuN06RCUfF86fl4vTqW5bs8VXNtrqcFNbCnpydsgyDiXMzJumWAUYVQ+s5PWiriU97Y WDvyDFBOUc+MXj4sMcHIUTLbWGpurVLHwGSthzYQHF2hxh1BfK91qsvzq41Smrqh9ErHyN DsLsOmwsyU+MEtCM8vyhwu5pLFZ3mfM= X-Rspam-User: X-Stat-Signature: mq566qm7ekenmosm9n4om1edra5eoeuk X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 22DED800B0 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b="Cm/iwBj9"; spf=pass (imf30.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none X-HE-Tag: 1662890370-736339 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: Rick Edgecombe The zero page should remain all zero, so that it can be mapped as read-only for read faults of memory that should be zeroed. If it is ever mapped writable to userspace, it could become non-zero and so other apps would unexpectedly get non-zero data. So the zero page should never be mapped writable to userspace. Check for this condition in page_table_check_set(). Signed-off-by: Rick Edgecombe Signed-off-by: Pasha Tatashin --- mm/page_table_check.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mm/page_table_check.c b/mm/page_table_check.c index e2062748791a..665ece0d55d4 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -102,6 +102,8 @@ static void page_table_check_set(struct mm_struct *mm, unsigned long addr, if (!pfn_valid(pfn)) return; + BUG_ON(is_zero_pfn(pfn) && rw); + page = pfn_to_page(pfn); page_ext = lookup_page_ext(page); anon = PageAnon(page); From patchwork Sun Sep 11 09:59:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12972822 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16C0CC6FA8A for ; Sun, 11 Sep 2022 09:59:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C896F8000C; Sun, 11 Sep 2022 05:59:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C0FB480008; Sun, 11 Sep 2022 05:59:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A894B8000C; Sun, 11 Sep 2022 05:59:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 943E580008 for ; Sun, 11 Sep 2022 05:59:31 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 67919A04E5 for ; Sun, 11 Sep 2022 09:59:31 +0000 (UTC) X-FDA: 79899357342.21.B0F3216 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 1B1B11C0084 for ; Sun, 11 Sep 2022 09:59:30 +0000 (UTC) Received: by mail-qk1-f178.google.com with SMTP id c19so2318931qkm.7 for ; Sun, 11 Sep 2022 02:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=IQgFAlcZ+zBw786vdsFczK8VrNHApPya6ZC6RPMkUdg=; b=B7B7pHbZ63+sPWwS2bD6YT1SStvX81UMer7JZxmb2Y5zl//fOZKSJe6QQrlxj4unjc WDxlNFc81O6KKYWX+3kHXoCbwgrnTNTHrGPYF/Gy9N2yadEqTjxSGmHf6kXGCKYQSWsf i4szN97Ry6b/Sp93I9coUyReS67tuLpesPv72OwqzThS4Z7UjkNZaqZ+lGko554zcfcr jMbMa0KbUB9TSqD9EkFodoHDAkeUypmhY4mRkP+TAvo28yxDtecBCwbKDDLMp/eo7EFz g36jyaTCaEVtCX8w4/C+5f1Y+v4pabrpWeWxLiP4KAvAF6WYqDwwQIXjtUOrqRHZQlRZ r4RA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=IQgFAlcZ+zBw786vdsFczK8VrNHApPya6ZC6RPMkUdg=; b=hxEOkW/LEfK81mhlY/MOj+DGjul8zmtTHzk1dFwCaqXq/AwfAWMMhvLOX3LHkIcyY7 91VXS/k/3s6ozoWmzjROuR+9ZLgONQXyZIXueqVsrvXt9iqZHssqMehhbB/zz0meq35k 3yG7Kaq1foRYPlwbUgdcBileIoFPBVRBdra6M99Ygh5v1U5uIb5zFa+pvFPDHfIbf9kn pnPKhhlvbJ4yzjoHl+Mwpn/zNvZtVupKk5RnaCx8EiX6u6DkgyBsrm2tqyKJCE0EbpC1 uwfSmD4q2DXZChGB3awYNEZCguHgfo7FszED1607kFhnzERF1e1b4F1xDFPAEGLltsc7 /xcQ== X-Gm-Message-State: ACgBeo12b4IWyrJJNYmDCTOS/1ME+eacdS9pyCzbNPk0cX4CIvcLhMSt Ky6jU5NtuIUqmcW2jn9gbocC4g== X-Google-Smtp-Source: AA6agR5DcmR8o9JAtmJ/2eIiSKRUYqewIiL/dNKxjys5qnEA0ST4IsGWy6xsrwjMK/lKCFbJNdD3zg== X-Received: by 2002:a05:620a:278d:b0:6bb:1435:c0bd with SMTP id g13-20020a05620a278d00b006bb1435c0bdmr15648933qkp.291.1662890370397; Sun, 11 Sep 2022 02:59:30 -0700 (PDT) Received: from soleen.c.googlers.com.com (240.157.150.34.bc.googleusercontent.com. [34.150.157.240]) by smtp.gmail.com with ESMTPSA id y29-20020a37f61d000000b006cbd60c14c9sm4625233qkj.35.2022.09.11.02.59.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 02:59:29 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, akpm@linux-foundation.org, corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, rick.p.edgecombe@intel.com Subject: [PATCH 2/3] mm/page_table_check: Do WARN_ON instead of BUG_ON by default Date: Sun, 11 Sep 2022 09:59:22 +0000 Message-Id: <20220911095923.3614387-3-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220911095923.3614387-1-pasha.tatashin@soleen.com> References: <20220911095923.3614387-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=B7B7pHbZ; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662890371; a=rsa-sha256; cv=none; b=QMDe0q99iG6isN0OixYeDAryOVT/Cd9TWIQFP0usn7Ta2TjELvu+3IB/J9zd9bdj8hUfYS Nic9ek8CFAmHqw75KMzHwqLmym2POboyrKAbHMeGmEkXfsuleU/yiyDKW+1QElcuQkbaFG CcygvMyRswo0n7K9xtBAMnqtrmch9I0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662890371; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=IQgFAlcZ+zBw786vdsFczK8VrNHApPya6ZC6RPMkUdg=; b=lifoE6UyFa8hLOFNRfb/Sk+Rwh2gv+xlh9Wn9ROUq0fhSfNzDW8wXOSq2Mlr2loZIRaqlW MWw1Y3pksS5zi9q8jT7RCwPXCp9alWMFFrAq3MHIDExBYHxchpnLi1FuKa7CCNN7IkV/+c Dz8LPWX/tJjpI7n2UdAfPl8ZUdICy8k= X-Stat-Signature: qb64r3gipjr6ddj1fm5346nhmreimb3o X-Rspam-User: Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=B7B7pHbZ; spf=pass (imf18.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.222.178 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com; dmarc=none X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 1B1B11C0084 X-HE-Tag: 1662890370-22124 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: Currently, page_table_check when detects errors panics kernel. Instead, print a warning, and panic only when specifically requested via kernel parameter: page_table_check=panic Signed-off-by: Pasha Tatashin --- mm/page_table_check.c | 53 +++++++++++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/mm/page_table_check.c b/mm/page_table_check.c index 665ece0d55d4..881f19d0714c 100644 --- a/mm/page_table_check.c +++ b/mm/page_table_check.c @@ -17,13 +17,37 @@ struct page_table_check { static bool __page_table_check_enabled __initdata = IS_ENABLED(CONFIG_PAGE_TABLE_CHECK_ENFORCED); +static bool __page_table_check_panic; DEFINE_STATIC_KEY_TRUE(page_table_check_disabled); EXPORT_SYMBOL(page_table_check_disabled); +#define PAGE_TABLE_CHECK_BUG(v) \ + do { \ + bool __bug = !!(v); \ + \ + if (__page_table_check_panic) \ + BUG_ON(__bug); \ + else if (WARN_ON_ONCE(__bug)) \ + static_branch_enable(&page_table_check_disabled); \ + } while (false) + static int __init early_page_table_check_param(char *buf) { - return strtobool(buf, &__page_table_check_enabled); + int rc = strtobool(buf, &__page_table_check_enabled); + + if (rc) { + if (!strcmp(buf, "panic")) { + __page_table_check_enabled = true; + __page_table_check_panic = true; + rc = 0; + } + } + + if (rc) + pr_warn("Invalid option string: '%s'\n", buf); + + return rc; } early_param("page_table_check", early_page_table_check_param); @@ -48,7 +72,8 @@ struct page_ext_operations page_table_check_ops = { static struct page_table_check *get_page_table_check(struct page_ext *page_ext) { - BUG_ON(!page_ext); + PAGE_TABLE_CHECK_BUG(!page_ext); + return (void *)(page_ext) + page_table_check_ops.offset; } @@ -75,11 +100,11 @@ static void page_table_check_clear(struct mm_struct *mm, unsigned long addr, struct page_table_check *ptc = get_page_table_check(page_ext); if (anon) { - BUG_ON(atomic_read(&ptc->file_map_count)); - BUG_ON(atomic_dec_return(&ptc->anon_map_count) < 0); + PAGE_TABLE_CHECK_BUG(atomic_read(&ptc->file_map_count)); + PAGE_TABLE_CHECK_BUG(atomic_dec_return(&ptc->anon_map_count) < 0); } else { - BUG_ON(atomic_read(&ptc->anon_map_count)); - BUG_ON(atomic_dec_return(&ptc->file_map_count) < 0); + PAGE_TABLE_CHECK_BUG(atomic_read(&ptc->anon_map_count)); + PAGE_TABLE_CHECK_BUG(atomic_dec_return(&ptc->file_map_count) < 0); } page_ext = page_ext_next(page_ext); } @@ -102,7 +127,7 @@ static void page_table_check_set(struct mm_struct *mm, unsigned long addr, if (!pfn_valid(pfn)) return; - BUG_ON(is_zero_pfn(pfn) && rw); + PAGE_TABLE_CHECK_BUG(!is_zero_pfn(pfn) && rw); page = pfn_to_page(pfn); page_ext = lookup_page_ext(page); @@ -112,11 +137,11 @@ static void page_table_check_set(struct mm_struct *mm, unsigned long addr, struct page_table_check *ptc = get_page_table_check(page_ext); if (anon) { - BUG_ON(atomic_read(&ptc->file_map_count)); - BUG_ON(atomic_inc_return(&ptc->anon_map_count) > 1 && rw); + PAGE_TABLE_CHECK_BUG(atomic_read(&ptc->file_map_count)); + PAGE_TABLE_CHECK_BUG(atomic_inc_return(&ptc->anon_map_count) > 1 && rw); } else { - BUG_ON(atomic_read(&ptc->anon_map_count)); - BUG_ON(atomic_inc_return(&ptc->file_map_count) < 0); + PAGE_TABLE_CHECK_BUG(atomic_read(&ptc->anon_map_count)); + PAGE_TABLE_CHECK_BUG(atomic_inc_return(&ptc->file_map_count) < 0); } page_ext = page_ext_next(page_ext); } @@ -131,12 +156,12 @@ void __page_table_check_zero(struct page *page, unsigned int order) struct page_ext *page_ext = lookup_page_ext(page); unsigned long i; - BUG_ON(!page_ext); + PAGE_TABLE_CHECK_BUG(!page_ext); for (i = 0; i < (1ul << order); i++) { struct page_table_check *ptc = get_page_table_check(page_ext); - BUG_ON(atomic_read(&ptc->anon_map_count)); - BUG_ON(atomic_read(&ptc->file_map_count)); + PAGE_TABLE_CHECK_BUG(atomic_read(&ptc->anon_map_count)); + PAGE_TABLE_CHECK_BUG(atomic_read(&ptc->file_map_count)); page_ext = page_ext_next(page_ext); } } From patchwork Sun Sep 11 09:59:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pasha Tatashin X-Patchwork-Id: 12972823 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C83BDECAAA1 for ; Sun, 11 Sep 2022 09:59:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D99F68000D; Sun, 11 Sep 2022 05:59:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D48BF80008; Sun, 11 Sep 2022 05:59:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B4CBA8000D; Sun, 11 Sep 2022 05:59:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 9CB8680008 for ; Sun, 11 Sep 2022 05:59:32 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 75B16C06F2 for ; Sun, 11 Sep 2022 09:59:32 +0000 (UTC) X-FDA: 79899357384.11.C9151B3 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) by imf06.hostedemail.com (Postfix) with ESMTP id 2675618007F for ; Sun, 11 Sep 2022 09:59:32 +0000 (UTC) Received: by mail-qt1-f173.google.com with SMTP id w2so700704qtv.9 for ; Sun, 11 Sep 2022 02:59:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=soleen.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date; bh=XLM1m2iZcSFN7zEYtkuHYYcYmZjAkeATO8o3pAdAyoQ=; b=dK8IGsH1J6j5irLf37g7ieCD4ck/MOLB0cramE5RrrjgdpHHVF5mw5wd2s75b3a94l 2XA1exMylYG3mBaBY4drslL3G2Wr58g/tKZyaR96Rjny+antzG4vSdeJU2jjsZgJbOwh l1rarVtoxM8hJuVE4cMZGXQFYRc3sAcijxxs4gqKwGwmOjAgw2SLhZ4+S7KCauil99p5 lwRlQBl5+O38nc8RwZA0hjvs3NWijTbLtlasFVm0u2mY3vvH3iQsqjw6uxhf8vZkmj3U 6E5zxQdKtcdl1TOzLfLHVK9qZEpQFtXtJmdpxEwvF3ur9Pyt/REZjxQzTHQFILIPhjA9 IK1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XLM1m2iZcSFN7zEYtkuHYYcYmZjAkeATO8o3pAdAyoQ=; b=h4NB992USJ8pnBLvL853HICq+IFAKHVPtcdZRiTNq8u/B2X/x2b50USNZBSObByILZ VSPkLXo/LoZBkBUF2EeFTBJu55mJIx/TN5T5gB4FOJVhToR947zNPES3oocLl5BtEkZK zHoBzseZ0+A1c2BzwlB2GnBWE94VJYV3c6c0jk2lNrYAUOjSkA1ywvOWJOp+X9IhgvoD V26RjNOkAFCGxTHqUg0Pkr8YS/4ly/c9bXH8Cgt4Jw+9xEDipT5/yIIAO52I7pgd0G3Q COQad8/hWPyG2afy0a5g1f9yOIkHjzOjDTGZdJJMFZ6g9+OTGMNyVSs4QLtRLu+Fuo7i LR1A== X-Gm-Message-State: ACgBeo0KHO65iRAHvLz06RU5SlQVDl8BZ+Bo6FVUpY5xDyKqF+rxu9Nl xIThhPf9mL+/hS5yn/gUzMf8dQ== X-Google-Smtp-Source: AA6agR6jAmuFf2yJvMnDJ68B5wtvIomz7XM30r86b++gsxlkrxwEhuDJSX45o24EeDA83ZFIOnD1zQ== X-Received: by 2002:a05:622a:6027:b0:343:5691:93de with SMTP id he39-20020a05622a602700b00343569193demr19278780qtb.165.1662890371433; Sun, 11 Sep 2022 02:59:31 -0700 (PDT) Received: from soleen.c.googlers.com.com (240.157.150.34.bc.googleusercontent.com. [34.150.157.240]) by smtp.gmail.com with ESMTPSA id y29-20020a37f61d000000b006cbd60c14c9sm4625233qkj.35.2022.09.11.02.59.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Sep 2022 02:59:30 -0700 (PDT) From: Pasha Tatashin To: pasha.tatashin@soleen.com, akpm@linux-foundation.org, corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, rick.p.edgecombe@intel.com Subject: [PATCH 3/3] doc/vm: add information about page_table_check=panic Date: Sun, 11 Sep 2022 09:59:23 +0000 Message-Id: <20220911095923.3614387-4-pasha.tatashin@soleen.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog In-Reply-To: <20220911095923.3614387-1-pasha.tatashin@soleen.com> References: <20220911095923.3614387-1-pasha.tatashin@soleen.com> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1662890372; a=rsa-sha256; cv=none; b=Y4vk9r+gI15WxRvOfhHEtffDbBvYm+RR8vLuoV19Z+Sqcsrf7vkxL+eJWer1s3w6pCsEBi rqrHunIWLKOjOtovm1l62i9m8GzgDj4Rs8VHhWaC1mhNr904u+savBTgESo0FkRXPC57kU WQ8aYpVcgr52jzJSbde/OF683IpR+ho= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=dK8IGsH1; dmarc=none; spf=pass (imf06.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1662890372; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XLM1m2iZcSFN7zEYtkuHYYcYmZjAkeATO8o3pAdAyoQ=; b=DHNl9O3Iw64LebzgXHX/jOYd4MZu/XvOosMXfdens9h52I1AlYCT/DtC0SqDvIMP5tB4l9 HfCp1sNzqZ6yU/smmIE2nKlnPeLKr4TDCmowYhaYBNXyeM30/UVNBL6Z61T6BF9k8DCuni T3Vlqi1a4Z79asB+pDl5EnFbA+xKlJ4= X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 2675618007F Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=soleen.com header.s=google header.b=dK8IGsH1; dmarc=none; spf=pass (imf06.hostedemail.com: domain of pasha.tatashin@soleen.com designates 209.85.160.173 as permitted sender) smtp.mailfrom=pasha.tatashin@soleen.com X-Stat-Signature: rhsf7oirrjfoqmn8dcamztsfoxmef6jt X-Rspam-User: X-HE-Tag: 1662890371-10127 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: The default behavior of page table check was changed from panicking kernel to printing a warning. Add a note how to still panic the kernel when error is detected. Signed-off-by: Pasha Tatashin --- Documentation/mm/page_table_check.rst | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Documentation/mm/page_table_check.rst b/Documentation/mm/page_table_check.rst index 1a09472f10a3..9306cd75647c 100644 --- a/Documentation/mm/page_table_check.rst +++ b/Documentation/mm/page_table_check.rst @@ -16,13 +16,13 @@ Page table check performs extra verifications at the time when new pages become accessible from the userspace by getting their page table entries (PTEs PMDs etc.) added into the table. -In case of detected corruption, the kernel is crashed. There is a small -performance and memory overhead associated with the page table check. Therefore, -it is disabled by default, but can be optionally enabled on systems where the -extra hardening outweighs the performance costs. Also, because page table check -is synchronous, it can help with debugging double map memory corruption issues, -by crashing kernel at the time wrong mapping occurs instead of later which is -often the case with memory corruptions bugs. +In case of detected corruption, a warning is printed or kernel is crashed. There +is a small performance and memory overhead associated with the page table check. +Therefore, it is disabled by default, but can be optionally enabled on systems +where the extra hardening outweighs the performance costs. Also, because page +table check is synchronous, it can help with debugging double map memory +corruption issues, by crashing kernel at the time wrong mapping occurs instead +of later which is often the case with memory corruptions bugs. Double mapping detection logic ============================== @@ -52,5 +52,7 @@ Build kernel with: - Boot with 'page_table_check=on' kernel parameter. +- Boot with 'page_table_check=panic' in order to panic when error is detected. + Optionally, build kernel with PAGE_TABLE_CHECK_ENFORCED in order to have page table support without extra kernel parameter.