Commit 3a2cd89b authored by huhai's avatar huhai Committed by Jakub Kicinski
Browse files

net: ipv4: Avoid bounds check warning



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: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarhuhai <huhai@kylinos.cn>
Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
Link: https://lore.kernel.org/r/20220526101213.2392980-1-zhanggenjian@kylinos.cn


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 90343f57
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -1207,7 +1207,7 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
	key->l3index = l3index;
	key->l3index = l3index;
	key->flags = flags;
	key->flags = flags;
	memcpy(&key->addr, addr,
	memcpy(&key->addr, addr,
	       (family == AF_INET6) ? sizeof(struct in6_addr) :
	       (IS_ENABLED(CONFIG_IPV6) && family == AF_INET6) ? sizeof(struct in6_addr) :
								 sizeof(struct in_addr));
								 sizeof(struct in_addr));
	hlist_add_head_rcu(&key->node, &md5sig->head);
	hlist_add_head_rcu(&key->node, &md5sig->head);
	return 0;
	return 0;