All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] net: ipv4: Avoid bounds check warning
@ 2022-05-26 10:12 zhanggenjian
  2022-05-30 16:10 ` David Ahern
  2022-05-31  4:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: zhanggenjian @ 2022-05-26 10:12 UTC (permalink / raw)
  To: pabeni, edumazet, davem, yoshfuji, dsahern, kuba
  Cc: netdev, linux-kernel, huhai, zhanggenjian123

From: huhai <huhai@kylinos.cn>

Fix the following build warning when CONFIG_IPV6 is not set:

In function ‘fortify_memcpy_chk’,
    inlined from ‘tcp_md5_do_add’ at net/ipv4/tcp_ipv4.c:1210:2:
./include/linux/fortify-string.h:328:4: error: call to ‘__write_overflow_field’ declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
  328 |    __write_overflow_field(p_size_field, size);
      |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: huhai <huhai@kylinos.cn>
---
 net/ipv4/tcp_ipv4.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 457f5b5d5d4a..46ae9d535086 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1208,8 +1208,8 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
 	key->l3index = l3index;
 	key->flags = flags;
 	memcpy(&key->addr, addr,
-	       (family == AF_INET6) ? sizeof(struct in6_addr) :
-				      sizeof(struct in_addr));
+	       (IS_ENABLED(CONFIG_IPV6) && family == AF_INET6) ? sizeof(struct in6_addr) :
+								 sizeof(struct in_addr));
 	hlist_add_head_rcu(&key->node, &md5sig->head);
 	return 0;
 }
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] net: ipv4: Avoid bounds check warning
  2022-05-26 10:12 [PATCH v2] net: ipv4: Avoid bounds check warning zhanggenjian
@ 2022-05-30 16:10 ` David Ahern
  2022-05-31  4:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: David Ahern @ 2022-05-30 16:10 UTC (permalink / raw)
  To: zhanggenjian, pabeni, edumazet, davem, yoshfuji, kuba
  Cc: netdev, linux-kernel, huhai

On 5/26/22 4:12 AM, zhanggenjian wrote:
> From: huhai <huhai@kylinos.cn>
> 
> Fix the following build warning when CONFIG_IPV6 is not set:
> 
> In function ‘fortify_memcpy_chk’,
>     inlined from ‘tcp_md5_do_add’ at net/ipv4/tcp_ipv4.c:1210:2:
> ./include/linux/fortify-string.h:328:4: error: call to ‘__write_overflow_field’ declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
>   328 |    __write_overflow_field(p_size_field, size);
>       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> Suggested-by: Paolo Abeni <pabeni@redhat.com>
> Signed-off-by: huhai <huhai@kylinos.cn>
> ---
>  net/ipv4/tcp_ipv4.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 

Reviewed-by: David Ahern <dsahern@kernel.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] net: ipv4: Avoid bounds check warning
  2022-05-26 10:12 [PATCH v2] net: ipv4: Avoid bounds check warning zhanggenjian
  2022-05-30 16:10 ` David Ahern
@ 2022-05-31  4:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-05-31  4:40 UTC (permalink / raw)
  To: zhanggenjian
  Cc: pabeni, edumazet, davem, yoshfuji, dsahern, kuba, netdev,
	linux-kernel, huhai

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 26 May 2022 18:12:13 +0800 you wrote:
> From: huhai <huhai@kylinos.cn>
> 
> Fix the following build warning when CONFIG_IPV6 is not set:
> 
> In function ‘fortify_memcpy_chk’,
>     inlined from ‘tcp_md5_do_add’ at net/ipv4/tcp_ipv4.c:1210:2:
> ./include/linux/fortify-string.h:328:4: error: call to ‘__write_overflow_field’ declared with attribute warning: detected write beyond size of field (1st parameter); maybe use struct_group()? [-Werror=attribute-warning]
>   328 |    __write_overflow_field(p_size_field, size);
>       |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> [...]

Here is the summary with links:
  - [v2] net: ipv4: Avoid bounds check warning
    https://git.kernel.org/netdev/net/c/3a2cd89bfbeb

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-05-31  4:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-26 10:12 [PATCH v2] net: ipv4: Avoid bounds check warning zhanggenjian
2022-05-30 16:10 ` David Ahern
2022-05-31  4:40 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.