From: Stephen Hemminger Date: Fri, 15 Feb 2008 09:37:49 +0000 (-0800) Subject: TC: oops in em_meta X-Git-Tag: v2.6.24.3~27 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=79a25f70244c66402c99d9b32d19204dfded85d0;p=karo-tx-linux.git TC: oops in em_meta Upstream commit: 04f217aca4d803fe72c2c54fe460d68f5233ce52 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 Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- diff --git a/net/sched/em_meta.c b/net/sched/em_meta.c index ceda8890ab0e..4d5ce774abd3 100644 --- a/net/sched/em_meta.c +++ b/net/sched/em_meta.c @@ -719,11 +719,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);