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 22828C433F5 for ; Wed, 8 Dec 2021 00:05:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D5376B0072; Tue, 7 Dec 2021 19:05:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 45D846B0073; Tue, 7 Dec 2021 19:05:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D7716B0074; Tue, 7 Dec 2021 19:05:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0206.hostedemail.com [216.40.44.206]) by kanga.kvack.org (Postfix) with ESMTP id 17AC16B0072 for ; Tue, 7 Dec 2021 19:05:25 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id BA1B68248D52 for ; Wed, 8 Dec 2021 00:05:14 +0000 (UTC) X-FDA: 78892682148.03.0ADF619 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf30.hostedemail.com (Postfix) with ESMTP id 5081AE0016B0 for ; Wed, 8 Dec 2021 00:05:14 +0000 (UTC) Received: from mail.kernel.org (unknown [198.145.29.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B9225B81EC4; Wed, 8 Dec 2021 00:05:12 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 8367560EBC; Wed, 8 Dec 2021 00:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1638921911; bh=uA2tjAPOCqPu5oyDY/yHUgBofZT6FAsAe0t5Dw+fZkg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=bxc/cdmU3aqOjKzv01krX8OHbweiZx256hr8gZQYWIBDw6i1vABexDTh5t1ra9uAQ bXh8lmbW4LHS9g5DnBZw1yOUF8maQw7dnkPSZau2LbWPUlIOWDN5S/SRb+fSI8+/E0 JvjfCe4t5ZHJVXEb47lL+r2v2TVf9QkU0BTKqEPI= Date: Tue, 7 Dec 2021 16:05:08 -0800 From: Andrew Morton To: Pasha Tatashin Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.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, jirislaby@kernel.org, songmuchun@bytedance.com, qydwhotmail@gmail.com Subject: Re: [PATCH v2 3/4] mm: page table check Message-Id: <20211207160508.6ef48f273c1ae14c0d02c6ac@linux-foundation.org> In-Reply-To: <20211204182314.1470076-4-pasha.tatashin@soleen.com> References: <20211204182314.1470076-1-pasha.tatashin@soleen.com> <20211204182314.1470076-4-pasha.tatashin@soleen.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5081AE0016B0 X-Stat-Signature: 7fij48u8pfwjqsy7py4569qmd73ts7ep Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b="bxc/cdmU"; spf=pass (imf30.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-HE-Tag: 1638921914-639295 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 Sat, 4 Dec 2021 18:23:13 +0000 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. > > ... > > --- a/arch/Kconfig > +++ b/arch/Kconfig > @@ -1307,6 +1307,9 @@ config HAVE_ARCH_PFN_VALID > config ARCH_SUPPORTS_DEBUG_PAGEALLOC > bool > > +config ARCH_SUPPORTS_PAGE_TABLE_CHECK > + bool > + I guess a dependency on CONFIG_DEBUG_VM would be appropriate?