Skip to content

Commit

Permalink
[NET_SCHED]: cls_basic: fix NULL pointer dereference
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Patrick McHardy authored and David S. Miller committed Mar 26, 2007
1 parent c93a882 commit d3fa76e
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions net/sched/cls_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,13 @@ static void basic_put(struct tcf_proto *tp, unsigned long f)

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;
}

Expand Down Expand Up @@ -176,15 +183,6 @@ static int basic_change(struct tcf_proto *tp, unsigned long base, u32 handle,
}

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;
Expand Down

0 comments on commit d3fa76e

Please sign in to comment.