All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Yo'av Moshe" <linux@yoavmoshe.com>
Cc: Frank.Li@kernel.org, imx@lists.linux.dev
Subject: Re: [PATCH v5] ARM: imx: Fix suspend/resume crash with Clang CFI
Date: Sun, 30 Aug 2026 16:05:06 +0000	[thread overview]
Message-ID: <20260830160506.84C701F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830155100.1020620-1-linux@yoavmoshe.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Global CFI Check Failure on fncpy() copied Suspend/PM routines (IMX5, AT91, OMAP1) due to missing kCFI hashes.
--

commit 24f4d3cbee4d4f64e23b67ce2fbbb6d3e3eb8db1
Author: Yo'av Moshe <linux@yoavmoshe.com>

ARM: imx: Fix suspend/resume crash with Clang CFI

The suspend code that runs from OCRAM is copied there with fncpy(), which does
not copy the kCFI type hash preceding the function. With CONFIG_CFI=y the
indirect call through imx6_suspend_in_ocram_fn therefore panics.

> diff --git a/arch/arm/mach-imx/pm-imx6.c b/arch/arm/mach-imx/pm-imx6.c
> index a671ca498f887..3c73e2cdb8ceb 100644
> --- a/arch/arm/mach-imx/pm-imx6.c
> +++ b/arch/arm/mach-imx/pm-imx6.c

[ ... ]

> @@ -568,6 +581,13 @@ static int __init imx6q_suspend_init(const struct imx6_pm_socdata *socdata)
>  			mmdc_offset_array[i]);
>  	}
>  
> +	/*
> +	 * Mask out the Thumb bit, as cfi_get_func_hash() expects the
> +	 * function's actual start address. Returns 0 if CONFIG_CFI=n.
> +	 */
> +	pm_info->cfi_type =
> +		cfi_get_func_hash((void *)((uintptr_t)&imx6_suspend & ~1UL));
> +
>  	imx6_suspend_in_ocram_fn = fncpy(
>  		suspend_ocram_base + sizeof(*pm_info),
>  		&imx6_suspend,
[Severity: High]
This isn't a bug introduced by this patch, but since fncpy() strips the 4-byte
kCFI type hash during SRAM copying, wouldn't other ARM architectures using
fncpy() for suspend routines also fail their CFI checks and panic in the exact
same way?

For instance, this happens during suspend or idle when the copied PM routine
is called indirectly.

In arch/arm/mach-imx/pm-imx5.c:mx5_suspend_enter():
    if (imx5_suspend_in_ocram_fn)
        imx5_suspend_in_ocram_fn(suspend_ocram_base);

In arch/arm/mach-at91/pm.c:at91_pm_suspend():
    at91_suspend_sram_fn(&soc_pm.data);

In arch/arm/mach-omap1/pm.c:omap1_pm_idle():
    omap_sram_suspend(omap_readl(ARM_IDLECT1),
                      omap_readl(ARM_IDLECT2));

In arch/arm/mach-omap1/pm.c:omap1_pm_suspend():
    omap_sram_suspend(arg0, arg1);

Do these architectures need a similar fix to ensure the kCFI hash is
physically located before the function copy in SRAM?

>  		MX6Q_SUSPEND_OCRAM_SIZE - sizeof(*pm_info));

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260830155100.1020620-1-linux@yoavmoshe.com?part=1

  reply	other threads:[~2026-08-30 16:05 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18 11:13 [PATCH v3] ARM: imx: Fix suspend/resume crash with Clang CFI Yo'av Moshe
2026-07-18 11:29 ` sashiko-bot
2026-07-20 16:53 ` Nick Desaulniers
2026-07-21  5:20   ` Yo'av Moshe
2026-07-20 19:29 ` Sami Tolvanen
2026-07-21  5:29   ` Yo'av Moshe
2026-07-21 18:09     ` Nathan Chancellor
2026-07-22 12:53       ` Yo'av Moshe
2026-07-22 15:00         ` Sami Tolvanen
2026-07-22 17:46           ` Yo'av Moshe
2026-07-22 18:03             ` Sami Tolvanen
2026-07-23 13:30               ` Yo'av Moshe
2026-07-23 19:21                 ` Sami Tolvanen
2026-07-23 19:55                   ` Yo'av Moshe
2026-07-24 15:53                     ` Sami Tolvanen
2026-07-24 20:49                       ` Nick Desaulniers
2026-07-26 15:36                         ` Yo'av Moshe
2026-08-17 17:45                           ` Yo'av Moshe
2026-08-17 21:31                             ` Frank Li
2026-08-17 21:58                           ` Nick Desaulniers
2026-08-24 14:09                             ` Yo'av Moshe
2026-08-25 17:33                               ` Nick Desaulniers
2026-08-27 16:55                                 ` Yo'av Moshe
2026-08-27 19:45 ` [PATCH v4] " Yo'av Moshe
2026-08-28 18:29   ` Nick Desaulniers
2026-08-28 18:45     ` Sami Tolvanen
2026-08-28 20:19       ` Nick Desaulniers
2026-08-28 20:50         ` Sami Tolvanen
2026-08-30 16:24           ` Yo'av Moshe
2026-09-01 19:45             ` Sami Tolvanen
2026-09-01 20:36               ` Nick Desaulniers
2026-09-02 16:44                 ` Frank Li
2026-09-02 17:10                   ` Nick Desaulniers
2026-09-02 17:11                     ` Nick Desaulniers
2026-09-02 18:38                     ` Nathan Chancellor
2026-08-30 15:51   ` [PATCH v5] " Yo'av Moshe
2026-08-30 16:05     ` sashiko-bot [this message]
2026-09-01 19:39     ` Sami Tolvanen
2026-09-02 19:37     ` Frank.Li

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=20260830160506.84C701F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux@yoavmoshe.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.