linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rapidio/rionet: do not free skb before reading its length
@ 2018-11-28  6:53 Pan Bian
  2018-11-28 18:41 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2018-11-28  6:53 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel, Alexandre Bounine, Pan Bian

skb is freed via dev_kfree_skb_any, however, skb->len is read then. This
may result in a use-after-free bug.

Fixes: e6161d64263 ("rapidio/rionet: rework driver initialization and removal")
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
 drivers/net/rionet.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c
index e9f101c..bfbb39f 100644
--- a/drivers/net/rionet.c
+++ b/drivers/net/rionet.c
@@ -216,9 +216,9 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev)
 			 * it just report sending a packet to the target
 			 * (without actual packet transfer).
 			 */
-			dev_kfree_skb_any(skb);
 			ndev->stats.tx_packets++;
 			ndev->stats.tx_bytes += skb->len;
+			dev_kfree_skb_any(skb);
 		}
 	}
 
-- 
2.7.4



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

* Re: [PATCH] rapidio/rionet: do not free skb before reading its length
  2018-11-28  6:53 [PATCH] rapidio/rionet: do not free skb before reading its length Pan Bian
@ 2018-11-28 18:41 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-11-28 18:41 UTC (permalink / raw)
  To: bianpan2016; +Cc: netdev, linux-kernel, alexandre.bounine

From: Pan Bian <bianpan2016@163.com>
Date: Wed, 28 Nov 2018 14:53:19 +0800

> skb is freed via dev_kfree_skb_any, however, skb->len is read then. This
> may result in a use-after-free bug.
> 
> Fixes: e6161d64263 ("rapidio/rionet: rework driver initialization and removal")
> Signed-off-by: Pan Bian <bianpan2016@163.com>

Applied and queued up for -stable.

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

end of thread, other threads:[~2018-11-28 18:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-28  6:53 [PATCH] rapidio/rionet: do not free skb before reading its length Pan Bian
2018-11-28 18:41 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).