Support for the following changes in the Linux kernel v6.12:
- 5f60d5f6bbc1 ("move asm/unaligned.h to linux/unaligned.h")
- cb787f4ac0c2 ("[tree-wide] finally take no_llseek out")
The prior strlcpy() replacement of strncpy() here (which was
later replaced with strscpy()) expected pinfo->model_num (and
pinfo->model_description) to be NUL-terminated, but it is possible
it was not, as the code pattern here shows vha->hw->model_number (and
vha->hw->model_desc) being exactly 1 character larger, and the replaced
strncpy() was copying only up to the size of the source character
array. Replace this with memtostr(), which is the unambiguous way to
convert a maybe not-NUL-terminated character array into a NUL-terminated
string.
Fixes: 527e9b704c3d ("scsi: qla2xxx: Use memcpy() and strlcpy() instead of strcpy() and strncpy()")
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20240410023155.2100422-5-keescook@chromium.org
Signed-off-by: Kees Cook <keescook@chromium.org>
[ commit c3408c4ae041 upstream ]
Support the previous commit against kernel versions before v6.7.
See also commit 9cba82bba500 ("seq_file: add helper macro to define
attribute for rw file") # v6.7.
Support for the following block layer changes in the Linux kernel v6.9:
- f3a608827d1f ("bdev: open block device as files")
- b1211a25c4fe ("bdev: make bdev_{release, open_by_dev}() private to
block layer")
Support for the following block layer changes in the Linux kernel v6.8:
- e719b4d15674 ("block: Provide bdev_open_* functions")
- cd34758c5238 ("block: Remove blkdev_get_by_*() functions")
scst_pass_through_cmd_done can run in interrupt context, and call
scst_replace_port_info, which in turn was calling scst_lookup_tg_id.
Since scst_lookup_tg_id does a mutex_lock, we should not call it from
interrupt context.
Add scst_cmd_inquired_dev_ident and use in various locations.
Unbreak the build for the previous commit against kernel versions
before v5.16.
See also commit 3080ea5553cc ("stddef: Introduce DECLARE_FLEX_ARRAY()
helper") # v5.16.
strlcpy() reads the entire source buffer first. This read may exceed the
destination size limit. This is both inefficient and can lead to linear
read overflows if a source string is not NULL-terminated [1].
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
Support for the following block layer changes in the Linux kernel v6.5:
- 05bdb9965305 ("block: replace fmode_t with a block-specific type for
block open flags")
- 0718afd47f70 ("block: introduce holder ops")
- 2736e8eeb0cc ("block: use the holder as indication for exclusive opens")
This patch replaces percpu_ref_kill() with percpu_ref_kill_and_confirm()
to guarantee safe usage of references in atomic mode immediately
afterwards.
This change ensures accurate checking of active commands following the
initial reference killing.
Reported-by: Lev Vainblat <lev@zadarastorage.com>
This patch changes the processing threads to use INTERRUPTIBLE sleep
states in the scst_wait_event_...() functions. This aims to avoid
warnings from the hung task detection checker and to prevent
unnecessary load counting.
Fixes: d8894cbd11 ("scst.h: Refactor wait_event_locked() to enhance usability and clarity")
This patch modifies scst_sync_ext_block_dev() to support INTERRUPTIBLE
waiting and handle signal-induced waiting cancellation. To achieve this,
the waitqueue head is moved from the stack and allocated with the blocker.
Additionally, reference counting and its management are added to the
blocker to handle memory freeing from multiple contexts.
Fixes: https://github.com/SCST-project/scst/issues/164
1. Set the default process state to TASK_UNINTERRUPTIBLE during sleep.
This change is made because our current code does not check whether a
process was interrupted by a signal.
2. Prefix all SCST wait_event-related macros with 'scst_'. This helps to
distinguish SCST-specific macros from those provided by the Linux
kernel itself.
3. Add the capability to return an error code when a process in a
non-TASK_UNINTERRUPTIBLE state is interrupted by a signal.
4. Divide the wait_event_locked function based on each lock type,
resulting in the following new functions: scst_wait_event_lock(),
scst_wait_event_lock_bh(), and scst_wait_event_lock_irq().
Previously, when scst_pr_send_ua_reg attempted to deliver a UNIT ATTENTION
to a registrant that was on another node in a dlm-based HA cluster, the
unit attention was dropped.
Rectify by adding a pr_reg_queue_rem_ua function to struct scst_cl_ops and
calling it from scst_pr_send_ua_reg.
Each registrant will maintain an incoming 'queue' of unit attentions by
adding next_rem_ua_idx to the registrant data maintained in the DLM. This
will tell the other nodes which PR_REG_UA_LOCK lock to create in the
lockspace in order to 'send' a unit attention to the registrant.
Further, each node will also maintain two lists (pending and sent) for the
outgoing unit attentions from this node to a registrant. When the
recipient has read all the sent unit attentions (and cleared
next_rem_ua_idx), then the sent list may be cleared.
Add a setting to scst_tgt that can prevent scst_gen_aen_or_ua from
generating an AEN, even if the underlying transport is capable of
transmitting them. It will instead generate a UA.
Commit 9be09fd68b ("scst/include/backport.h: Fix building on
RHEL 8.8") fixed the build for RHEL 8.8, but at the same time, it
broke the build for RHEL 9.0.
Support for the following fc changes in the Linux kernel v6.3:
- 64fd2ba977b1 ("scsi: scsi_transport_fc: Add an additional flag to fc_host_fpin_rcv()")
Make the SCST_VERSION_STRING macro revision-independent, because it
causes a version string mismatch for SCST-dependent modules where the
revision is not exported.
Fixes: a86e5c55ea ("Makefile, scst: Add revision to SCST version macro")
Fixes: https://github.com/SCST-project/scst/issues/130
Fix a regression introduced during d989aa91f3 ("scst_lib: Port to
Linux kernel v5.19") that breaks dev_disk operation.
The kernel function blk_execute_rq_nowait will set rq->end_io to the
done parameter, so pass in the existing rq->end_io rather than NULL
to prevent zeroing it.
Fixes: d989aa91f3 ("scst_lib: Port to Linux kernel v5.19")
[ glebchesn: added patch description ]
Unbreak the build for the previous commit against kernel versions
before v3.12.
Fixes: ee6312ac5a ("scst_vdisk, qla2x00t-32gbit: Use PTR_ERR_OR_ZERO
instead of IS_ERR and PTR_ERR")