From: Stephen Hemminger <shemminger@osdl.org>
To: Guillaume Chazarain <guichaz@yahoo.fr>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] Fix slab corruption with netem
Date: Sat, 15 Jul 2006 08:49:32 -0700 [thread overview]
Message-ID: <44B90E8C.5090400@osdl.org> (raw)
In-Reply-To: <44B8395A.1050602@yahoo.fr>
Guillaume Chazarain wrote:
> 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.
>
> ------------------------------------------------------------------------
>
> --- 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;
>
Would rather leave it unitialized, rather than setting to 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)) {
>
>
next prev parent reply other threads:[~2006-07-15 15:49 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-07-15 0:39 [PATCH] Fix slab corruption with netem Guillaume Chazarain
2006-07-15 15:49 ` Stephen Hemminger [this message]
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=44B90E8C.5090400@osdl.org \
--to=shemminger@osdl.org \
--cc=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 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).