Skip to content

Commit

Permalink
[TC]: oops in em_meta
Browse files Browse the repository at this point in the history
If userspace passes a unknown match index into em_meta, then
em_meta_change will return an error and the data for the match will
not be set. This then causes an null pointer dereference when the
cleanup is done in the error path via tcf_em_tree_destroy. Since the
tree structure comes kzalloc, it is initialized to NULL.

Discovered when testing a new version of tc command against an
accidental older kernel.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Stephen Hemminger authored and David S. Miller committed Feb 8, 2008
1 parent 4e881a2 commit 04f217a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/sched/em_meta.c
Original file line number Diff line number Diff line change
Expand Up @@ -735,11 +735,13 @@ static int em_meta_match(struct sk_buff *skb, struct tcf_ematch *m,

static inline void meta_delete(struct meta_match *meta)
{
struct meta_type_ops *ops = meta_type_ops(&meta->lvalue);
if (meta) {
struct meta_type_ops *ops = meta_type_ops(&meta->lvalue);

if (ops && ops->destroy) {
ops->destroy(&meta->lvalue);
ops->destroy(&meta->rvalue);
if (ops && ops->destroy) {
ops->destroy(&meta->lvalue);
ops->destroy(&meta->rvalue);
}
}

kfree(meta);
Expand Down

0 comments on commit 04f217a

Please sign in to comment.