* [PATCH net] ipvlan: don't deref eth hdr before checking it's set
@ 2020-03-09 22:56 Mahesh Bandewar
2020-03-10 1:00 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Mahesh Bandewar @ 2020-03-09 22:56 UTC (permalink / raw)
To: David Miller, Netdev; +Cc: Eric Dumazet, Mahesh Bandewar, Mahesh Bandewar
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.”)
Signed-off-by: Mahesh Bandewar <maheshb@google.com>
Reported-by: Eric Dumazet <edumazet@google.com>
---
drivers/net/ipvlan/ipvlan_core.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c
index 30cd0c4f0be0..53dac397db37 100644
--- a/drivers/net/ipvlan/ipvlan_core.c
+++ b/drivers/net/ipvlan/ipvlan_core.c
@@ -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);
--
2.25.1.481.gfbce0eb801-goog
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] ipvlan: don't deref eth hdr before checking it's set
2020-03-09 22:56 [PATCH net] ipvlan: don't deref eth hdr before checking it's set Mahesh Bandewar
@ 2020-03-10 1:00 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2020-03-10 1:00 UTC (permalink / raw)
To: maheshb; +Cc: netdev, edumazet, mahesh
From: Mahesh Bandewar <maheshb@google.com>
Date: Mon, 9 Mar 2020 15:56:56 -0700
> 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.”)
> Signed-off-by: Mahesh Bandewar <maheshb@google.com>
> Reported-by: Eric Dumazet <edumazet@google.com>
Applied and queued up for -stable.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-03-10 1:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-09 22:56 [PATCH net] ipvlan: don't deref eth hdr before checking it's set Mahesh Bandewar
2020-03-10 1:00 ` David Miller
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.