All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Yan Zhai <yan@cloudflare.com>
Cc: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	David Ahern <dsahern@kernel.org>,
	Abhishek Chauhan <quic_abchauha@quicinc.com>,
	Mina Almasry <almasrymina@google.com>,
	Florian Westphal <fw@strlen.de>,
	Alexander Lobakin <aleksander.lobakin@intel.com>,
	David Howells <dhowells@redhat.com>,
	Jiri Pirko <jiri@resnulli.us>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Pavel Begunkov <asml.silence@gmail.com>,
	linux-kernel@vger.kernel.org, kernel-team@cloudflare.com,
	Jesper Dangaard Brouer <hawk@kernel.org>
Subject: Re: [RFC v2 net-next 7/7] af_packet: use sk_skb_reason_drop to free rx packets
Date: Tue, 4 Jun 2024 16:18:55 +0100	[thread overview]
Message-ID: <20240604151855.GT491852@kernel.org> (raw)
In-Reply-To: <b86569aac8c4a2f180e7d3e22389547ff2e26cdc.1717206060.git.yan@cloudflare.com>

On Fri, May 31, 2024 at 06:43:00PM -0700, Yan Zhai wrote:
> Replace kfree_skb_reason with sk_skb_reason_drop and pass the receiving
> socket to the tracepoint.
> 
> Signed-off-by: Yan Zhai <yan@cloudflare.com>
> ---
>  net/packet/af_packet.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
> index fce390887591..3133d4eb4a1b 100644
> --- a/net/packet/af_packet.c
> +++ b/net/packet/af_packet.c

Hi Yan Zhai,

Near the top of packet_rcv,
immediately after local variable declarations, and
before sk is initialised is the following:

	if (skb->pkt_type == PACKET_LOOPBACK)
		goto drop;

> @@ -2226,7 +2226,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
>  		skb->len = skb_len;
>  	}
>  drop:
> -	kfree_skb_reason(skb, drop_reason);
> +	sk_skb_reason_drop(sk, skb, drop_reason);

So sk may be used uninitialised here.

Similarly in tpacket_rcv()

Flagged by clang-18 W=1 allmodconfig builds on x86_64.

>  	return 0;
>  }
>  
> @@ -2494,7 +2494,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
>  		skb->len = skb_len;
>  	}
>  drop:
> -	kfree_skb_reason(skb, drop_reason);
> +	sk_skb_reason_drop(sk, skb, drop_reason);
>  	return 0;
>  
>  drop_n_account:
> @@ -2503,7 +2503,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
>  	drop_reason = SKB_DROP_REASON_PACKET_SOCK_ERROR;
>  
>  	sk->sk_data_ready(sk);
> -	kfree_skb_reason(copy_skb, drop_reason);
> +	sk_skb_reason_drop(sk, copy_skb, drop_reason);
>  	goto drop_n_restore;
>  }
>  
> -- 
> 2.30.2
> 
> 

  reply	other threads:[~2024-06-04 15:19 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-01  1:42 [RFC v2 net-next 0/7] net: pass receive socket to drop tracepoint Yan Zhai
2024-06-01  1:42 ` [RFC v2 net-next 1/7] net: add rx_sk to trace_kfree_skb Yan Zhai
2024-06-01  8:55   ` kernel test robot
2024-06-01 12:56   ` kernel test robot
2024-06-01  1:42 ` [RFC v2 net-next 2/7] net: introduce sk_skb_reason_drop function Yan Zhai
2024-06-01  1:42 ` [RFC v2 net-next 3/7] ping: use sk_skb_reason_drop to free rx packets Yan Zhai
2024-06-01  1:42 ` [RFC v2 net-next 4/7] net: raw: " Yan Zhai
2024-06-01  1:42 ` [RFC v2 net-next 5/7] tcp: " Yan Zhai
2024-06-01  1:42 ` [RFC v2 net-next 6/7] udp: " Yan Zhai
2024-06-01  1:43 ` [RFC v2 net-next 7/7] af_packet: " Yan Zhai
2024-06-04 15:18   ` Simon Horman [this message]
2024-06-04 20:35     ` Yan Zhai

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=20240604151855.GT491852@kernel.org \
    --to=horms@kernel.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=almasrymina@google.com \
    --cc=asml.silence@gmail.com \
    --cc=bigeasy@linutronix.de \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=hawk@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=kernel-team@cloudflare.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=quic_abchauha@quicinc.com \
    --cc=yan@cloudflare.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 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.