From: Guillaume Chazarain <guichaz@yahoo.fr>
To: netdev@vger.kernel.org
Subject: [PATCH] Fix slab corruption with netem
Date: Sat, 15 Jul 2006 02:39:54 +0200 [thread overview]
Message-ID: <44B8395A.1050602@yahoo.fr> (raw)
[-- Attachment #1: Type: text/plain, Size: 426 bytes --]
Hello,
CONFIG_DEBUG_SLAB found the following bug:
netem_enqueue() in sch_netem.c gets a pointer inside a slab object:
struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
But then, the slab object may be freed: skb = skb_unshare(skb, GFP_ATOMIC)
cb is still pointing inside the freed skb, so here is a patch to
initialize cb later, and make it clear
that initializing it sooner is a bad idea.
Thanks.
--
Guillaume
[-- Attachment #2: netem_cb_initialization.diff --]
[-- Type: text/x-patch, Size: 845 bytes --]
--- a/net/sched/sch_netem.c
+++ b/net/sched/sch_netem.c
@@ -148,7 +148,8 @@ static int netem_enqueue(struct sk_buff
static int netem_enqueue(struct sk_buff *skb, struct Qdisc *sch)
{
struct netem_sched_data *q = qdisc_priv(sch);
- struct netem_skb_cb *cb = (struct netem_skb_cb *)skb->cb;
+ /* We don't fill cb now as skb_unshare() may invalidate it */
+ struct netem_skb_cb *cb = NULL;
struct sk_buff *skb2;
int ret;
int count = 1;
@@ -200,6 +201,7 @@ static int netem_enqueue(struct sk_buff
skb->data[net_random() % skb_headlen(skb)] ^= 1<<(net_random() % 8);
}
+ cb = (struct netem_skb_cb *)skb->cb;
if (q->gap == 0 /* not doing reordering */
|| q->counter < q->gap /* inside last reordering gap */
|| q->reorder < get_crandom(&q->reorder_cor)) {
--
Signed-off-by: Guillaume Chazarain <guichaz@yahoo.fr>
next reply other threads:[~2006-07-15 0:38 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-15 0:39 Guillaume Chazarain [this message]
2006-07-15 15:49 ` [PATCH] Fix slab corruption with netem Stephen Hemminger
2006-07-15 16:06 ` Guillaume Chazarain
2006-07-15 23:34 ` Stephen Hemminger
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=44B8395A.1050602@yahoo.fr \
--to=guichaz@yahoo.fr \
--cc=netdev@vger.kernel.org \
/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.