scsi: elx: libefc: Fix second parameter type in state callbacks
Subsystems (3)
PATCH 1/1 scsi: elx: libefc: Fix second parameter type in state callbacks
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/scsi/elx/libefc/efc_node.c:811:22: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict]
ctx->current_state = state;
^ ~~~~~
drivers/scsi/elx/libefc/efc_node.c:878:21: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict]
node->nodedb_state = state;
^ ~~~~~
drivers/scsi/elx/libefc/efc_node.c:905:6: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' from 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') [-Werror,-Wincompatible-function-pointer-types-strict]
pf = node->nodedb_state;
^ ~~~~~~~~~~~~~~~~~~
drivers/scsi/elx/libefc/efc_device.c:455:22: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict]
node->nodedb_state = __efc_d_init;
^ ~~~~~~~~~~~~
drivers/scsi/elx/libefc/efc_sm.c:41:22: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict]
ctx->current_state = state;
^ ~~~~~The type of the second parameter in the prototypes of ->current_state() and ->nodedb_state() ('u32') does not match the implementations, which have a second parameter type of 'enum efc_sm_event'. Update the prototypes to have the correct second parameter type, clearing up all the warnings and CFI failures.
--- drivers/scsi/elx/libefc/efclib.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/scsi/elx/libefc/efclib.h +4 -2
@@ -58,10 +58,12 @@ enum efc_node_send_ls_acc {#define EFC_LINK_STATUS_UP 0#define EFC_LINK_STATUS_DOWN 1 +enum efc_sm_event ; +/* State machine context header */ struct efc_sm_ctx {void (*current_state)(struct efc_sm_ctx *ctx, -u32 evt,void *arg); +enum efc_sm_event evt,void *arg);const char *description;void *app;
@@ -365,7 +367,7 @@ struct efc_node {int prev_evt;void (*nodedb_state)(struct efc_sm_ctx *ctx, -u32 evt,void *arg); +enum efc_sm_event evt,void *arg);struct timer_list gidpt_delay_timer;u64 time_last_gidpt_msec;
base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
Signature · 1 line
2.38.1
Quoted 32 lines · Nathan Chancellor
With clang's kernel control flow integrity (kCFI,
CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:drivers/scsi/elx/libefc/efc_node.c:811:22: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict] ctx->current_state = state; ^ ~~~~~ drivers/scsi/elx/libefc/efc_node.c:878:21: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict] node->nodedb_state = state; ^ ~~~~~ drivers/scsi/elx/libefc/efc_node.c:905:6: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' from 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') [-Werror,-Wincompatible-function-pointer-types-strict] pf = node->nodedb_state; ^ ~~~~~~~~~~~~~~~~~~ drivers/scsi/elx/libefc/efc_device.c:455:22: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict] node->nodedb_state = __efc_d_init; ^ ~~~~~~~~~~~~ drivers/scsi/elx/libefc/efc_sm.c:41:22: error: incompatible function pointer types assigning to 'void (*)(struct efc_sm_ctx *, u32, void *)' (aka 'void (*)(struct efc_sm_ctx *, unsigned int, void *)') from 'void (*)(struct efc_sm_ctx *, enum efc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict] ctx->current_state = state; ^ ~~~~~The type of the second parameter in the prototypes of ->current_state() and ->nodedb_state() ('u32') does not match the implementations, which have a second parameter type of 'enum
efc_sm_event'. Update the prototypes to have the correct second parameter type, clearing up all the warnings and CFI failures.
Quoted 3 lines
Reported-by Sami Tolvanen <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>
Signature · 1 line
Kees Cook
Quoted 53 lines · Kees Cook
Quoted 9 lines · Nathan Chancellor
With clang's kernel control flow integrity (kCFI,
CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
drivers/scsi/elx/libefc/efc_node.c:811:22: error: incompatiblefunction pointer types assigning to 'void (*)(struct
efc_sm_ctx*, u32, void *)' (aka 'void (*)(structefc_sm_ctx*, unsigned int, void *)') from 'void (*)(structefc_sm_ctx*, enumefc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict]Quoted 3 lines
ctx->current_state = state; ^ ~~~~~
drivers/scsi/elx/libefc/efc_node.c:878:21: error: incompatiblefunction pointer types assigning to 'void (*)(struct
efc_sm_ctx*, u32, void *)' (aka 'void (*)(structefc_sm_ctx*, unsigned int, void *)') from 'void (*)(structefc_sm_ctx*, enumefc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict]Quoted 3 lines
node->nodedb_state = state; ^ ~~~~~
drivers/scsi/elx/libefc/efc_node.c:905:6: error: incompatible functionpointer types assigning to 'void (*)(struct
efc_sm_ctx*, enumefc_sm_event, void *)' from 'void (*)(structefc_sm_ctx*, u32, void *)' (aka 'void (*)(structefc_sm_ctx*, unsigned int, void *)') [-Werror,-Wincompatible-function-pointer-types-strict]Quoted 4 lines
pf = node->nodedb_state; ^ ~~~~~~~~~~~~~~~~~~
drivers/scsi/elx/libefc/efc_device.c:455:22: error: incompatiblefunction pointer types assigning to 'void (*)(struct
efc_sm_ctx*, u32, void *)' (aka 'void (*)(structefc_sm_ctx*, unsigned int, void *)') from 'void (structefc_sm_ctx*, enumefc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict]Quoted 4 lines
node->nodedb_state = __efc_d_init; ^ ~~~~~~~~~~~~
drivers/scsi/elx/libefc/efc_sm.c:41:22: error: incompatible functionpointer types assigning to 'void (*)(struct
efc_sm_ctx*, u32, void *)' (aka 'void (*)(structefc_sm_ctx*, unsigned int, void *)') from 'void (*)(structefc_sm_ctx*, enumefc_sm_event, void *)' [-Werror,-Wincompatible-function-pointer-types-strict]Quoted 9 lines
ctx->current_state = state; ^ ~~~~~The type of the second parameter in the prototypes of ->current_state() and ->nodedb_state() ('u32') does not match the implementations, which have a second parameter type of 'enum
efc_sm_event'. Update the prototypes to have the correct second parameter type, clearing up all the warnings and CFI failures.
Quoted 9 lines
Quoted 3 lines
Reported-by Sami Tolvanen <[email protected]>Signed-off-by Nathan Chancellor <[email protected]>Reviewed-by Kees Cook <[email protected]>--
Kees Cook
Looks good.
Signature · 11 lines
This electronic communication and the information and any files transmitted with it, or attached to it, are confidential and are intended solely for the use of the individual or entity to whom it is addressed and may contain information that is confidential, legally privileged, protected by privacy laws, or otherwise restricted from disclosure to anyone else. If you are not the intended recipient or the person responsible for delivering the e-mail to the intended recipient, you are hereby notified that any use, copying, distributing, dissemination, forwarding, printing, or copying of this e-mail is strictly prohibited. If you received this e-mail in error, please return the e-mail to the sender, delete it from your computer, and destroy any printed copy of it.
Martin K. Petersen
AppliedNathan,
Quoted 7 lines
With clang's kernel control flow integrity (kCFI,
CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:
Applied to 6.2/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedQuoted 9 lines · Nathan Chancellor
With clang's kernel control flow integrity (kCFI,
CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. A proposed warning in clang aims to catch these at compile time, which reveals:[...]
Applied to 6.2/scsi-queue, thanks!
[1/1] scsi: elx: libefc: Fix second parameter type in state callbacks
https://git.kernel.org/mkp/scsi/c/3d75e766b58a
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering