netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2.6 NET] Fixes slab corruption in cbq_destroy
@ 2004-09-16 13:28 Thomas Graf
  2004-09-16 13:47 ` Patrick McHardy
  2004-09-16 20:29 ` David S. Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Graf @ 2004-09-16 13:28 UTC (permalink / raw)
  To: David S. Miller; +Cc: Patrick McHardy, Alexey Kuznetsov, netdev

Fixes slab corruption in cbq_destroy. cbq_destroy_filters and
qdisc_put_rtab(q->link.R_tab) are already called in cbq_destroy_class.
The latter lead to a slab corruption due to repeated freeing of
q->link.R_tab because q->link is part of q->classes. Problem introduced
in 1.21.

Signed-off-by: Thomas Graf <tgraf@suug.ch>


--- linux-2.6.9-rc2-bk2.orig/net/sched/sch_cbq.c	2004-09-16 14:52:23.000000000 +0200
+++ linux-2.6.9-rc2-bk2/net/sched/sch_cbq.c	2004-09-16 14:53:53.000000000 +0200
@@ -1770,10 +1770,6 @@
 #ifdef CONFIG_NET_CLS_POLICE
 	q->rx_class = NULL;
 #endif
-	for (h = 0; h < 16; h++) {
-		for (cl = q->classes[h]; cl; cl = cl->next)
-			cbq_destroy_filters(cl);
-	}
 
 	for (h = 0; h < 16; h++) {
 		struct cbq_class *next;
@@ -1783,8 +1779,6 @@
 			cbq_destroy_class(sch, cl);
 		}
 	}
-
-	qdisc_put_rtab(q->link.R_tab);
 }
 
 static void cbq_put(struct Qdisc *sch, unsigned long arg)

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

* Re: [PATCH 2.6 NET] Fixes slab corruption in cbq_destroy
  2004-09-16 13:28 [PATCH 2.6 NET] Fixes slab corruption in cbq_destroy Thomas Graf
@ 2004-09-16 13:47 ` Patrick McHardy
  2004-09-16 14:09   ` Thomas Graf
  2004-09-16 20:29 ` David S. Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Patrick McHardy @ 2004-09-16 13:47 UTC (permalink / raw)
  To: Thomas Graf; +Cc: David S. Miller, Alexey Kuznetsov, netdev

Thomas Graf wrote:

>Fixes slab corruption in cbq_destroy. cbq_destroy_filters and
>qdisc_put_rtab(q->link.R_tab) are already called in cbq_destroy_class.
>The latter lead to a slab corruption due to repeated freeing of
>q->link.R_tab because q->link is part of q->classes. Problem introduced
>in 1.21.
>  
>
I don't see how there can be slab corruption. qdisc_put_rtab only
calls kfree if the table is found in qdisc_rtab_list, which only
happens once. But the patch is still fine as cleanup :)

Regards
Patrick

>Signed-off-by: Thomas Graf <tgraf@suug.ch>
>
>
>--- linux-2.6.9-rc2-bk2.orig/net/sched/sch_cbq.c	2004-09-16 14:52:23.000000000 +0200
>+++ linux-2.6.9-rc2-bk2/net/sched/sch_cbq.c	2004-09-16 14:53:53.000000000 +0200
>@@ -1770,10 +1770,6 @@
> #ifdef CONFIG_NET_CLS_POLICE
> 	q->rx_class = NULL;
> #endif
>-	for (h = 0; h < 16; h++) {
>-		for (cl = q->classes[h]; cl; cl = cl->next)
>-			cbq_destroy_filters(cl);
>-	}
> 
> 	for (h = 0; h < 16; h++) {
> 		struct cbq_class *next;
>@@ -1783,8 +1779,6 @@
> 			cbq_destroy_class(sch, cl);
> 		}
> 	}
>-
>-	qdisc_put_rtab(q->link.R_tab);
> }
> 
> static void cbq_put(struct Qdisc *sch, unsigned long arg)
>
>  
>

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

* Re: [PATCH 2.6 NET] Fixes slab corruption in cbq_destroy
  2004-09-16 13:47 ` Patrick McHardy
@ 2004-09-16 14:09   ` Thomas Graf
  2004-09-16 14:58     ` Patrick McHardy
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Graf @ 2004-09-16 14:09 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: David S. Miller, Alexey Kuznetsov, netdev

* Patrick McHardy <4149998C.6060501@trash.net> 2004-09-16 15:47
> Thomas Graf wrote:
> 
> >Fixes slab corruption in cbq_destroy. cbq_destroy_filters and
> >qdisc_put_rtab(q->link.R_tab) are already called in cbq_destroy_class.
> >The latter lead to a slab corruption due to repeated freeing of
> >q->link.R_tab because q->link is part of q->classes. Problem introduced
> >in 1.21.
> > 
> >
> I don't see how there can be slab corruption. qdisc_put_rtab only
> calls kfree if the table is found in qdisc_rtab_list, which only
> happens once. But the patch is still fine as cleanup :)

On second call to qdisc_put_rtab with tab pointing to an already
freed qdisc_rate_table:

sch_api.c:271:  if (!tab || --tab->refcnt)

Sep 16 01:52:51 axs kernel: Slab corruption: start=d8bd4f30, len=2048
Sep 16 01:52:51 axs kernel: Redzone: 0x5a2cf071/0x5a2cf071.
Sep 16 01:52:51 axs kernel: Last user: [<c036c9af>](cbq_destroy_class+0x36/0x60)
Sep 16 01:52:51 axs kernel: 410: 6a 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b 6b
                                 ^^
	I guess this is the --tab->refcnt

Sep 16 01:52:51 axs kernel: Prev obj: start=d8bd4724, len=2048
Sep 16 01:52:51 axs kernel: Redzone: 0x170fc2a5/0x170fc2a5.
Sep 16 01:52:51 axs kernel: Last user: [<c0364594>](qdisc_get_rtab+0x77/0xcd)
Sep 16 01:52:51 axs kernel: 000: 04 00 00 00 00 00 40 00 20 bc be 00 05 00 00 00
Sep 16 01:52:51 axs kernel: 010: 05 00 00 00 05 00 00 00 05 00 00 00 05 00 00 00
Sep 16 01:52:51 axs kernel: Next obj: start=d8bd573c, len=2048
Sep 16 01:52:51 axs kernel: Redzone: 0x170fc2a5/0x170fc2a5.
Sep 16 01:52:51 axs kernel: Last user: [<c03484ce>](alloc_skb+0x48/0xe1)
Sep 16 01:52:51 axs kernel: 000: 6c 04 00 00 28 00 05 06 d5 d5 48 41 00 00 00 00
Sep 16 01:52:51 axs kernel: 010: 00 00 00 00 04 00 00 00 12 00 10 00 00 00 10 00

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

* Re: [PATCH 2.6 NET] Fixes slab corruption in cbq_destroy
  2004-09-16 14:09   ` Thomas Graf
@ 2004-09-16 14:58     ` Patrick McHardy
  2004-09-16 20:33       ` Thomas Graf
  0 siblings, 1 reply; 6+ messages in thread
From: Patrick McHardy @ 2004-09-16 14:58 UTC (permalink / raw)
  To: Thomas Graf; +Cc: David S. Miller, Alexey Kuznetsov, netdev

Thomas Graf wrote:

>* Patrick McHardy <4149998C.6060501@trash.net> 2004-09-16 15:47
>  
>
>>I don't see how there can be slab corruption. qdisc_put_rtab only
>>calls kfree if the table is found in qdisc_rtab_list, which only
>>happens once. But the patch is still fine as cleanup :)
>>    
>>
>
>On second call to qdisc_put_rtab with tab pointing to an already
>freed qdisc_rate_table:
>
>sch_api.c:271:  if (!tab || --tab->refcnt)
>  
>
You're right, no double free but accessing and modifying of freed memory.

Regards
Patrick

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

* Re: [PATCH 2.6 NET] Fixes slab corruption in cbq_destroy
  2004-09-16 13:28 [PATCH 2.6 NET] Fixes slab corruption in cbq_destroy Thomas Graf
  2004-09-16 13:47 ` Patrick McHardy
@ 2004-09-16 20:29 ` David S. Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David S. Miller @ 2004-09-16 20:29 UTC (permalink / raw)
  To: Thomas Graf; +Cc: kaber, kuznet, netdev

On Thu, 16 Sep 2004 15:28:56 +0200
Thomas Graf <tgraf@suug.ch> wrote:

> Fixes slab corruption in cbq_destroy. cbq_destroy_filters and
> qdisc_put_rtab(q->link.R_tab) are already called in cbq_destroy_class.
> The latter lead to a slab corruption due to repeated freeing of
> q->link.R_tab because q->link is part of q->classes. Problem introduced
> in 1.21.

Good catch, applied.

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

* Re: [PATCH 2.6 NET] Fixes slab corruption in cbq_destroy
  2004-09-16 14:58     ` Patrick McHardy
@ 2004-09-16 20:33       ` Thomas Graf
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Graf @ 2004-09-16 20:33 UTC (permalink / raw)
  To: Patrick McHardy; +Cc: David S. Miller, Alexey Kuznetsov, netdev

* Patrick McHardy <4149AA12.10306@trash.net> 2004-09-16 16:58
> Thomas Graf wrote:
> 
> >* Patrick McHardy <4149998C.6060501@trash.net> 2004-09-16 15:47
> > 
> >
> >>I don't see how there can be slab corruption. qdisc_put_rtab only
> >>calls kfree if the table is found in qdisc_rtab_list, which only
> >>happens once. But the patch is still fine as cleanup :)
> >>   
> >>
> >
> >On second call to qdisc_put_rtab with tab pointing to an already
> >freed qdisc_rate_table:
> >
> >sch_api.c:271:  if (!tab || --tab->refcnt)
> > 
> >
> You're right, no double free but accessing and modifying of freed memory.

My patch description was misleading should have been something like
this:

Fixes slab corruption in cbq_destroy. cbq_destroy_filters and
qdisc_put_rtab(q->link.R_tab) are already called in cbq_destroy_class.
The latter lead to a slab corruption due to use of q->link.R_tab after
being freed by previous call to qdisc_put_rtab. Problem introduced
in 1.21.

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

end of thread, other threads:[~2004-09-16 20:33 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-16 13:28 [PATCH 2.6 NET] Fixes slab corruption in cbq_destroy Thomas Graf
2004-09-16 13:47 ` Patrick McHardy
2004-09-16 14:09   ` Thomas Graf
2004-09-16 14:58     ` Patrick McHardy
2004-09-16 20:33       ` Thomas Graf
2004-09-16 20:29 ` David S. 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).