From: Andrew Morton <akpm@linux-foundation.org>
To: Ren Wei <enjou1224z@gmail.com>
Cc: linux-mm@kvack.org, pasha.tatashin@soleen.com, vega@nebusec.ai,
roxy520tt@gmail.com, Vlastimil Babka <vbabka@kernel.org>,
Suren Baghdasaryan <surenb@google.com>,
Michal Hocko <mhocko@suse.com>,
Brendan Jackman <jackmanb@google.com>,
Johannes Weiner <hannes@cmpxchg.org>
Subject: Re: [PATCH 1/1] mm/page_table_check: widen map counters
Date: Fri, 17 Jul 2026 22:11:08 -0700 [thread overview]
Message-ID: <20260717221108.c6caf7dd11a47bd7c32aa6ff@linux-foundation.org> (raw)
In-Reply-To: <b4414b588418c52a99d959d35a40e064ae8b6e72.1784337674.git.roxy520tt@gmail.com>
On Sat, 18 Jul 2026 12:27:20 +0800 Ren Wei <enjou1224z@gmail.com> wrote:
> From: Zhiling Zou <roxy520tt@gmail.com>
>
> page_table_check_set() and page_table_check_clear() store per-page
> anonymous and file map counts in signed atomic_t counters. A page can
> have more than INT_MAX read-only mappings while still being mapped
> legally.
>
> The global zero page is one example: repeated read faults on private
> anonymous mappings install read-only PTEs that are accounted as file
> mappings. Once file_map_count wraps, the next set or clear observes a
> negative count and trips BUG_ON(), allowing an unprivileged user to panic
> a kernel with CONFIG_PAGE_TABLE_CHECK enabled.
>
> Use atomic64_t for both counters so page_table_check can keep the same
> type-conflict checks without overflowing at INT_MAX mappings.
Thanks.
> Fixes: df4e817b7108 ("mm: page table check")
> Cc: stable@vger.kernel.org
>
> ...
>
> index 53a8997ec043..edd9d9edf6fc 100644
> --- a/mm/page_table_check.c
> +++ b/mm/page_table_check.c
> @@ -14,8 +14,8 @@
> #define pr_fmt(fmt) "page_table_check: " fmt
>
> struct page_table_check {
> - atomic_t anon_map_count;
> - atomic_t file_map_count;
> + atomic64_t anon_map_count;
> + atomic64_t file_map_count;
> };
AI review suggest this might cause problems in, of all places, page_ext.c:
https://sashiko.dev/#/patchset/b4414b588418c52a99d959d35a40e064ae8b6e72.1784337674.git.roxy520tt@gmail.com
My googling indicates that a 64-bit atomic op on a 32-bit-aligned
address is probably usually OK, but it doesn't sound smart.
Probably adding __aligned(sizeof(atomic64_t)) will address?
next prev parent reply other threads:[~2026-07-18 5:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1784337674.git.roxy520tt@gmail.com>
2026-07-18 4:27 ` [PATCH 1/1] mm/page_table_check: widen map counters Ren Wei
2026-07-18 5:11 ` Andrew Morton [this message]
2026-07-18 5:31 ` Andrew Morton
2026-07-18 10:21 ` tt roxy
2026-07-19 15:20 ` Pasha Tatashin
2026-07-18 5:17 ` Matthew Wilcox
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=20260717221108.c6caf7dd11a47bd7c32aa6ff@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=enjou1224z@gmail.com \
--cc=hannes@cmpxchg.org \
--cc=jackmanb@google.com \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=pasha.tatashin@soleen.com \
--cc=roxy520tt@gmail.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=vega@nebusec.ai \
/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