aboutsummaryrefslogtreecommitdiff
path: root/drivers/scsi/elx/libefc
AgeCommit message (Collapse)AuthorFilesLines
2024-08-22scsi: elx: libefc: Fix potential use after free in efc_nport_vport_del()Dan Carpenter1-1/+1
The kref_put() function will call nport->release if the refcount drops to zero. The nport->release release function is _efc_nport_free() which frees "nport". But then we dereference "nport" on the next line which is a use after free. Re-order these lines to avoid the use after free. Fixes: fcd427303eb9 ("scsi: elx: libefc: SLI and FC PORT state machine interfaces") Signed-off-by: Dan Carpenter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Daniel Wagner <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2023-11-15scsi: elx: libefc: Replace deprecated strncpy() with strscpy_pad()/memcpy()Justin Stitt1-6/+6
strncpy() is deprecated for use on NUL-terminated destination strings [1] and as such we should prefer more robust and less ambiguous string interfaces. To keep node->current_state_name and node->prev_state_name NUL-padded and NUL-terminated let's use strscpy_pad() as this implicitly provides both. For the swap between the two, a simple memcpy() will suffice. Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] Link: https://github.com/KSPP/linux/issues/90 Cc: [email protected] Signed-off-by: Justin Stitt <[email protected]> Link: https://lore.kernel.org/r/20231026-strncpy-drivers-scsi-elx-libefc-efc_node-h-v2-1-5c083d0c13f4@google.com Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-11-08scsi: elx: libefc: Fix second parameter type in state callbacksNathan Chancellor1-2/+4
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 <[email protected]> Signed-off-by: Nathan Chancellor <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2022-01-24scsi: elx: efct: Don't use GFP_KERNEL under spin lockYang Yingliang1-6/+2
GFP_KERNEL/GFP_DMA can't be used under a spin lock. According the comment, els_ios_lock is used to protect els ios list so we can move down the spin lock to avoid using this flag under the lock. Link: https://lore.kernel.org/r/[email protected] Fixes: 8f406ef72859 ("scsi: elx: libefc: Extended link Service I/O handling") Reported-by: Hulk Robot <[email protected]> Reviewed-by: James Smart <[email protected]> Signed-off-by: Yang Yingliang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-12-16scsi: efct: Don't pass GFP_DMA to dma_alloc_coherent()Christoph Hellwig2-4/+4
dma_alloc_coherent() ignores the zone specifiers so this is pointless and confusing. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: James Smart <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-10-12Merge branch '5.15/scsi-fixes' into 5.16/scsi-stagingMartin K. Petersen2-6/+4
Merge the 5.15/scsi-fixes branch into the staging tree to resolve UFS conflict reported by sfr. Signed-off-by: Martin K. Petersen <[email protected]>
2021-09-22scsi: efct: Fix nport freeDmitry Bogdanov2-1/+7
nport_free for an empty nport hangs the state machine waiting for mbox completion if nport is not yet attached thinking that it is attaching right now. Add a check for nport attaching state and complete nport free. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ram Vegesna <[email protected]> Signed-off-by: Dmitry Bogdanov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-09-22scsi: efct: Add state in nport sm trace printoutDmitry Bogdanov1-1/+1
Similar to other state machine traces and to make debug easier, add the state name to nport sm trace printout. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Ram Vegesna <[email protected]> Signed-off-by: Dmitry Bogdanov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-09-14scsi: elx: libefc: Prefer kcalloc() over open coded arithmeticLen Baker1-1/+1
As noted in the "Deprecated Interfaces, Language Features, Attributes, and Conventions" documentation [1], size calculations (especially multiplication) should not be performed in memory allocator (or similar) function arguments due to the risk of them overflowing. This could lead to values wrapping around and a smaller allocation being made than the caller was expecting. Using those allocations could lead to linear overflows of heap memory and other misbehaviors. Use the purpose specific kcalloc() function instead of the argument count * size in the kzalloc() function. [1] https://www.kernel.org/doc/html/v5.14/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Link: https://lore.kernel.org/r/[email protected] Reviewed-by: James Smart <[email protected]> Signed-off-by: Len Baker <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-09-13scsi: elx: efct: Fix void-pointer-to-enum-cast warning for efc_nport_topologyJames Smart2-6/+4
The kernel test robot flagged an warning for ".../efc_device.c:932:6: warning: cast to smaller integer type 'enum efc_nport_topology' from 'void *'" For the topology events, the "arg" field is generically defined as a void * and is used to pass different arguments. Most of the arguments are pointers to data structures. But for the EFC_EVT_NPORT_TOPOLOGY_NOTIFY event, the argument is an enum value, and the code is typecasting the void * to an enum generating the warning. Fix by converting the EFC_EVT_NPORT_TOPOLOGY_NOTIFY event to pass a pointer to the enum, thus it's a straight-forward pointer dereference in the event handler. Link: https://lore.kernel.org/r/[email protected] Fixes: 202bfdffae27 ("scsi: elx: libefc: FC node ELS and state handling") Reported-by: kernel test robot <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-18scsi: elx: libefc: Fix IRQ restore in efc_domain_dispatch_frame()Dan Carpenter1-2/+2
Calling a nested spin_lock_irqsave() will overwrite the original "flags" so that they can not be enabled again at the end. Link: https://lore.kernel.org/r/YMyjH16k4M1yEmmU@mwanda Fixes: 3146240f19bf ("scsi: elx: libefc: FC Domain state machine interfaces") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-18scsi: elx: libefc: Fix less than zero comparison of a unsigned intColin Ian King1-1/+1
The comparison of the u32 variable rc to less than zero always false because it is unsigned. Fix this by making it an int. Link: https://lore.kernel.org/r/[email protected] Fixes: 202bfdffae27 ("scsi: elx: libefc: FC node ELS and state handling") Signed-off-by: Colin Ian King <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> Addresses-Coverity: ("Unsigned compared against 0")
2021-06-15scsi: elx: libefc: Register discovery objects with hardwareJames Smart2-0/+812
Add library interface definitions for: - Registrations for VFI, VPI and RPI. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Daniel Wagner <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-15scsi: elx: libefc: Extended link Service I/O handlingJames Smart2-0/+1205
Add library interface definitions for: - Functions to build and send ELS/CT/BLS commands and responses. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Daniel Wagner <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-15scsi: elx: libefc: FC node ELS and state handlingJames Smart2-0/+1675
Add library interface definitions for: - FC node PRLI handling and state management. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Daniel Wagner <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-15scsi: elx: libefc: Fabric node state machine interfacesJames Smart2-0/+1680
Add library interface definitions for: - Fabric node initialization and logins. - Name/Directory Services node. - Fabric Controller node to process rscn events. These are all interactions with remote ports that correspond to well-known fabric entities Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Daniel Wagner <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-15scsi: elx: libefc: Remote node state machine interfacesJames Smart2-0/+1293
Add library interface definitions for: - Remote node (aka remote port) allocation, initializaion and destroy routines. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Daniel Wagner <[email protected]> Reviewed-by: Hannes Reinecke <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-15scsi: elx: libefc: SLI and FC PORT state machine interfacesJames Smart2-0/+827
Add library interface definitions for: - SLI and FC port (aka n_port_id) registration, allocation and deallocation. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Daniel Wagner <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-15scsi: elx: libefc: FC Domain state machine interfacesJames Smart2-0/+1142
Add library interface definitions for: - FC Domain registration, allocation and deallocation sequence Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Daniel Wagner <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-15scsi: elx: libefc: Emulex FC discovery library APIs and definitionsJames Smart3-0/+753
Add library interface definitions for: - SLI/Local FC port objects - efc_domain_s: FC domain (aka fabric) objects - efc_node_s: FC node (aka remote ports) objects Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Daniel Wagner <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
2021-06-15scsi: elx: libefc: Generic state machine frameworkJames Smart2-0/+251
Start the population of the libefc library. The library will contain common tasks usable by a target or initiator driver. The library will also contain a FC discovery state machine interface. Creates the library directory and add definitions for the discovery state machine interface. Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Hannes Reinecke <[email protected]> Reviewed-by: Daniel Wagner <[email protected]> Co-developed-by: Ram Vegesna <[email protected]> Signed-off-by: Ram Vegesna <[email protected]> Signed-off-by: James Smart <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>