Skip to contentSkip to conversation

ipvlan: don't deref eth hdr before checking it's set

PATCH In review Mahesh Bandewar 2 participants 2 messages Mar 9, 2020 – Mar 10, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ipvlan: don't deref eth hdr before checking it's set

IPvlan in L3 mode discards outbound multicast packets but performs the check before ensuring the ether-header is set or not. This is an error that Eric found through code browsing.

Fixes 2ad7bf363841 (“ipvlan: Initial check-in of the IPVLAN driver.”)
---
 drivers/net/ipvlan/ipvlan_core.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
drivers/net/ipvlan/ipvlan_core.c +10 -8
index 30cd0c4f0be0..53dac397db37 100644
@@ -498,19 +498,21 @@ static int ipvlan_process_outbound(struct sk_buff *skb)
 	struct ethhdr *ethh = eth_hdr(skb);
 	int ret = NET_XMIT_DROP;
 
-	/* In this mode we dont care about multicast and broadcast traffic */
-	if (is_multicast_ether_addr(ethh->h_dest)) {
-		pr_debug_ratelimited("Dropped {multi|broad}cast of type=[%x]\n",
-				     ntohs(skb->protocol));
-		kfree_skb(skb);
-		goto out;
-	}
-
 	/* The ipvlan is a pseudo-L2 device, so the packets that we receive
 	 * will have L2; which need to discarded and processed further
 	 * in the net-ns of the main-device.
 	 */
 	if (skb_mac_header_was_set(skb)) {
+		/* In this mode we dont care about
+		 * multicast and broadcast traffic */
+		if (is_multicast_ether_addr(ethh->h_dest)) {
+			pr_debug_ratelimited(
+				"Dropped {multi|broad}cast of type=[%x]\n",
+				ntohs(skb->protocol));
+			kfree_skb(skb);
+			goto out;
+		}
+
 		skb_pull(skb, sizeof(*ethh));
 		skb->mac_header = (typeof(skb->mac_header))~0U;
 		skb_reset_network_header(skb);
Signature · 1 line
2.25.1.481.gfbce0eb801-goog
maintainer
#1 lore raw

From: Mahesh Bandewar <[email protected]>
Date: Mon, 9 Mar 2020 15:56:56 -0700

Quoted 7 lines

IPvlan in L3 mode discards outbound multicast packets but performs the check before ensuring the ether-header is set or not. This is an error that Eric found through code browsing.

Fixes 2ad7bf363841 (“ipvlan: Initial check-in of the IPVLAN driver.”)

Applied and queued up for -stable.