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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id B01A7C433F5 for ; Wed, 1 Dec 2021 08:38:41 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 166136B0073; Wed, 1 Dec 2021 03:38:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 114D96B0074; Wed, 1 Dec 2021 03:38:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 002216B0075; Wed, 1 Dec 2021 03:38:30 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id E5B236B0073 for ; Wed, 1 Dec 2021 03:38:30 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 8103389105 for ; Wed, 1 Dec 2021 08:38:20 +0000 (UTC) X-FDA: 78868573560.08.DA5F722 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by imf22.hostedemail.com (Postfix) with ESMTP id 4196A1904 for ; Wed, 1 Dec 2021 08:38:20 +0000 (UTC) Received: by mail-wr1-f54.google.com with SMTP id t9so33439657wrx.7 for ; Wed, 01 Dec 2021 00:38:19 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=spAN/Hm6eyYQRpVZG0bxWXSe/+KMWx87QIzxMeC45pg=; b=VShXYrwIvLwn41pbIkbQDZC5PXEQl4j022Xqb0CAzDeJ9pGDrjfxMfNilDEx7OLZA7 iMognj4R3FqaPnx3GDo7MNd/9H9nCIj7oBQQp2lnOz948wFptKwwXFcwYsJOzxDo9sua iP66iiaCMCw3BIyh0R4MQicDY+InxaGqbVWZClobDt0gIcXYbp6VY56vZBiAMAY3k7tT XWuWy7TwR20MQqTt9R0+JBVNqsg32lPZXCMrtidxrkfm9hguMoY/QET7uKIVxKqLAg1T rh3RT7nzo3nXsqEskuP69Lz0pU3rrVpFp8kU1CSc+XYtLFdySNf+rMgXQ/TEB97z8jWg iARg== X-Gm-Message-State: AOAM532buQE9iz6pgNFza/Ua74vwAQeN0CWM5hxXEEMLyDe+R3P5X6Rh w7YLg0oT9doLBLk3t59vkjg= X-Google-Smtp-Source: ABdhPJx22R0stTBem73oFqWNt/SE3yZ0IWIfzf02NhKlROqRQhHBNhMtD/P1c4bhO2ni4XDioecBIQ== X-Received: by 2002:a05:6000:15c7:: with SMTP id y7mr5128929wry.424.1638347898932; Wed, 01 Dec 2021 00:38:18 -0800 (PST) Received: from ?IPV6:2a0b:e7c0:0:107::70f? ([2a0b:e7c0:0:107::70f]) by smtp.gmail.com with ESMTPSA id d15sm25530187wri.50.2021.12.01.00.38.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 01 Dec 2021 00:38:18 -0800 (PST) Message-ID: <37511fa2-baed-c387-150c-3fa6b5b1c64f@kernel.org> Date: Wed, 1 Dec 2021 09:38:16 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH 2/3] mm: page table check Content-Language: en-US To: Pasha Tatashin , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, akpm@linux-foundation.org, rientjes@google.com, pjt@google.com, weixugc@google.com, gthelen@google.com, mingo@redhat.com, corbet@lwn.net, will@kernel.org, rppt@kernel.org, keescook@chromium.org, tglx@linutronix.de, peterz@infradead.org, masahiroy@kernel.org, samitolvanen@google.com, dave.hansen@linux.intel.com, x86@kernel.org, frederic@kernel.org, hpa@zytor.com, aneesh.kumar@linux.ibm.com References: <20211123214814.3756047-1-pasha.tatashin@soleen.com> <20211123214814.3756047-3-pasha.tatashin@soleen.com> From: Jiri Slaby In-Reply-To: <20211123214814.3756047-3-pasha.tatashin@soleen.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 4196A1904 X-Stat-Signature: n81epo9zq78ef6hawrmh4en4ykkpin1i Authentication-Results: imf22.hostedemail.com; dkim=none; spf=pass (imf22.hostedemail.com: domain of jirislaby@gmail.com designates 209.85.221.54 as permitted sender) smtp.mailfrom=jirislaby@gmail.com; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=kernel.org (policy=none) X-HE-Tag: 1638347900-530920 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: On 23. 11. 21, 22:48, Pasha Tatashin wrote: > Check user page table entries at the time they are added and removed. > > Allows to synchronously catch memory corruption issues related to > double mapping. > > When a pte for an anonymous page is added into page table, we verify > that this pte does not already point to a file backed page, and vice > versa if this is a file backed page that is being added we verify that > this page does not have an anonymous mapping > > We also enforce that read-only sharing for anonymous pages is allowed > (i.e. cow after fork). All other sharing must be for file pages. > > Page table check allows to protect and debug cases where "struct page" > metadata became corrupted for some reason. For example, when refcnt or > mapcount become invalid. > > Signed-off-by: Pasha Tatashin ... > --- a/mm/Kconfig.debug > +++ b/mm/Kconfig.debug > @@ -62,6 +62,30 @@ config PAGE_OWNER > > If unsure, say N. > > +config PAGE_TABLE_CHECK > + bool "Check for invalid mappings in user page tables" > + depends on ARCH_SUPPORTS_PAGE_TABLE_CHECK > + select PAGE_EXTENSION > + help > + Check that anonymous page is not being mapped twice with read write > + permissions. Check that anonymous and file pages are not being > + erroneously shared. Since the checking is performed at the time > + entries are added and removed to user page tables, leaking, corruption > + and double mapping problems are detected synchronously. > + > + If unsure say "n". > + > +config PAGE_TABLE_CHECK_ENFORCED > + bool "Enforce the page table checking by defauled" s/defauled/default/ regards, -- js suse labs