From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Andrey Smirnov <andrey.smirnov@siderolabs.com>,
pasha.tatashin@soleen.com, akpm@linux-foundation.org
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-riscv@lists.infradead.org, pjw@kernel.org,
palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr,
syzbot+2b5fe617654be3d8848b@syzkaller.appspotmail.com,
"Thomas Gleixner" <tglx@linutronix.de>,
"Thomas Weißschuh" <thomas.weissschuh@linutronix.de>,
"Andrei Vagin" <avagin@gmail.com>,
"Andy Lutomirski" <luto@kernel.org>,
"Vincenzo Frascino" <vincenzo.frascino@arm.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] mm/page_table_check: do not track special (PFN-mapped) PTEs
Date: Wed, 17 Jun 2026 13:07:14 +0200 [thread overview]
Message-ID: <e37721e1-75d6-4908-8f93-7c0f68a73eb9@kernel.org> (raw)
In-Reply-To: <20260608155758.1220420-1-andrey.smirnov@siderolabs.com>
On 6/8/26 17:57, Andrey Smirnov wrote:
> The vDSO data store ("[vvar]") special mapping is created as a VM_PFNMAP
> mapping and its pages are installed into userspace with vmf_insert_pfn(),
> which produces special PTEs (pte_special()). On x86 and arm64 (and riscv)
> pte_user_accessible_page() only tests the PRESENT/USER bits and does not
> exclude special PTEs, so page_table_check accounts these PFN mappings in
> the per-page anon/file map counters even though they are not rmap-managed
> pages (vm_normal_page() returns NULL for them).
>
> Most of these data pages live in the kernel image and are never freed, so
> the stray accounting is invisible. The time-namespace VVAR page is the
> exception: it is a real alloc_page() page that is released with
> __free_page() in free_time_ns() when the last task of a time namespace
> exits. Across the map / unmap / vdso_join_timens() zap transitions the
> special-PTE accounting is not balanced for this page, so a non-zero
> file_map_count survives to the free path and trips:
>
> kernel BUG at mm/page_table_check.c:143!
> __page_table_check_zero+0xfb/0x130
> __free_frozen_pages+0x52f/0x650
> free_time_ns+0x85/0xc0
> free_nsproxy+0x7f/0x130
> do_exit+0x313/0xa60
> do_group_exit+0x77/0x90
>
> This is reliably reproducible on x86_64 and arm64 under heavy container/CI
> churn that rapidly creates and destroys time namespaces (CLONE_NEWTIME via
> runc / docker-init / tini), and was independently reported by syzbot on
> riscv. It only manifests when CONFIG_PAGE_TABLE_CHECK is active.
>
> Special PTEs have no struct-page rmap semantics and must never have been
> tracked by page table check. Skip them in both the set and clear paths so
> the counters stay balanced (always zero) for PFN-mapped pages, regardless
> of how the architecture defines pte_user_accessible_page(). pte_special()
> is available generically (it is a no-op returning false on architectures
> without ARCH_HAS_PTE_SPECIAL), so this is a single, arch-independent fix.
Using pte_special() is usually a sign that something is likely shaky, as it
misses architectures that don't support CONFIG_ARCH_HAS_PTE_SPECIAL.
I assume relevant architectures (loongarch32?) do not support
CONFIG_PAGE_TABLE_CHECK.
arch/arm64/Kconfig: select ARCH_SUPPORTS_PAGE_TABLE_CHECK
arch/powerpc/Kconfig: select ARCH_SUPPORTS_PAGE_TABLE_CHECK if !HUGETLB_PAGE
arch/riscv/Kconfig: select ARCH_SUPPORTS_PAGE_TABLE_CHECK if MMU
arch/s390/Kconfig: select ARCH_SUPPORTS_PAGE_TABLE_CHECK
arch/x86/Kconfig: select ARCH_SUPPORTS_PAGE_TABLE_CHECK if X86_64
mm/Kconfig.debug: depends on ARCH_SUPPORTS_PAGE_TABLE_CHECK
Can we enforce somehow that we expect CONFIG_ARCH_HAS_PTE_SPECIAL, so anybody
unlocking ARCH_SUPPORTS_PAGE_TABLE_CHECK is aware of this?
For example, through a BUILD_BUG_ON?
--
Cheers,
David
prev parent reply other threads:[~2026-06-17 11:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 15:57 Andrey Smirnov
2026-06-08 21:22 ` Andrew Morton
2026-06-09 2:23 ` Pasha Tatashin
2026-06-12 14:24 ` Thomas Weißschuh
2026-06-17 11:07 ` David Hildenbrand (Arm) [this message]
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=e37721e1-75d6-4908-8f93-7c0f68a73eb9@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alex@ghiti.fr \
--cc=andrey.smirnov@siderolabs.com \
--cc=aou@eecs.berkeley.edu \
--cc=avagin@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-riscv@lists.infradead.org \
--cc=luto@kernel.org \
--cc=palmer@dabbelt.com \
--cc=pasha.tatashin@soleen.com \
--cc=pjw@kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+2b5fe617654be3d8848b@syzkaller.appspotmail.com \
--cc=tglx@linutronix.de \
--cc=thomas.weissschuh@linutronix.de \
--cc=vincenzo.frascino@arm.com \
/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
Powered by JetHome