diff mbox

[v2] arc_emac: fix potential use after free

Message ID 20131227.130506.1806271226641881502.davem@davemloft.net
State Accepted, archived
Delegated to: David Miller
Headers show

Commit Message

David Miller Dec. 27, 2013, 6:05 p.m. UTC
From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 19 Dec 2013 18:10:40 -0800

> Signed-off-by: Eric Dumazet <edumazet@google.com>
> 
> skb_tx_timestamp(skb) should be called _before_ TX completion
> has a chance to trigger, otherwise it is too late and we access
> freed memory.
> 
> Fixes: e4f2379db6c6 ("ethernet/arc/arc_emac - Add new driver")
> From: Eric Dumazet <edumazet@google.com>
> Cc: Alexey Brodkin <Alexey.Brodkin@synopsys.com>
> Cc: Richard Cochran <richardcochran@gmail.com>

Applied, thanks.

I've seen this bug enough times that I've expanded the comment
a bit more.
diff mbox

Patch

====================
[PATCH] net: Add some clarification to skb_tx_timestamp() comment.

We've seen so many instances of people invoking skb_tx_timestamp()
after the device already has been given the packet, that it's worth
being a little bit more verbose and explicit in this comment.

Signed-off-by: David S. Miller <davem@davemloft.net>
---
 include/linux/skbuff.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 6aae838..6f69b3f 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -2531,6 +2531,10 @@  static inline void sw_tx_timestamp(struct sk_buff *skb)
  * Ethernet MAC Drivers should call this function in their hard_xmit()
  * function immediately before giving the sk_buff to the MAC hardware.
  *
+ * Specifically, one should make absolutely sure that this function is
+ * called before TX completion of this packet can trigger.  Otherwise
+ * the packet could potentially already be freed.
+ *
  * @skb: A socket buffer.
  */
 static inline void skb_tx_timestamp(struct sk_buff *skb)