Patch "scsi: qla2xxx: Avoid possible run-time warning with long model_num" has been added to the 6.8-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: qla2xxx: Avoid possible run-time warning with long model_num

to the 6.8-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     scsi-qla2xxx-avoid-possible-run-time-warning-with-lo.patch
and it can be found in the queue-6.8 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1957842812e97dbe643644c6fa211e06f4073176
Author: Kees Cook <keescook@xxxxxxxxxxxx>
Date:   Tue Apr 9 19:31:54 2024 -0700

    scsi: qla2xxx: Avoid possible run-time warning with long model_num
    
    [ Upstream commit c3408c4ae041dcc6a302397099fcad0dc307f6fd ]
    
    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@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240410023155.2100422-5-keescook@xxxxxxxxxxxx
    Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/scsi/qla2xxx/qla_mr.c b/drivers/scsi/qla2xxx/qla_mr.c
index 083f94e43fba0..82a7e21ddc838 100644
--- a/drivers/scsi/qla2xxx/qla_mr.c
+++ b/drivers/scsi/qla2xxx/qla_mr.c
@@ -1909,10 +1909,8 @@ qlafx00_fx_disc(scsi_qla_host_t *vha, fc_port_t *fcport, uint16_t fx_type)
 	if (fx_type == FXDISC_GET_CONFIG_INFO) {
 		struct config_info_data *pinfo =
 		    (struct config_info_data *) fdisc->u.fxiocb.rsp_addr;
-		strscpy(vha->hw->model_number, pinfo->model_num,
-			ARRAY_SIZE(vha->hw->model_number));
-		strscpy(vha->hw->model_desc, pinfo->model_description,
-			ARRAY_SIZE(vha->hw->model_desc));
+		memtostr(vha->hw->model_number, pinfo->model_num);
+		memtostr(vha->hw->model_desc, pinfo->model_description);
 		memcpy(&vha->hw->mr.symbolic_name, pinfo->symbolic_name,
 		    sizeof(vha->hw->mr.symbolic_name));
 		memcpy(&vha->hw->mr.serial_num, pinfo->serial_num,




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux