All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] qmi_wwan: Clone the skb when in pass-through mode
@ 2021-06-14 14:18 Kristian Evensen
  2021-06-14 14:45 ` Bjørn Mork
  0 siblings, 1 reply; 14+ messages in thread
From: Kristian Evensen @ 2021-06-14 14:18 UTC (permalink / raw)
  To: bjorn, netdev, subashab; +Cc: Kristian Evensen

The skb that we pass to the rmnet driver is owned by usbnet and is freed
soon after the rx_fixup() callback is called (in usbnet_bh()).  There is
no guarantee that rmnet is done handling the skb before it is freed. We
should clone the skb before we call netif_rx() to prevent use-after-free
and misc. kernel oops.

Fixes: 59e139cf0b32 ("net: qmi_wwan: Add pass through mode")

Signed-off-by: Kristian Evensen <kristian.evensen@gmail.com>
---
 drivers/net/usb/qmi_wwan.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index db8d3a4f2678..5ac307eb0bfd 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -620,6 +620,10 @@ static int qmi_wwan_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
 		return qmimux_rx_fixup(dev, skb);
 
 	if (info->flags & QMI_WWAN_FLAG_PASS_THROUGH) {
+		skb = skb_clone(skb, GFP_ATOMIC);
+		if (!skb)
+			return 0;
+
 		skb->protocol = htons(ETH_P_MAP);
 		return (netif_rx(skb) == NET_RX_SUCCESS);
 	}
-- 
2.25.1


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

end of thread, other threads:[~2021-06-16 10:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-14 14:18 [PATCH net] qmi_wwan: Clone the skb when in pass-through mode Kristian Evensen
2021-06-14 14:45 ` Bjørn Mork
2021-06-14 15:49   ` Kristian Evensen
2021-06-14 17:02     ` Kristian Evensen
2021-06-14 20:05   ` Jakub Kicinski
2021-06-15  6:24     ` Bjørn Mork
2021-06-15  9:03     ` Kristian Evensen
2021-06-15 10:04       ` Bjørn Mork
2021-06-15 10:51         ` Kristian Evensen
2021-06-15 11:04           ` Kristian Evensen
2021-06-15 13:39             ` Bjørn Mork
2021-06-15 19:26               ` Jakub Kicinski
2021-06-15 19:27                 ` Jakub Kicinski
2021-06-16 10:08                 ` Kristian Evensen

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.