Message ID | 1482027379-30785-1-git-send-email-mahesh@bandewar.net |
---|---|
State | Changes Requested, archived |
Delegated to: | David Miller |
Headers | show |
From: Mahesh Bandewar <mahesh@bandewar.net> Date: Sat, 17 Dec 2016 18:16:19 -0800 > diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c > index b4e990743e1d..4294fc1f5564 100644 > --- a/drivers/net/ipvlan/ipvlan_core.c > +++ b/drivers/net/ipvlan/ipvlan_core.c > @@ -660,6 +660,9 @@ rx_handler_result_t ipvlan_handle_frame(struct sk_buff **pskb) > if (!port) > return RX_HANDLER_PASS; > > + if (unlikely(!pskb_may_pull(skb, sizeof(struct ethhdr)))) > + goto out; > + > switch (port->mode) { ipvlan only allows non-loopback ethernet devices to register this RX handler. Such situations being tested here should therefore be completely impossible. Every such device must send the SKB through eth_type_trans(), which unconditionally accesses the ethernet header, therefore it must be pulled into the linear SKB area already, long before this RX handler is invoked. If this really can legitimately happen, you must explain how so. Just showing the crash that later happens in some (completely unrelated BTW) ipvlan multicast workqueue handling function, is really an insufficient commit log message for a bug like this.
On Sat, Dec 17, 2016 at 8:54 PM, David Miller <davem@davemloft.net> wrote: > From: Mahesh Bandewar <mahesh@bandewar.net> > Date: Sat, 17 Dec 2016 18:16:19 -0800 > >> diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c >> index b4e990743e1d..4294fc1f5564 100644 >> --- a/drivers/net/ipvlan/ipvlan_core.c >> +++ b/drivers/net/ipvlan/ipvlan_core.c >> @@ -660,6 +660,9 @@ rx_handler_result_t ipvlan_handle_frame(struct sk_buff **pskb) >> if (!port) >> return RX_HANDLER_PASS; >> >> + if (unlikely(!pskb_may_pull(skb, sizeof(struct ethhdr)))) >> + goto out; >> + >> switch (port->mode) { > > ipvlan only allows non-loopback ethernet devices to register > this RX handler. > > Such situations being tested here should therefore be completely > impossible. > Yes, correct. This happens when the master device is set in loopback mode. > Every such device must send the SKB through eth_type_trans(), which > unconditionally accesses the ethernet header, therefore it must > be pulled into the linear SKB area already, long before this RX > handler is invoked. > > If this really can legitimately happen, you must explain how so. > OK, will update the commit log. > Just showing the crash that later happens in some (completely > unrelated BTW) ipvlan multicast workqueue handling function, is > really an insufficient commit log message for a bug like this.
diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c index b4e990743e1d..4294fc1f5564 100644 --- a/drivers/net/ipvlan/ipvlan_core.c +++ b/drivers/net/ipvlan/ipvlan_core.c @@ -660,6 +660,9 @@ rx_handler_result_t ipvlan_handle_frame(struct sk_buff **pskb) if (!port) return RX_HANDLER_PASS; + if (unlikely(!pskb_may_pull(skb, sizeof(struct ethhdr)))) + goto out; + switch (port->mode) { case IPVLAN_MODE_L2: return ipvlan_handle_mode_l2(pskb, port); @@ -672,6 +675,8 @@ rx_handler_result_t ipvlan_handle_frame(struct sk_buff **pskb) /* Should not reach here */ WARN_ONCE(true, "ipvlan_handle_frame() called for mode = [%hx]\n", port->mode); + +out: kfree_skb(skb); return RX_HANDLER_CONSUMED; }