From: "David Hildenbrand (Arm)" <david@kernel.org>
To: "Mike Rapoport (Microsoft)" <rppt@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Alexander Potapenko <glider@google.com>,
Marco Elver <elver@google.com>,
"Rafael J. Wysocki" <rafael@kernel.org>
Cc: Dmitry Vyukov <dvyukov@google.com>, Len Brown <lenb@kernel.org>,
Pavel Machek <pavel@kernel.org>,
kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, linux-pm@vger.kernel.org
Subject: Re: [PATCH v2 4/5] hibernation, KFENCE: explicitly map/unmap KFENCE pages
Date: Mon, 28 Sep 2026 11:00:51 +0200 [thread overview]
Message-ID: <f2e718cd-92eb-4127-84fc-23f29396ccb6@kernel.org> (raw)
In-Reply-To: <20260926-hibernation-v2-4-235f69f3ab2a@kernel.org>
On 9/26/26 11:26, Mike Rapoport (Microsoft) wrote:
> The pages protected by KFENCE are removed from the direct map.
>
> safe_copy_page() temporarily maps and unmaps them using set_direct_map
> APIs, or, when the stars align, even using debug_pagealloc_map_pages().
>
> Neither of these APIs cares whether it is a KFENCE page and both blindly
> perform the update of the kernel page table for any non-present page.
>
> Ability to use debug_pagealloc_map_pages() to remap KFENCE pages when both
> KFENCE and debug_pagealloc are enabled is an amusing coincidence.
>
> But with increasing appetite for using set_direct_map for hardening
> purposes, it becomes too big of a hammer to enable saving any non-present
> page in the hibernation image.
>
> Another gotcha is that loongarch that does not have a direct map at all
> advertises ARCH_HAS_SET_DIRECT_MAP to allow coexistence of KFENCE and
> hibernation.
>
> Extend KFENCE with a bitmap that tracks which pages are protected and
> provide kfence_force_mapping() and kfence_reset_mapping() APIs that allow
> forced mapping and unmapping of KFENCE pages.
>
> Use these APIs in hibernate_{map,unmap}_pages() for KFENCE pages.
>
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>
> ---
Reviewed-by: David Hildenbrand (Arm) <david@kernel.org>
--
Cheers,
David
next prev parent reply other threads:[~2026-09-28 9:01 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-26 9:26 [PATCH v2 0/5] hibernation: make safe_copy_page more robust and remove debug_pagealloc support Mike Rapoport (Microsoft)
2026-09-26 9:26 ` [PATCH v2 1/5] hibernation: make swsusp_page helpers static Mike Rapoport (Microsoft)
2026-09-26 9:26 ` [PATCH v2 2/5] hibernation: ensure secretmem pages don't reach a snapshot Mike Rapoport (Microsoft)
2026-09-28 8:56 ` David Hildenbrand (Arm)
2026-09-26 9:26 ` [PATCH v2 3/5] hibernate: handle potential errors in hibernate_{map,unmap}_page() Mike Rapoport (Microsoft)
2026-09-28 8:58 ` David Hildenbrand (Arm)
2026-09-26 9:26 ` [PATCH v2 4/5] hibernation, KFENCE: explicitly map/unmap KFENCE pages Mike Rapoport (Microsoft)
2026-09-28 9:00 ` David Hildenbrand (Arm) [this message]
2026-09-26 9:26 ` [PATCH v2 5/5] hibernation: make hibernation unavailable when debug_pagealloc is on Mike Rapoport (Microsoft)
2026-09-27 22:02 ` [PATCH v2 0/5] hibernation: make safe_copy_page more robust and remove debug_pagealloc support Andrew Morton
2026-09-29 11:53 ` Rafael J. Wysocki (Intel)
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=f2e718cd-92eb-4127-84fc-23f29396ccb6@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=dvyukov@google.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-pm@vger.kernel.org \
--cc=pavel@kernel.org \
--cc=rafael@kernel.org \
--cc=rppt@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.