Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1580877 > unrolled thread

[PATCH] IB/hfi1: use size_t for passing array length

Started byArnd Bergmann <arnd@arndb.de>
First post2017-02-14 22:30 +0100
Last post2017-02-19 15:00 +0100
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] IB/hfi1: use size_t for passing array length Arnd Bergmann <arnd@arndb.de> - 2017-02-14 22:30 +0100
    Re: [PATCH] IB/hfi1: use size_t for passing array length Leon Romanovsky <leon@kernel.org> - 2017-02-15 06:30 +0100
    Re: [PATCH] IB/hfi1: use size_t for passing array length Doug Ledford <dledford@redhat.com> - 2017-02-19 15:00 +0100

#1580877 — [PATCH] IB/hfi1: use size_t for passing array length

FromArnd Bergmann <arnd@arndb.de>
Date2017-02-14 22:30 +0100
Subject[PATCH] IB/hfi1: use size_t for passing array length
Message-ID<taSPF-72f-27@gated-at.bofh.it>
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(-)

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

[toc] | [next] | [standalone]


#1581063

FromLeon Romanovsky <leon@kernel.org>
Date2017-02-15 06:30 +0100
Message-ID<tb0k9-3UE-5@gated-at.bofh.it>
In reply to#1580877

[Multipart message — attachments visible in raw view] — view raw

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>

[toc] | [prev] | [next] | [standalone]


#1584147

FromDoug Ledford <dledford@redhat.com>
Date2017-02-19 15:00 +0100
Message-ID<tcAbT-83c-7@gated-at.bofh.it>
In reply to#1580877

[Multipart message — attachments visible in raw view] — view raw

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@arndb.de>

Thanks, applied.

-- 
Doug Ledford <dledford@redhat.com>
    GPG KeyID: B826A3330E572FDD
   
Key fingerprint = AE6B 1BDA 122B 23B4 265B  1274 B826 A333 0E57 2FDD

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web