* [PATCH] scsi: smartpqi: Replace all non-returning strlcpy with strscpy
@ 2023-05-30 16:23 Azeem Shaikh
2023-05-30 23:20 ` Kees Cook
2023-05-31 22:06 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Azeem Shaikh @ 2023-05-30 16:23 UTC (permalink / raw)
To: Don Brace
Cc: linux-hardening, Azeem Shaikh, storagedev, linux-scsi,
linux-kernel, James E.J. Bottomley, Martin K. Petersen
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 NUL-terminated [1].
In an effort to remove strlcpy() completely [2], replace
strlcpy() here with strscpy().
No return values were used, so direct replacement is safe.
[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
[2] https://github.com/KSPP/linux/issues/89
Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
---
drivers/scsi/smartpqi/smartpqi_init.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c
index 03de97cd72c2..74f608b9fc9d 100644
--- a/drivers/scsi/smartpqi/smartpqi_init.c
+++ b/drivers/scsi/smartpqi/smartpqi_init.c
@@ -6903,7 +6903,7 @@ static ssize_t pqi_lockup_action_store(struct device *dev,
char *action_name;
char action_name_buffer[32];
- strlcpy(action_name_buffer, buffer, sizeof(action_name_buffer));
+ strscpy(action_name_buffer, buffer, sizeof(action_name_buffer));
action_name = strstrip(action_name_buffer);
for (i = 0; i < ARRAY_SIZE(pqi_lockup_actions); i++) {
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] scsi: smartpqi: Replace all non-returning strlcpy with strscpy
2023-05-30 16:23 [PATCH] scsi: smartpqi: Replace all non-returning strlcpy with strscpy Azeem Shaikh
@ 2023-05-30 23:20 ` Kees Cook
2023-05-31 22:06 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2023-05-30 23:20 UTC (permalink / raw)
To: Azeem Shaikh
Cc: Don Brace, linux-hardening, storagedev, linux-scsi, linux-kernel,
James E.J. Bottomley, Martin K. Petersen
On Tue, May 30, 2023 at 04:23:21PM +0000, Azeem Shaikh wrote:
> 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 NUL-terminated [1].
> In an effort to remove strlcpy() completely [2], replace
> strlcpy() here with strscpy().
> No return values were used, so direct replacement is safe.
>
> [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy
> [2] https://github.com/KSPP/linux/issues/89
>
> Signed-off-by: Azeem Shaikh <azeemshaikh38@gmail.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
--
Kees Cook
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: smartpqi: Replace all non-returning strlcpy with strscpy
2023-05-30 16:23 [PATCH] scsi: smartpqi: Replace all non-returning strlcpy with strscpy Azeem Shaikh
2023-05-30 23:20 ` Kees Cook
@ 2023-05-31 22:06 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2023-05-31 22:06 UTC (permalink / raw)
To: Azeem Shaikh
Cc: Don Brace, linux-hardening, storagedev, linux-scsi, linux-kernel,
James E.J. Bottomley, Martin K. Petersen
Azeem,
> 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 NUL-terminated [1]. In
> an effort to remove strlcpy() completely [2], replace strlcpy() here
> with strscpy(). No return values were used, so direct replacement is
> safe.
Applied to 6.5/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-05-31 22:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-30 16:23 [PATCH] scsi: smartpqi: Replace all non-returning strlcpy with strscpy Azeem Shaikh
2023-05-30 23:20 ` Kees Cook
2023-05-31 22:06 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox