All of lore.kernel.org
 help / color / mirror / Atom feed
* [Bridge] [PATCH net] bridge: Fix incorrect re-injection of STP packets
@ 2016-06-03  9:39 ` Ido Schimmel
  0 siblings, 0 replies; 8+ messages in thread
From: Ido Schimmel @ 2016-06-03  9:39 UTC (permalink / raw)
  To: stephen, davem
  Cc: yotamg, netdev, bridge, Florian Westphal, Ido Schimmel, jiri,
	nogahf, eladr, ogerlitz

Commit 8626c56c8279 ("bridge: fix potential use-after-free when hook
returns QUEUE or STOLEN verdict") fixed incorrect usage of NF_HOOK's
return value by consuming packets in okfn via br_pass_frame_up().

However, this function re-injects packets to the Rx path with skb->dev
set to the bridge device, which breaks kernel's STP, as all STP packets
appear to originate from the bridge device itself.

Instead, if okfn was called for a packet, make bridge's rx_handler
re-inject it to the Rx path by returning RX_HANDLER_PASS. This is
consistent with previous behavior.

Cc: Florian Westphal <fw@strlen.de>
Fixes: 8626c56c8279 ("bridge: fix potential use-after-free when hook returns QUEUE or STOLEN verdict")
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 net/bridge/br_input.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 1607977..c73ed44 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -223,9 +223,7 @@ static int br_handle_local_finish(struct net *net, struct sock *sk, struct sk_bu
 	if (p->flags & BR_LEARNING && br_should_learn(p, skb, &vid))
 		br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, false);
 
-	BR_INPUT_SKB_CB(skb)->brdev = p->br->dev;
-	br_pass_frame_up(skb);
-	return 0;
+	return RX_HANDLER_PASS;
 }
 
 /*
@@ -238,6 +236,7 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
 	struct sk_buff *skb = *pskb;
 	const unsigned char *dest = eth_hdr(skb)->h_dest;
 	br_should_route_hook_t *rhook;
+	int err;
 
 	if (unlikely(skb->pkt_type == PACKET_LOOPBACK))
 		return RX_HANDLER_PASS;
@@ -287,8 +286,11 @@ rx_handler_result_t br_handle_frame(struct sk_buff **pskb)
 		}
 
 		/* Deliver packet to local host only */
-		NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, dev_net(skb->dev),
-			NULL, skb, skb->dev, NULL, br_handle_local_finish);
+		err = NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, dev_net(skb->dev),
+			      NULL, skb, skb->dev, NULL,
+			      br_handle_local_finish);
+		if (err == RX_HANDLER_PASS)
+			return RX_HANDLER_PASS;
 		return RX_HANDLER_CONSUMED;
 	}
 
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2016-06-05  7:40 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-03  9:39 [Bridge] [PATCH net] bridge: Fix incorrect re-injection of STP packets Ido Schimmel
2016-06-03  9:39 ` Ido Schimmel
2016-06-04  6:41 ` [Bridge] " Shmulik Ladkani
2016-06-04  6:41   ` Shmulik Ladkani
2016-06-04  8:15   ` [Bridge] " Ido Schimmel
2016-06-04  8:15     ` Ido Schimmel
2016-06-05  7:40 ` [Bridge] " Ido Schimmel
2016-06-05  7:40   ` Ido Schimmel

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.