* [PATCH net] net: bridge: fix corrupted ethernet header on multicast-to-unicast
@ 2024-05-05 18:42 Felix Fietkau
2024-05-07 12:15 ` Nikolay Aleksandrov
2024-05-08 9:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Felix Fietkau @ 2024-05-05 18:42 UTC (permalink / raw)
To: netdev, Roopa Prabhu, Nikolay Aleksandrov, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: bridge, linux-kernel
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);
--
2.44.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH net] net: bridge: fix corrupted ethernet header on multicast-to-unicast
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
2024-05-08 9:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Aleksandrov @ 2024-05-07 12:15 UTC (permalink / raw)
To: Felix Fietkau, netdev, Roopa Prabhu, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: bridge, linux-kernel
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>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH net] net: bridge: fix corrupted ethernet header on multicast-to-unicast
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
@ 2024-05-08 9:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-05-08 9:40 UTC (permalink / raw)
To: Felix Fietkau
Cc: netdev, roopa, razor, davem, edumazet, kuba, pabeni, bridge,
linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:
On Sun, 5 May 2024 20:42:38 +0200 you 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>
>
> [...]
Here is the summary with links:
- [net] net: bridge: fix corrupted ethernet header on multicast-to-unicast
https://git.kernel.org/netdev/net/c/86b29d830ad6
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-05-08 9:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
2024-05-08 9:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox