bridge.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Nikolay Aleksandrov <razor@blackwall.org>
To: Felix Fietkau <nbd@nbd.name>,
	netdev@vger.kernel.org, Roopa Prabhu <roopa@nvidia.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: bridge@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net] net: bridge: fix corrupted ethernet header on multicast-to-unicast
Date: Tue, 7 May 2024 15:15:43 +0300	[thread overview]
Message-ID: <9a1825ff-3a55-4c2a-86bc-0709d4ff8153@blackwall.org> (raw)
In-Reply-To: <20240505184239.15002-1-nbd@nbd.name>

On 05/05/2024 21:42, Felix Fietkau wrote:
> The change from skb_copy to pskb_copy unfortunately changed the data
> copying to omit the ethernet header, since it was pulled before reaching
> this point. Fix this by calling __skb_push/pull around pskb_copy.
> 
> Fixes: 59c878cbcdd8 ("net: bridge: fix multicast-to-unicast with fraglist GSO")
> Signed-off-by: Felix Fietkau <nbd@nbd.name>
> ---
>   net/bridge/br_forward.c | 9 +++++++--
>   1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
> index d7c35f55bd69..d97064d460dc 100644
> --- a/net/bridge/br_forward.c
> +++ b/net/bridge/br_forward.c
> @@ -258,6 +258,7 @@ static void maybe_deliver_addr(struct net_bridge_port *p, struct sk_buff *skb,
>   {
>   	struct net_device *dev = BR_INPUT_SKB_CB(skb)->brdev;
>   	const unsigned char *src = eth_hdr(skb)->h_source;
> +	struct sk_buff *nskb;
>   
>   	if (!should_deliver(p, skb))
>   		return;
> @@ -266,12 +267,16 @@ static void maybe_deliver_addr(struct net_bridge_port *p, struct sk_buff *skb,
>   	if (skb->dev == p->dev && ether_addr_equal(src, addr))
>   		return;
>   
> -	skb = pskb_copy(skb, GFP_ATOMIC);
> -	if (!skb) {
> +	__skb_push(skb, ETH_HLEN);
> +	nskb = pskb_copy(skb, GFP_ATOMIC);
> +	__skb_pull(skb, ETH_HLEN);
> +	if (!nskb) {
>   		DEV_STATS_INC(dev, tx_dropped);
>   		return;
>   	}
>   
> +	skb = nskb;
> +	__skb_pull(skb, ETH_HLEN);
>   	if (!is_broadcast_ether_addr(addr))
>   		memcpy(eth_hdr(skb)->h_dest, addr, ETH_ALEN);
>   

This dance is getting ugly, but better to have it correct.
It'd be nice if you could add a selftest that exercises it.

Acked-by: Nikolay Aleksandrov <razor@blackwall.org>


  reply	other threads:[~2024-05-07 12:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-05 18:42 [PATCH net] net: bridge: fix corrupted ethernet header on multicast-to-unicast Felix Fietkau
2024-05-07 12:15 ` Nikolay Aleksandrov [this message]
2024-05-08  9:40 ` patchwork-bot+netdevbpf

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=9a1825ff-3a55-4c2a-86bc-0709d4ff8153@blackwall.org \
    --to=razor@blackwall.org \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nbd@nbd.name \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=roopa@nvidia.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 read-only IMAP folder(s) and NNTP newsgroup(s).