[PATCH v2] ARM: imx: Fix suspend/resume crash with Clang CFI
Yo'av Moshe <[email protected]> Sat, 18 Jul 2026 11:19:17 +0200
| Newsgroups | dev.linux.lists.llvm,dev.linux.lists.imx,org.infradead.lists.linux-arm-kernel,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
Relocated suspend code in OCRAM lacks compiler-generated CFI type signatures. When CONFIG_CFI=y is active, the indirect call to imx6_suspend_in_ocram_fn triggers a strict CFI violation panic. Annotate imx6q_suspend_finish with __nocfi to bypass CFI checking for this specific indirect call. Additionally, protect the imx6_suspend_in_ocram_fn pointer by marking it __ro_after_init to prevent it from being used as a CFI bypass exploit vector. Cc: [email protected] Signed-off-by: Yo'av Moshe <[email protected]> --- Tested on a Kobo Clara HD (i.MX6SLL SoC) running postmarketOS edge. Before this patch, suspending the device caused an immediate silent hang requiring a hard-reboot. With this patch applied, suspend and resume work successfully. Differences from v1: - Added __ro_after_init to imx6_suspend_in_ocram_fn to prevent it from being exploited as a CFI bypass gadget. arch/arm/mach-imx/pm-imx6.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c index a671ca498..b425a4701 100644 --- a/arch/arm/mach-imx/pm-imx6.c +++ b/arch/arm/mach-imx/pm-imx6.c @@ -63,7 +63,7 @@ static void __iomem *ccm_base; static void __iomem *suspend_ocram_base; -static void (*imx6_suspend_in_ocram_fn)(void __iomem *ocram_vbase); +static void (*imx6_suspend_in_ocram_fn)(void __iomem *ocram_vbase) __ro_after_init; /* * suspend ocram space layout: @@ -360,7 +360,7 @@ int imx6_set_lpm(enum mxc_cpu_pwr_mode mode) return 0; } -static int imx6q_suspend_finish(unsigned long val) +static int __nocfi imx6q_suspend_finish(unsigned long val) { if (!imx6_suspend_in_ocram_fn) { cpu_do_idle(); -- 2.55.0