netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [NET_SCHED]: cls_basic: fix NULL pointer dereference
@ 2007-03-20 17:15 Patrick McHardy
  2007-03-25  5:14 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick McHardy @ 2007-03-20 17:15 UTC (permalink / raw)
  To: David S. Miller; +Cc: Linux Netdev List, jamal

[-- Attachment #1: Type: text/plain, Size: 124 bytes --]

These two patches fix the cls_basic crash reported by Chris
Madden and the ingress locking problem.

Please apply, thanks.


[-- Attachment #2: 01.diff --]
[-- Type: text/x-diff, Size: 1515 bytes --]

[NET_SCHED]: cls_basic: fix NULL pointer dereference

cls_basic doesn't allocate tp->root before it is linked into the
active classifier list, resulting in a NULL pointer dereference
when packets hit the classifier before its ->change function is
called.

Reported by Chris Madden <chris@reflexsecurity.com>

Signed-off-by: Patrick McHardy <kaber@trash.net>

---
commit f1b9a0694552e18e7a43c292d21abe3b51dfcae2
tree f5ae39c1746fdc1ffbee6c1d90d035ee48ca4904
parent 0a14fe6e5efd0af0f9c6c01e0433445d615d0110
author Patrick McHardy <kaber@trash.net> Tue, 20 Mar 2007 16:08:54 +0100
committer Patrick McHardy <kaber@trash.net> Tue, 20 Mar 2007 16:08:54 +0100

 net/sched/cls_basic.c |   16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/net/sched/cls_basic.c b/net/sched/cls_basic.c
index fad08e5..70fe36e 100644
--- a/net/sched/cls_basic.c
+++ b/net/sched/cls_basic.c
@@ -81,6 +81,13 @@ static void basic_put(struct tcf_proto *
 
 static int basic_init(struct tcf_proto *tp)
 {
+	struct basic_head *head;
+
+	head = kzalloc(sizeof(*head), GFP_KERNEL);
+	if (head == NULL)
+		return -ENOBUFS;
+	INIT_LIST_HEAD(&head->flist);
+	tp->root = head;
 	return 0;
 }
 
@@ -176,15 +183,6 @@ static int basic_change(struct tcf_proto
 	}
 
 	err = -ENOBUFS;
-	if (head == NULL) {
-		head = kzalloc(sizeof(*head), GFP_KERNEL);
-		if (head == NULL)
-			goto errout;
-
-		INIT_LIST_HEAD(&head->flist);
-		tp->root = head;
-	}
-
 	f = kzalloc(sizeof(*f), GFP_KERNEL);
 	if (f == NULL)
 		goto errout;

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

* Re: [NET_SCHED]: cls_basic: fix NULL pointer dereference
  2007-03-20 17:15 [NET_SCHED]: cls_basic: fix NULL pointer dereference Patrick McHardy
@ 2007-03-25  5:14 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2007-03-25  5:14 UTC (permalink / raw)
  To: kaber; +Cc: netdev, hadi

From: Patrick McHardy <kaber@trash.net>
Date: Tue, 20 Mar 2007 18:15:00 +0100

> These two patches fix the cls_basic crash reported by Chris
> Madden and the ingress locking problem.
> 
> Please apply, thanks.

Applied, I'll push to -stable, thanks!

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

end of thread, other threads:[~2007-03-25  5:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-03-20 17:15 [NET_SCHED]: cls_basic: fix NULL pointer dereference Patrick McHardy
2007-03-25  5:14 ` 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).