lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240405063605.649744-1-michal.swiatkowski@linux.intel.com>
Date: Fri,  5 Apr 2024 08:36:05 +0200
From: Michal Swiatkowski <michal.swiatkowski@...ux.intel.com>
To: davem@...emloft.net,
	edumazet@...gle.com,
	kuba@...nel.org,
	pabeni@...hat.com
Cc: netdev@...r.kernel.org,
	aleksander.lobakin@...el.com,
	nex.sw.ncis.osdt.itp.upstreaming@...el.com,
	Michal Swiatkowski <michal.swiatkowski@...ux.intel.com>,
	Arnd Bergmann <arnd@...db.de>
Subject: [net-next v2] pfcp: avoid copy warning by simplifing code

>From Arnd comments:
"The memcpy() in the ip_tunnel_info_opts_set() causes
a string.h fortification warning, with at least gcc-13:

    In function 'fortify_memcpy_chk',
        inlined from 'ip_tunnel_info_opts_set' at include/net/ip_tunnels.h:619:3,
        inlined from 'pfcp_encap_recv' at drivers/net/pfcp.c:84:2:
    include/linux/fortify-string.h:553:25: 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]
      553 |                         __write_overflow_field(p_size_field, size);"

It is a false-positivie caused by ambiguity of the union.

However, as Arnd noticed, copying here is unescessary. The code can be
simplified to avoid calling ip_tunnel_info_opts_set(), which is doing
copying, setting flags and options_len.

Set correct flags and options_len directly on tun_info.

Fixes: 6dd514f48110 ("pfcp: always set pfcp metadata")
Reported-by: Arnd Bergmann <arnd@...db.de>
Closes: https://lore.kernel.org/netdev/701f8f93-f5fb-408b-822a-37a1d5c424ba@app.fastmail.com/
Acked-by: Arnd Bergmann <arnd@...db.de>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@...ux.intel.com>
---
v1 --> v2:
Links: https://lore.kernel.org/netdev/Zg6yMB%2F3w4EBQVDm@mev-dev/
 * Add Fixes and Closes tag
---
 drivers/net/pfcp.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/pfcp.c b/drivers/net/pfcp.c
index cc5b28c5f99f..69434fd13f96 100644
--- a/drivers/net/pfcp.c
+++ b/drivers/net/pfcp.c
@@ -80,9 +80,8 @@ static int pfcp_encap_recv(struct sock *sk, struct sk_buff *skb)
 	else
 		pfcp_node_recv(pfcp, skb, md);
 
-	__set_bit(IP_TUNNEL_PFCP_OPT_BIT, flags);
-	ip_tunnel_info_opts_set(&tun_dst->u.tun_info, md, sizeof(*md),
-				flags);
+	__set_bit(IP_TUNNEL_PFCP_OPT_BIT, tun_dst->u.tun_info.key.tun_flags);
+	tun_dst->u.tun_info.options_len = sizeof(*md);
 
 	if (unlikely(iptunnel_pull_header(skb, PFCP_HLEN, skb->protocol,
 					  !net_eq(sock_net(sk),
-- 
2.42.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ