From: Pasha Tatashin <pasha.tatashin@soleen.com>
To: Jonathan Corbet <corbet@lwn.net>
Cc: LKML <linux-kernel@vger.kernel.org>,
linux-mm <linux-mm@kvack.org>,
Linux Doc Mailing List <linux-doc@vger.kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
David Rientjes <rientjes@google.com>,
Paul Turner <pjt@google.com>,
weixugc@google.com, Greg Thelen <gthelen@google.com>,
Ingo Molnar <mingo@redhat.com>, Will Deacon <will@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Kees Cook <keescook@chromium.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
masahiroy@kernel.org, Sami Tolvanen <samitolvanen@google.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
"maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
<x86@kernel.org>,
frederic@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: Re: [RFC 2/3] mm: page table check
Date: Wed, 17 Nov 2021 11:47:08 -0500 [thread overview]
Message-ID: <CA+CK2bCwHeodpyfHqSzqQWFTrJEYyYFeythYoMAD2eYw7BfNKg@mail.gmail.com> (raw)
In-Reply-To: <878rxngq6g.fsf@meer.lwn.net>
> > Documentation/vm/page_table_check.rst | 53 ++++++
>
> Thanks for documenting this feature! When you add a new RST file,
> though, you need to add it to the index.rst file as well so that it is
> included in the docs build.
I will add the index.rst changes.
>
> > MAINTAINERS | 9 +
> > arch/Kconfig | 3 +
> > include/linux/page_table_check.h | 147 ++++++++++++++
> > mm/Kconfig.debug | 24 +++
> > mm/Makefile | 1 +
> > mm/page_alloc.c | 4 +
> > mm/page_ext.c | 4 +
> > mm/page_table_check.c | 264 ++++++++++++++++++++++++++
> > 9 files changed, 509 insertions(+)
> > create mode 100644 Documentation/vm/page_table_check.rst
> > create mode 100644 include/linux/page_table_check.h
> > create mode 100644 mm/page_table_check.c
> >
> > diff --git a/Documentation/vm/page_table_check.rst b/Documentation/vm/page_table_check.rst
> > new file mode 100644
> > index 000000000000..41435a45869f
> > --- /dev/null
> > +++ b/Documentation/vm/page_table_check.rst
> > @@ -0,0 +1,53 @@
> > +.. SPDX-License-Identifier: GPL-2.0
> > +
> > +.. _page_table_check:
>
> Do you need this label for anything? As-is it's just added visual
> clutter and could come out.
Sure, I will remove it
>
> > +================
> > +Page Table Check
> > +================
> > +
> > +Page table check allows to hardern the kernel by ensuring that some types of
> > +memory corruptions are prevented.
> > +
> > +Page table check performs extra verifications at the time when new pages become
> > +accessible from 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 page table check. Thereofre, it
> > +is disabled by default but can be optionally enabled on systems where extra
> > +hardening outweighs the 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
> > +==============================
>
> I'd use subsection markup (single "==========" line underneath) for the
> subsections.
I will change to subsection.
Thanks,
Pasha
On Wed, Nov 17, 2021 at 3:08 AM Jonathan Corbet <corbet@lwn.net> wrote:
>
> Pasha Tatashin <pasha.tatashin@soleen.com> writes:
>
> > 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 <pasha.tatashin@soleen.com>
> > ---
> > Documentation/vm/page_table_check.rst | 53 ++++++
>
> Thanks for documenting this feature! When you add a new RST file,
> though, you need to add it to the index.rst file as well so that it is
> included in the docs build.
>
> > MAINTAINERS | 9 +
> > arch/Kconfig | 3 +
> > include/linux/page_table_check.h | 147 ++++++++++++++
> > mm/Kconfig.debug | 24 +++
> > mm/Makefile | 1 +
> > mm/page_alloc.c | 4 +
> > mm/page_ext.c | 4 +
> > mm/page_table_check.c | 264 ++++++++++++++++++++++++++
> > 9 files changed, 509 insertions(+)
> > create mode 100644 Documentation/vm/page_table_check.rst
> > create mode 100644 include/linux/page_table_check.h
> > create mode 100644 mm/page_table_check.c
> >
> > diff --git a/Documentation/vm/page_table_check.rst b/Documentation/vm/page_table_check.rst
> > new file mode 100644
> > index 000000000000..41435a45869f
> > --- /dev/null
> > +++ b/Documentation/vm/page_table_check.rst
> > @@ -0,0 +1,53 @@
> > +.. SPDX-License-Identifier: GPL-2.0
> > +
> > +.. _page_table_check:
>
> Do you need this label for anything? As-is it's just added visual
> clutter and could come out.
>
> > +================
> > +Page Table Check
> > +================
> > +
> > +Page table check allows to hardern the kernel by ensuring that some types of
> > +memory corruptions are prevented.
> > +
> > +Page table check performs extra verifications at the time when new pages become
> > +accessible from 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 page table check. Thereofre, it
> > +is disabled by default but can be optionally enabled on systems where extra
> > +hardening outweighs the 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
> > +==============================
>
> I'd use subsection markup (single "==========" line underneath) for the
> subsections.
>
> > ++-------------------+-------------------+-------------------+------------------+
> > +| Current Mapping | New mapping | Permissions | Rule |
> > ++===================+===================+===================+==================+
> > +| Anonymous | Anonymous | Read | Allow |
> > ++-------------------+-------------------+-------------------+------------------+
> > +| Anonymous | Anonymous | Read / Write | Prohibit |
> > ++-------------------+-------------------+-------------------+------------------+
> > +| Anonymous | Named | Any | Prohibit |
> > ++-------------------+-------------------+-------------------+------------------+
> > +| Named | Anonymous | Any | Prohibit |
> > ++-------------------+-------------------+-------------------+------------------+
> > +| Named | Named | Any | Allow |
> > ++-------------------+-------------------+-------------------+------------------+
> > +
> > +=========================
> > +Enabling Page Table Check
> > +=========================
> > +
> > +Build kernel with:
> > +
> > +- PAGE_TABLE_CHECK=y
> > +Note, it can only be enabled on platforms where ARCH_SUPPORTS_PAGE_TABLE_CHECK
> > +is available.
> > +- Boot with 'page_table_check=on' kernel parameter.
> > +
> > +Optionally, build kernel with PAGE_TABLE_CHECK_ENFORCED in order to have page
> > +table support without extra kernel parameter.
>
> Thanks,
>
> jon
next prev parent reply other threads:[~2021-11-17 16:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-16 22:00 [RFC 0/3] " Pasha Tatashin
2021-11-16 22:00 ` [RFC 1/3] mm: ptep_clear() page table helper Pasha Tatashin
2021-11-17 8:51 ` Anshuman Khandual
2021-11-17 16:43 ` Pasha Tatashin
2021-11-16 22:00 ` [RFC 2/3] mm: page table check Pasha Tatashin
2021-11-17 8:08 ` Jonathan Corbet
2021-11-17 16:47 ` Pasha Tatashin [this message]
2021-11-16 22:00 ` [RFC 3/3] x86: mm: add x86_64 support for " Pasha Tatashin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+CK2bCwHeodpyfHqSzqQWFTrJEYyYFeythYoMAD2eYw7BfNKg@mail.gmail.com \
--to=pasha.tatashin@soleen.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=corbet@lwn.net \
--cc=dave.hansen@linux.intel.com \
--cc=frederic@kernel.org \
--cc=gthelen@google.com \
--cc=hpa@zytor.com \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=masahiroy@kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=pjt@google.com \
--cc=rientjes@google.com \
--cc=rppt@kernel.org \
--cc=samitolvanen@google.com \
--cc=tglx@linutronix.de \
--cc=weixugc@google.com \
--cc=will@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox