netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
	pabeni@redhat.com
Cc: netdev@vger.kernel.org, aleksander.lobakin@intel.com,
	nex.sw.ncis.osdt.itp.upstreaming@intel.com,
	Arnd Bergmann <arnd@arndb.de>
Subject: Re: [net-next v1] pfcp: avoid copy warning by simplifing code
Date: Thu, 4 Apr 2024 15:59:12 +0200	[thread overview]
Message-ID: <Zg6yMB/3w4EBQVDm@mev-dev> (raw)
In-Reply-To: <20240404135721.647474-1-michal.swiatkowski@linux.intel.com>

On Thu, Apr 04, 2024 at 03:57:21PM +0200, Michal Swiatkowski wrote:
> From Arnd comment:
> "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.
> 
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
> ---
>  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
> 

Ehh, sorry, misstype in netdev ccing
CC: netdev@vger.kernel.org

       reply	other threads:[~2024-04-04 13:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20240404135721.647474-1-michal.swiatkowski@linux.intel.com>
2024-04-04 13:59 ` Michal Swiatkowski [this message]
2024-04-04 14:22   ` [net-next v1] pfcp: avoid copy warning by simplifing code Arnd Bergmann
2024-04-04 14:59   ` Jakub Kicinski
2024-04-04 16:21     ` Alexander Lobakin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zg6yMB/3w4EBQVDm@mev-dev \
    --to=michal.swiatkowski@linux.intel.com \
    --cc=aleksander.lobakin@intel.com \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nex.sw.ncis.osdt.itp.upstreaming@intel.com \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).