mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
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 5/5] hibernation: make hibernation unavailable when debug_pagealloc is on
Date: Wed, 23 Sep 2026 12:24:41 +0200	[thread overview]
Message-ID: <5f950806-3e76-4a16-9511-a23719125f4b@kernel.org> (raw)
In-Reply-To: <20260917-hibernation-v1-5-7f7dfae3dbe0@kernel.org>

On 9/17/26 08:07, Mike Rapoport (Microsoft) wrote:
> Back in 2008 when commit 8a235efad548a ("Hibernation: Handle
> DEBUG_PAGEALLOC on x86") enabled coexistence of hibernation and
> DEBUG_PAGEALLOC, the world was simpler, the combination was only supported
> on x86 and a non-present page in the direct map meant that the page was
> free and debug_pagealloc removed its mapping.
> 
> Nowadays there are more architectures with inconsistent views of how the
> direct map should be managed, there are more debug mechanisms in MM that
> can either drop a page from the direct map (e.g. KFENCE) or require that a
> page must be mapped immediately after resume (e.g. init_on_free).
> 
> The latter constraint is particularly nasty, because enabling
> debug_pagealloc and PAGE_POISON at the same time simply breaks resume:
> 
>   BUG: unable to handle page fault for address: ffff888000100000
>   #PF: supervisor write access in kernel mode
>   #PF: error_code(0x0002) - not-present page
>   PGD 4f0c067 P4D 4f0c067 PUD 4f0d067 PMD 4f0e067 PTE 800fffffffeff020
>   Oops: Oops: 0002 [#1] SMP DEBUG_PAGEALLOC NOPTI
>   CPU: 0 UID: 0 PID: 477 Comm: bash Not tainted 7.3.0-rc3-00090-g4a613f1d9124 #1 PREEMPT(full)
>   Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS 1.17.0-debian-1.17.0-1 04/01/2014
>   RIP: 0010:__kernel_poison_pages+0x45/0x70
>   Code: 89 fa 48 c1 e6 06 48 01 fe 48 89 d1 48 2b 0d 9a ed 87 01 48 83 c2 40 48 c1 f9 06 48 c1 e1 0c 48 03 0d 97 ed 87 01 48 8d 79 08 <48> 89 01 48 83 e7 f8 48 89 81 f8 0f 00 00 48 29 f9 81 c1 00 10 00
>   RSP: 0018:ffffc900017dfd78 EFLAGS: 00010086
>   RAX: aaaaaaaaaaaaaaaa RBX: 0000000000000000 RCX: ffff888000100000
>   RDX: ffffea0000004040 RSI: ffffea0000004040 RDI: ffff888000100008
>   RBP: 0000000000000000 R08: ffff888130fcada0 R09: 00000000723e0de4
>   R10: 0000000096ad9215 R11: 00000000db907bcf R12: 0000000000000005
>   R13: 0000000000000005 R14: 0000000000000000 R15: 0000000000000000
>   FS:  00007f8f2243e780(0000) GS:ffff8882e8e13000(0000) knlGS:0000000000000000
>   CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>   CR2: ffff888000100000 CR3: 0000000140679000 CR4: 0000000000750ef0
>   PKRU: 55555554
>   Call Trace:
>    <TASK>
>    clear_or_poison_free_pages+0xd1/0xe0
>    hibernation_snapshot+0x548/0x5a0
>    hibernate.cold+0xcb/0x321
>    state_store+0xc3/0xd0
>    kernfs_fop_write_iter+0x163/0x240
>    vfs_write+0x21f/0x550
>    ksys_write+0x70/0xf0
>    do_syscall_64+0xb1/0x590
>    ? __irq_exit_rcu+0x40/0x110
>    entry_SYSCALL_64_after_hwframe+0x76/0x7e
>   RIP: 0033:0x7f8f224d0687
>   Code: 48 89 fa 4c 89 df e8 58 b3 00 00 8b 93 08 03 00 00 59 5e 48 83 f8 fc 74 1a 5b c3 0f 1f 84 00 00 00 00 00 48 8b 44 24 10 0f 05 <5b> c3 0f 1f 80 00 00 00 00 83 e2 39 83 fa 08 75 de e8 23 ff ff ff
>   RSP: 002b:00007ffe7bbe0910 EFLAGS: 00000202 ORIG_RAX: 0000000000000001
>   RAX: ffffffffffffffda RBX: 00007f8f2243e780 RCX: 00007f8f224d0687
>   RDX: 0000000000000005 RSI: 000055e3e53135d0 RDI: 0000000000000001
>   RBP: 000055e3e53135d0 R08: 0000000000000000 R09: 0000000000000000
>   R10: 0000000000000000 R11: 0000000000000202 R12: 0000000000000005
>   R13: 00007f8f226295c0 R14: 00007f8f22626e80 R15: 0000000000000000
>    </TASK>
>   Modules linked in:
>   CR2: ffff888000100000
> 
> It's possible to build a complex infrastructure involving a new page flag
> and/or page_type to allow robust hibernation and restore with
> debug_pagealloc enabled.
> 
> This infrastructure requires a proper detection whether it is safe to
> temporarily remap a page to include it in the hibernation snapshot because
> relying on kernel_page_present() is too permissive and may include pages
> that were deliberately removed from the direct map for security reasons.
> 
> This complexity does not seem justified to deal with an esoteric use case
> of hibernating a system that runs with debug_pagealloc enabled.
> 
> Make hibernation unavailable when debug_pagealloc is enabled and simplify
> hibernate_{map,unmap}_page() that don't need to deal with debug_pagealloc
> anymore.
> 
> Signed-off-by: Mike Rapoport (Microsoft) <rppt@kernel.org>

Acked-by: David Hildenbrand (Arm) <david@kernel.org>

-- 
Cheers,

David

  reply	other threads:[~2026-09-23 10:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-17  6:07 [PATCH 0/5] hibernation: make safe_copy_page more robust and remove debug_pagealloc support Mike Rapoport (Microsoft)
2026-09-17  6:07 ` [PATCH 1/5] hibernation: make swsusp_page helpers static Mike Rapoport (Microsoft)
2026-09-23 10:08   ` David Hildenbrand (Arm)
2026-09-17  6:07 ` [PATCH 2/5] hibernation: ensure secretmem pages don't reach a snapshot Mike Rapoport (Microsoft)
2026-09-23 10:10   ` David Hildenbrand (Arm)
2026-09-23 15:38     ` Mike Rapoport
2026-09-17  6:07 ` [PATCH 3/5] hibernate: handle potential errors in hibernate_{map,unmap}_page() Mike Rapoport (Microsoft)
2026-09-23 10:13   ` David Hildenbrand (Arm)
2026-09-23 15:42     ` Mike Rapoport
2026-09-17  6:07 ` [PATCH 4/5] hibernation, KFENCE: explicitly map/unmap KFENCE pages Mike Rapoport (Microsoft)
2026-09-23 10:31   ` David Hildenbrand (Arm)
2026-09-23 15:49     ` Mike Rapoport
2026-09-17  6:07 ` [PATCH 5/5] hibernation: make hibernation unavailable when debug_pagealloc is on Mike Rapoport (Microsoft)
2026-09-23 10:24   ` David Hildenbrand (Arm) [this message]
2026-09-23  9:26 ` [PATCH 0/5] hibernation: make safe_copy_page more robust and remove debug_pagealloc support Mike Rapoport

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=5f950806-3e76-4a16-9511-a23719125f4b@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®