Re: [PATCH] x86/hpet: Mark boot-time variables as __ro_after_init
From: Habil Eren Türker
Date: Thu Nov 19 2026 - 15:37:55 EST
On Thu, 19 Nov 2026, 11:40:32, -0800, Dave Hansen wrote:
> How did you find this? Why does it matter?
Hi Dave,
I found this by auditing the HPET code for variables that are only
written during early boot. I used `git grep` to trace every write
access to these variables and confirmed that all modifications happen
exclusively in __init functions or early setup paths.
Here is the exact breakdown from the tree:
- hpet_blockid: Written only in acpi_parse_hpet()
(arch/x86/kernel/acpi/boot.c:907), which is an __init function.
- hpet_msi_disable: Written only in early_disable_hpet_msi()
(arch/x86/kernel/quirks.c:529), an early PCI quirk.
- hpet_freq: Written only in hpet_enable()
(arch/x86/kernel/hpet.c:1022), which is __init.
- boot_hpet_disable: Written only in early-quirks.c:624 and __init
setup functions in hpet.c (lines 111, 124, 984).
Why it matters:
Marking these as __ro_after_init hardens the kernel by placing them in the
read-only data section post-init. This prevents accidental or malicious
runtime modifications (e.g., via a memory corruption exploit) that could
silently corrupt HPET frequencies or block IDs, causing severe timing
issues or system hangs.
It also explicitly documents the intent for future developers that
these are strictly boot-time variables.
Let me know if there is anything else needed.
Regards,
Türker