netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: add a temporary sanity check in skb_orphan()
@ 2013-08-01 18:43 Eric Dumazet
  2013-08-01 19:49 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Dumazet @ 2013-08-01 18:43 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

David suggested to add a BUG_ON() to catch if some layer
sets skb->sk pointer without a corresponding destructor.

As skb can sit in a queue, it's mandatory to make sure the
socket cannot disappear, and it's usually done by taking a
reference on the socket, then releasing it from the skb
destructor.

This patch is a follow-up to commit c34a761231b5
("net: skb_orphan() changes") and will be reverted after
catching all possible offenders if any.

Suggested-by: David Miller <davem@davemloft.net>
Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/linux/skbuff.h |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index a95547a..d48de68 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1809,6 +1809,8 @@ static inline void skb_orphan(struct sk_buff *skb)
 		skb->destructor(skb);
 		skb->destructor = NULL;
 		skb->sk		= NULL;
+	} else {
+		BUG_ON(skb->sk);
 	}
 }
 

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

end of thread, other threads:[~2013-08-01 19:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-01 18:43 [PATCH net-next] net: add a temporary sanity check in skb_orphan() Eric Dumazet
2013-08-01 19:49 ` 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).