All of lore.kernel.org
 help / color / mirror / Atom feed
From: Evgeniy Polyakov <johnpol@2ka.mipt.ru>
To: Eric Dumazet <dada1@cosmosbay.com>
Cc: David Miller <davem@davemloft.net>,
	paul.moore@hp.com, kaber@trash.net, netdev@vger.kernel.org,
	acme@ghostprotocols.net,
	Eric Sesterhenn / Snakebyte <snakebyte@gmx.de>
Subject: Additional run-tme check [Run-time kfree check for correct cache]
Date: Thu, 1 Mar 2007 19:17:44 +0300	[thread overview]
Message-ID: <20070301161744.GB16344@2ka.mipt.ru> (raw)
In-Reply-To: <20070228141652.GA3033@2ka.mipt.ru>

Due to slab poisoning after origianl freeing, skb->users will not allow
subsequent freeing to succeed and fire slab debugging, which ends up
with obscure bugs.

Patch based on Eric Sesterhenn's <snakebyte@gmx.de> one, I changed
check to skb>truesize instead of skb->users.counter, since the latter in
theory can be different than simple integer containing structure.

--- linux/net/core/skbuff.c.orig	2007-02-28 11:34:13.865540564 +0100
+++ linux/net/core/skbuff.c	2007-03-01 13:42:05.633136591 +0100
@@ -407,6 +407,11 @@ void kfree_skb(struct sk_buff *skb)
 {
 	if (unlikely(!skb))
 		return;
+#ifdef CONFIG_DEBUG_SLAB
+	/* check for double kfree_skb() */
+	WARN_ON(unlikely((skb->truesize & 0xFFFFFFFF) == 0x6b6b6b6b));
+#endif
+
 	if (likely(atomic_read(&skb->users) == 1))
 		smp_rmb();
 	else if (likely(!atomic_dec_and_test(&skb->users)))

-- 
	Evgeniy Polyakov

  reply	other threads:[~2007-03-01 16:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-27 17:06 [NET]: Fix kfree(skb) Patrick McHardy
2007-02-27 17:35 ` Paul Moore
2007-02-27 18:00   ` David Miller
2007-02-27 18:14     ` Evgeniy Polyakov
2007-02-27 18:20       ` Evgeniy Polyakov
2007-02-27 18:24         ` David Miller
2007-02-27 22:24           ` Arnaldo Carvalho de Melo
2007-02-28  9:02           ` Run-time kfree check for correct cache [was Re: [NET]: Fix kfree(skb)] Evgeniy Polyakov
2007-02-28 10:10             ` Eric Dumazet
2007-02-28 14:16               ` Run-time kfree check for correct cache [plus x86_64 APIC troubles] Evgeniy Polyakov
2007-03-01 16:17                 ` Evgeniy Polyakov [this message]
2007-02-27 18:01 ` [NET]: Fix kfree(skb) David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070301161744.GB16344@2ka.mipt.ru \
    --to=johnpol@2ka.mipt.ru \
    --cc=acme@ghostprotocols.net \
    --cc=dada1@cosmosbay.com \
    --cc=davem@davemloft.net \
    --cc=kaber@trash.net \
    --cc=netdev@vger.kernel.org \
    --cc=paul.moore@hp.com \
    --cc=snakebyte@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.