linux/drivers/scsi/elx/libefc
Nathan Chancellor 3d75e766b5 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.

Link: https://github.com/ClangBuiltLinux/linux/issues/1750
Reported-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Link: https://lore.kernel.org/r/20221102161906.2781508-1-nathan@kernel.org
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2022-11-08 03:05:16 +00:00
..
efc.h scsi: efct: Add state in nport sm trace printout 2021-09-22 00:04:55 -04:00
efc_cmds.c scsi: efct: Don't pass GFP_DMA to dma_alloc_coherent() 2021-12-16 22:52:29 -05:00
efc_cmds.h scsi: elx: libefc: Register discovery objects with hardware 2021-06-15 23:39:30 -04:00
efc_device.c scsi: elx: efct: Fix void-pointer-to-enum-cast warning for efc_nport_topology 2021-09-13 22:15:40 -04:00
efc_device.h scsi: elx: libefc: FC node ELS and state handling 2021-06-15 23:39:30 -04:00
efc_domain.c scsi: elx: libefc: Fix IRQ restore in efc_domain_dispatch_frame() 2021-06-18 23:01:04 -04:00
efc_domain.h scsi: elx: libefc: FC Domain state machine interfaces 2021-06-15 23:39:30 -04:00
efc_els.c scsi: elx: efct: Don't use GFP_KERNEL under spin lock 2022-01-24 23:30:23 -05:00
efc_els.h scsi: elx: libefc: Extended link Service I/O handling 2021-06-15 23:39:30 -04:00
efc_fabric.c Merge branch '5.15/scsi-fixes' into 5.16/scsi-staging 2021-10-12 11:58:12 -04:00
efc_fabric.h scsi: elx: libefc: Fabric node state machine interfaces 2021-06-15 23:39:30 -04:00
efc_node.c scsi: elx: libefc: Remote node state machine interfaces 2021-06-15 23:39:30 -04:00
efc_node.h scsi: elx: libefc: Remote node state machine interfaces 2021-06-15 23:39:30 -04:00
efc_nport.c scsi: elx: libefc: SLI and FC PORT state machine interfaces 2021-06-15 23:39:30 -04:00
efc_nport.h scsi: elx: libefc: SLI and FC PORT state machine interfaces 2021-06-15 23:39:30 -04:00
efc_sm.c
efc_sm.h
efclib.c
efclib.h scsi: elx: libefc: Fix second parameter type in state callbacks 2022-11-08 03:05:16 +00:00