From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailtransmit04.runbox.com (mailtransmit04.runbox.com [185.226.149.37]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 534423B813C for ; Mon, 8 Jun 2026 09:55:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.226.149.37 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780912550; cv=none; b=Hbk7h5/WyQV7ZmenAtbV7tlWfOuCQ6uJQW0J7+Cw7jo4qn0trZnkD/cvvorTu5SRXM/yEWa/EwAAxG47+Anwd7M16r3L4LSBh6dXzz8pz3KirQNO2JZ5YeN+wgXN4ZcqcVOeD2L+Afnvs8EK6RPO1m8FBqAacDFChsQOtgbMsco= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780912550; c=relaxed/simple; bh=wz8XEsY3kJvOSryhfHZlc/eFu9yoBoFSN2PD5F8zRpA=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=uth4VYVS6yQguIyCRolhS2zEnRwKFjNjq2NoVkAgKDz0lgTqOve7ZV6zlg4XP0OEuXVA7iXlZ32HWUda8r6trM6lIKjrUtW4fWPtseeE9v3p2q9Crp6VCN9StdwHgavSMRoCqNExLm5x4wU9izh61bBUmzY8pvHOl69Pd7/sX9M= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=runbox.com; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b=L3pZv2Cz; arc=none smtp.client-ip=185.226.149.37 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=runbox.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=runbox.com header.i=@runbox.com header.b="L3pZv2Cz" Received: from mailtransmit03.runbox ([10.9.9.163] helo=aibo.runbox.com) by mailtransmit04.runbox.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1wWWhm-00BRvn-Kt; Mon, 08 Jun 2026 11:55:38 +0200 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=runbox.com; s=selector1; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date: Subject:Cc:To:From; bh=g+VTKhbN/6tees8YPIaQJkfwcrtiigF1OfLz8IHB57c=; b=L3pZv2 CzHxv1vHmf6IMa+vsMQfgnE04LeNq2X29Qrv0UZgeN/DGAuqjIFgXPw4xhS98x8A4YNCs++sJb0n9 1K8X8hKDazq6eMPm69OwOogjV7FX6Fic3IRK57L0rfn41UF4BOtVsFyyRUDT0kZc5QAc8II0pX1R3 l+ef4mlCj4DAulp9YspOtNqrIqOL1DAiH+47MdXbztuFW8nbi+BQhZeataBKk0a9Dw+GrAvUtmdJx ukp+KoE9zy2eX+9ZDT+jikMk21ep3PbuhwoeUfUOjxagH9depryO/vxbpJxcmqgO6b9hsyO5/zrXu 9CTJXfGgYWqf7oRH3qDZ35SK5iTA==; Received: from [10.9.9.73] (helo=submission02.runbox) by mailtransmit03.runbox with esmtp (Exim 4.86_2) (envelope-from ) id 1wWWhl-0003bI-NT; Mon, 08 Jun 2026 11:55:38 +0200 Received: by submission02.runbox with esmtpsa [Authenticated ID (1493616)] (TLS1.2:ECDHE_SECP256R1__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.95) id 1wWWhd-00Ag6G-0r; Mon, 08 Jun 2026 11:55:29 +0200 From: david.laight.linux@gmail.com To: Kees Cook , linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org Cc: Arnd Bergmann , GR-QLogic-Storage-Upstream@marvell.com, "James E.J. Bottomley" , Manish Rangankar , "Martin K. Petersen" , Nilesh Javali , David Laight Subject: [PATCH next] drivers/scsi/qla4xxx/ql4_mbx: Use strscpy() to copy strings into arrays Date: Mon, 8 Jun 2026 10:54:53 +0100 Message-Id: <20260608095523.2606-9-david.laight.linux@gmail.com> X-Mailer: git-send-email 2.39.5 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: David Laight Replacing strcpy() with strscpy() ensures that overflow of the target buffer cannot happen. Signed-off-by: David Laight --- This is one of a group of patches that remove potentially unbounded strcpy() calls. They are mostly replaced by strscpy() or, when strlen() has just been called, with memcpy() (usually including the '\0'). Calls with copy string literals into arrays are left unchanged. They are safe and easily detected as such. The changes were made by getting the compiler to detect the calls and then fixing the code by hand. Note that all the changes are only compile tested. Some Makefiles were changed to allow files to contain strcpy(). As well as 'difficult to fix' files, this included 'show' functions as they really need to use sysfs_emit() or seq_printf(). All the patches are being sent individually to avoid very long cc lists. Apologies for the terse commit messages and likely unexpected tags. (There are about 100 patches in total.) drivers/scsi/qla4xxx/ql4_mbx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/qla4xxx/ql4_mbx.c b/drivers/scsi/qla4xxx/ql4_mbx.c index 7febc0baa9d6..cb0dc2908582 100644 --- a/drivers/scsi/qla4xxx/ql4_mbx.c +++ b/drivers/scsi/qla4xxx/ql4_mbx.c @@ -1370,7 +1370,7 @@ int qla4xxx_about_firmware(struct scsi_qla_host *ha) sizeof(about_fw->fw_build_date)); memcpy(ha->fw_info.fw_build_time, about_fw->fw_build_time, sizeof(about_fw->fw_build_time)); - strcpy((char *)ha->fw_info.fw_build_user, + strscpy(ha->fw_info.fw_build_user, skip_spaces((char *)about_fw->fw_build_user)); ha->fw_info.fw_load_source = le16_to_cpu(about_fw->fw_load_source); ha->fw_info.iscsi_major = le16_to_cpu(about_fw->iscsi_major); @@ -1379,7 +1379,7 @@ int qla4xxx_about_firmware(struct scsi_qla_host *ha) ha->fw_info.bootload_minor = le16_to_cpu(about_fw->bootload_minor); ha->fw_info.bootload_patch = le16_to_cpu(about_fw->bootload_patch); ha->fw_info.bootload_build = le16_to_cpu(about_fw->bootload_build); - strcpy((char *)ha->fw_info.extended_timestamp, + strscpy(ha->fw_info.extended_timestamp, skip_spaces((char *)about_fw->extended_timestamp)); ha->fw_uptime_secs = le32_to_cpu(mbox_sts[5]); -- 2.39.5