* [PATCH] IB/hfi1: use size_t for passing array length
@ 2017-02-14 21:23 Arnd Bergmann
2017-02-15 5:24 ` Leon Romanovsky
[not found] ` <20170214212358.2730288-1-arnd-r2nGTMty4D4@public.gmane.org>
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2017-02-14 21:23 UTC (permalink / raw)
To: Mike Marciniszyn, Dennis Dalessandro
Cc: Arnd Bergmann, Doug Ledford, Sean Hefty, Hal Rosenstock,
Ira Weiny, Jubin John, Jianxin Xiong,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
gcc-7 produces a mysterious warning about the size argument being potentially out
of range:
drivers/infiniband/hw/hfi1/verbs.c: In function 'init_cntr_names':
drivers/infiniband/hw/hfi1/verbs.c:1644:2: error: 'memcpy': specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
This seems to refer to a the case where an 64-bit size_t gets truncated
into a negative 'int' and subsequently turned into a high 64-bit number
again.
The fix is clearly to use size_t here, which matches the type that gets
used for this value elsewhere.
Fixes: b7481944b06e ("IB/hfi1: Show statistics counters under IB stats interface")
Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
---
drivers/infiniband/hw/hfi1/verbs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
index 95ed4d6da510..1d8ac9432742 100644
--- a/drivers/infiniband/hw/hfi1/verbs.c
+++ b/drivers/infiniband/hw/hfi1/verbs.c
@@ -1618,7 +1618,7 @@ static int cntr_names_initialized;
* external strings.
*/
static int init_cntr_names(const char *names_in,
- const int names_len,
+ const size_t names_len,
int num_extra_names,
int *num_cntrs,
const char ***cntr_names)
--
2.9.0
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/hfi1: use size_t for passing array length
2017-02-14 21:23 [PATCH] IB/hfi1: use size_t for passing array length Arnd Bergmann
@ 2017-02-15 5:24 ` Leon Romanovsky
[not found] ` <20170214212358.2730288-1-arnd-r2nGTMty4D4@public.gmane.org>
1 sibling, 0 replies; 3+ messages in thread
From: Leon Romanovsky @ 2017-02-15 5:24 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Mike Marciniszyn, Dennis Dalessandro, Doug Ledford, Sean Hefty,
Hal Rosenstock, Ira Weiny, Jubin John, Jianxin Xiong, linux-rdma,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]
On Tue, Feb 14, 2017 at 10:23:07PM +0100, Arnd Bergmann wrote:
> gcc-7 produces a mysterious warning about the size argument being potentially out
> of range:
>
> drivers/infiniband/hw/hfi1/verbs.c: In function 'init_cntr_names':
> drivers/infiniband/hw/hfi1/verbs.c:1644:2: error: 'memcpy': specified size between 18446744071562067968 and 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
>
> This seems to refer to a the case where an 64-bit size_t gets truncated
> into a negative 'int' and subsequently turned into a high 64-bit number
> again.
>
> The fix is clearly to use size_t here, which matches the type that gets
> used for this value elsewhere.
>
> Fixes: b7481944b06e ("IB/hfi1: Show statistics counters under IB stats interface")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> drivers/infiniband/hw/hfi1/verbs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/hfi1: use size_t for passing array length
[not found] ` <20170214212358.2730288-1-arnd-r2nGTMty4D4@public.gmane.org>
@ 2017-02-19 13:56 ` Doug Ledford
0 siblings, 0 replies; 3+ messages in thread
From: Doug Ledford @ 2017-02-19 13:56 UTC (permalink / raw)
To: Arnd Bergmann, Mike Marciniszyn, Dennis Dalessandro
Cc: Sean Hefty, Hal Rosenstock, Ira Weiny, Jubin John, Jianxin Xiong,
linux-rdma-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 1099 bytes --]
On Tue, 2017-02-14 at 22:23 +0100, Arnd Bergmann wrote:
> gcc-7 produces a mysterious warning about the size argument being
> potentially out
> of range:
>
> drivers/infiniband/hw/hfi1/verbs.c: In function 'init_cntr_names':
> drivers/infiniband/hw/hfi1/verbs.c:1644:2: error: 'memcpy': specified
> size between 18446744071562067968 and 18446744073709551615 exceeds
> maximum object size 9223372036854775807 [-Werror=stringop-overflow=]
>
> This seems to refer to a the case where an 64-bit size_t gets
> truncated
> into a negative 'int' and subsequently turned into a high 64-bit
> number
> again.
>
> The fix is clearly to use size_t here, which matches the type that
> gets
> used for this value elsewhere.
>
> Fixes: b7481944b06e ("IB/hfi1: Show statistics counters under IB
> stats interface")
> Signed-off-by: Arnd Bergmann <arnd-r2nGTMty4D4@public.gmane.org>
Thanks, applied.
--
Doug Ledford <dledford-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
GPG KeyID: B826A3330E572FDD
Key fingerprint = AE6B 1BDA 122B 23B4 265B 1274 B826 A333 0E57 2FDD
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-02-19 13:56 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-14 21:23 [PATCH] IB/hfi1: use size_t for passing array length Arnd Bergmann
2017-02-15 5:24 ` Leon Romanovsky
[not found] ` <20170214212358.2730288-1-arnd-r2nGTMty4D4@public.gmane.org>
2017-02-19 13:56 ` Doug Ledford
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox