Patch "scsi: mptfusion: Avoid possible run-time warning with long manufacturer strings" 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: mptfusion: Avoid possible run-time warning with long manufacturer strings

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-mptfusion-avoid-possible-run-time-warning-with-.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 4eb3fe9f394758406659fbae37a3b01ef3340e1c
Author: Kees Cook <keescook@xxxxxxxxxxxx>
Date:   Tue Apr 9 19:31:51 2024 -0700

    scsi: mptfusion: Avoid possible run-time warning with long manufacturer strings
    
    [ Upstream commit 5bb288c4abc2e67d4ea94ba6bc80bb0ab18b123e ]
    
    The prior strscpy() replacement of strncpy() here expected the
    manufacture_reply strings to be NUL-terminated, but it is possible
    they are not, as the code pattern here shows, e.g., edev->vendor_id
    being exactly 1 character larger than manufacture_reply->vendor_id,
    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.
    
    Reported-by: Charles Bertsch <cbertsch@xxxxxxx>
    Closes: https://lore.kernel.org/all/5445ba0f-3e27-4d43-a9ba-0cc22ada2fce@xxxxxxx/
    Fixes: 45e833f0e5bb ("scsi: message: fusion: Replace deprecated strncpy() with strscpy()")
    Reviewed-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240410023155.2100422-2-keescook@xxxxxxxxxxxx
    Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index 300f8e955a531..0f80c840afc3a 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -2964,17 +2964,13 @@ mptsas_exp_repmanufacture_info(MPT_ADAPTER *ioc,
 			goto out_free;
 
 		manufacture_reply = data_out + sizeof(struct rep_manu_request);
-		strscpy(edev->vendor_id, manufacture_reply->vendor_id,
-			sizeof(edev->vendor_id));
-		strscpy(edev->product_id, manufacture_reply->product_id,
-			sizeof(edev->product_id));
-		strscpy(edev->product_rev, manufacture_reply->product_rev,
-			sizeof(edev->product_rev));
+		memtostr(edev->vendor_id, manufacture_reply->vendor_id);
+		memtostr(edev->product_id, manufacture_reply->product_id);
+		memtostr(edev->product_rev, manufacture_reply->product_rev);
 		edev->level = manufacture_reply->sas_format;
 		if (manufacture_reply->sas_format) {
-			strscpy(edev->component_vendor_id,
-				manufacture_reply->component_vendor_id,
-				sizeof(edev->component_vendor_id));
+			memtostr(edev->component_vendor_id,
+				 manufacture_reply->component_vendor_id);
 			tmp = (u8 *)&manufacture_reply->component_id;
 			edev->component_id = tmp[0] << 8 | tmp[1];
 			edev->component_revision_id =




[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