[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240305-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v3-6-5b78a13ff984@google.com>
Date: Tue, 05 Mar 2024 23:34:41 +0000
From: Justin Stitt <justinstitt@...gle.com>
To: Sathya Prakash Veerichetty <sathya.prakash@...adcom.com>, Kashyap Desai <kashyap.desai@...adcom.com>,
Sumit Saxena <sumit.saxena@...adcom.com>, Sreekanth Reddy <sreekanth.reddy@...adcom.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>, "Martin K. Petersen" <martin.petersen@...cle.com>,
Suganath Prabu Subramani <suganath-prabu.subramani@...adcom.com>, Ariel Elior <aelior@...vell.com>,
Manish Chopra <manishc@...vell.com>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Saurav Kashyap <skashyap@...vell.com>, Javed Hasan <jhasan@...vell.com>,
GR-QLogic-Storage-Upstream@...vell.com, Nilesh Javali <njavali@...vell.com>,
Manish Rangankar <mrangankar@...vell.com>, Don Brace <don.brace@...rochip.com>
Cc: mpi3mr-linuxdrv.pdl@...adcom.com, linux-scsi@...r.kernel.org,
linux-hardening@...r.kernel.org, linux-kernel@...r.kernel.org,
Kees Cook <keescook@...omium.org>, MPT-FusionLinux.pdl@...adcom.com,
netdev@...r.kernel.org, storagedev@...rochip.com,
Justin Stitt <justinstitt@...gle.com>
Subject: [PATCH v3 6/7] scsi: smartpqi: replace deprecated strncpy with strscpy
buffer->driver_version is sized 32:
| struct bmic_host_wellness_driver_version {
| ...
| char driver_version[32];
.. the source string "Linux " + DRIVER_VERISON is sized at 16. There's
really no bug in the existing code since the buffers are sized
appropriately with great care taken to manually NUL-terminate the
destination buffer. Nonetheless, let's make the swap over to strscpy()
for robustness' (and readability's) sake.
Reviewed-by: Kees Cook <keescook@...omium.org>
Signed-off-by: Justin Stitt <justinstitt@...gle.com>
---
drivers/scsi/smartpqi/smartpqi_init.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index ceff1ec13f9e..bfe6f42e8e96 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -1041,9 +1041,8 @@ static int pqi_write_driver_version_to_host_wellness(
buffer->driver_version_tag[1] = 'V';
put_unaligned_le16(sizeof(buffer->driver_version),
&buffer->driver_version_length);
- strncpy(buffer->driver_version, "Linux " DRIVER_VERSION,
- sizeof(buffer->driver_version) - 1);
- buffer->driver_version[sizeof(buffer->driver_version) - 1] = '\0';
+ strscpy(buffer->driver_version, "Linux " DRIVER_VERSION,
+ sizeof(buffer->driver_version));
buffer->dont_write_tag[0] = 'D';
buffer->dont_write_tag[1] = 'W';
buffer->end_tag[0] = 'Z';
--
2.44.0.278.ge034bb2e1d-goog
Powered by blists - more mailing lists