LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] scsi: lpfc: Fix gcc -Wstringop-overread warning, again
@ 2021-09-20 9:56 Arnd Bergmann
2021-09-20 18:49 ` James Smart
2021-09-22 4:44 ` Martin K. Petersen
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2021-09-20 9:56 UTC (permalink / raw)
To: James Smart, Dick Kennedy, James E.J. Bottomley,
Martin K. Petersen, Arnd Bergmann, Justin Tee
Cc: Lee Jones, Gaurav Srivastava, linux-scsi, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
I fixed a stringop-overread warning earlier this year, now a
second copy of the original code was added and the warning came
back:
drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_cmf_info_show':
drivers/scsi/lpfc/lpfc_attr.c:289:25: error: 'strnlen' specified bound 4095 exceeds source size 24 [-Werror=stringop-overread]
289 | strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Fix it the same way as the other copy.
Fixes: ada48ba70f6b ("scsi: lpfc: Fix gcc -Wstringop-overread warning")
Fixes: 74a7baa2a3ee ("scsi: lpfc: Add cmf_info sysfs entry")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/scsi/lpfc/lpfc_attr.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_attr.c b/drivers/scsi/lpfc/lpfc_attr.c
index b35bf70a8c0d..ca0433e28ac3 100644
--- a/drivers/scsi/lpfc/lpfc_attr.c
+++ b/drivers/scsi/lpfc/lpfc_attr.c
@@ -285,11 +285,8 @@ lpfc_cmf_info_show(struct device *dev, struct device_attribute *attr,
"6312 Catching potential buffer "
"overflow > PAGE_SIZE = %lu bytes\n",
PAGE_SIZE);
- strscpy(buf + PAGE_SIZE - 1 -
- strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1),
- LPFC_INFO_MORE_STR,
- strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1)
- + 1);
+ strscpy(buf + PAGE_SIZE - 1 - sizeof(LPFC_INFO_MORE_STR),
+ LPFC_INFO_MORE_STR, sizeof(LPFC_INFO_MORE_STR) + 1);
}
return len;
}
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: lpfc: Fix gcc -Wstringop-overread warning, again
2021-09-20 9:56 [PATCH] scsi: lpfc: Fix gcc -Wstringop-overread warning, again Arnd Bergmann
@ 2021-09-20 18:49 ` James Smart
2021-09-22 4:44 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: James Smart @ 2021-09-20 18:49 UTC (permalink / raw)
To: Arnd Bergmann, James Smart, Dick Kennedy, James E.J. Bottomley,
Martin K. Petersen, Arnd Bergmann, Justin Tee
Cc: Lee Jones, Gaurav Srivastava, linux-scsi, linux-kernel
On 9/20/2021 2:56 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> I fixed a stringop-overread warning earlier this year, now a
> second copy of the original code was added and the warning came
> back:
>
> drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_cmf_info_show':
> drivers/scsi/lpfc/lpfc_attr.c:289:25: error: 'strnlen' specified bound 4095 exceeds source size 24 [-Werror=stringop-overread]
> 289 | strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1),
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> Fix it the same way as the other copy.
>
> Fixes: ada48ba70f6b ("scsi: lpfc: Fix gcc -Wstringop-overread warning")
> Fixes: 74a7baa2a3ee ("scsi: lpfc: Add cmf_info sysfs entry")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/scsi/lpfc/lpfc_attr.c | 7 ++-----
Thank You Arnd. Looks good.
Reviewed-by: James Smart <jsmart2021@gmail.com>
-- james
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] scsi: lpfc: Fix gcc -Wstringop-overread warning, again
2021-09-20 9:56 [PATCH] scsi: lpfc: Fix gcc -Wstringop-overread warning, again Arnd Bergmann
2021-09-20 18:49 ` James Smart
@ 2021-09-22 4:44 ` Martin K. Petersen
1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2021-09-22 4:44 UTC (permalink / raw)
To: James E.J. Bottomley, Dick Kennedy, Arnd Bergmann, James Smart,
Justin Tee, Arnd Bergmann
Cc: Martin K . Petersen, Lee Jones, Gaurav Srivastava, linux-kernel,
linux-scsi
On Mon, 20 Sep 2021 11:56:22 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> I fixed a stringop-overread warning earlier this year, now a
> second copy of the original code was added and the warning came
> back:
>
> drivers/scsi/lpfc/lpfc_attr.c: In function 'lpfc_cmf_info_show':
> drivers/scsi/lpfc/lpfc_attr.c:289:25: error: 'strnlen' specified bound 4095 exceeds source size 24 [-Werror=stringop-overread]
> 289 | strnlen(LPFC_INFO_MORE_STR, PAGE_SIZE - 1),
> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>
> [...]
Applied to 5.15/scsi-fixes, thanks!
[1/1] scsi: lpfc: Fix gcc -Wstringop-overread warning, again
https://git.kernel.org/mkp/scsi/c/a38923f2d088
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-09-22 4:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-20 9:56 [PATCH] scsi: lpfc: Fix gcc -Wstringop-overread warning, again Arnd Bergmann
2021-09-20 18:49 ` James Smart
2021-09-22 4:44 ` 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;
as well as URLs for NNTP newsgroup(s).