diff mbox series

[RFC,v2,08/21] psci: Fix the function type for psci_initcall_t

Message ID 20220513202159.1550547-9-samitolvanen@google.com (mailing list archive)
State New, archived
Headers show
Series KCFI support | expand

Commit Message

Sami Tolvanen May 13, 2022, 8:21 p.m. UTC
Functions called through a psci_initcall_t pointer all have
non-const arguments. Fix the type definition to avoid tripping
indirect call checks with CFI_CLANG.

Reported-by: Mark Rutland <mark.rutland@arm.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
 drivers/firmware/psci/psci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Kees Cook May 14, 2022, 9:50 p.m. UTC | #1
On Fri, May 13, 2022 at 01:21:46PM -0700, Sami Tolvanen wrote:
> Functions called through a psci_initcall_t pointer all have
> non-const arguments. Fix the type definition to avoid tripping
> indirect call checks with CFI_CLANG.
> 
> Reported-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

This could land separately from this series, too, yes?

Reviewed-by: Kees Cook <keescook@chromium.org>
Sami Tolvanen May 16, 2022, 3:44 p.m. UTC | #2
On Sat, May 14, 2022 at 2:50 PM Kees Cook <keescook@chromium.org> wrote:
>
> On Fri, May 13, 2022 at 01:21:46PM -0700, Sami Tolvanen wrote:
> > Functions called through a psci_initcall_t pointer all have
> > non-const arguments. Fix the type definition to avoid tripping
> > indirect call checks with CFI_CLANG.
> >
> > Reported-by: Mark Rutland <mark.rutland@arm.com>
> > Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
>
> This could land separately from this series, too, yes?

Correct.

Sami
Mark Rutland May 17, 2022, 8:47 a.m. UTC | #3
On Fri, May 13, 2022 at 01:21:46PM -0700, Sami Tolvanen wrote:
> Functions called through a psci_initcall_t pointer all have
> non-const arguments. Fix the type definition to avoid tripping
> indirect call checks with CFI_CLANG.
> 
> Reported-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

I'd prefer that we spread the `const` to each of the implementations rather
than dropping it from the type.

I have a local patch for that I can send out shortly.

Thanks,
Mark.

> ---
>  drivers/firmware/psci/psci.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
> index cfb448eabdaa..6554bf4b8c99 100644
> --- a/drivers/firmware/psci/psci.c
> +++ b/drivers/firmware/psci/psci.c
> @@ -521,7 +521,7 @@ static int __init psci_probe(void)
>  	return 0;
>  }
>  
> -typedef int (*psci_initcall_t)(const struct device_node *);
> +typedef int (*psci_initcall_t)(struct device_node *);
>  
>  /*
>   * PSCI init function for PSCI versions >=0.2
> -- 
> 2.36.0.550.gb090851708-goog
>
diff mbox series

Patch

diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index cfb448eabdaa..6554bf4b8c99 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -521,7 +521,7 @@  static int __init psci_probe(void)
 	return 0;
 }
 
-typedef int (*psci_initcall_t)(const struct device_node *);
+typedef int (*psci_initcall_t)(struct device_node *);
 
 /*
  * PSCI init function for PSCI versions >=0.2