diff options
author | Ignacy Gawędzki <ignacy.gawedzki@green-communications.fr> | 2015-02-03 13:05:18 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-02-04 23:26:12 -0500 |
commit | b057df24a7536cce6c372efe9d0e3d1558afedf4 (patch) | |
tree | 4c062e5a5eb0c470ff686b741d85814ba66a593a | |
parent | 3725a269815ba6dbb415feddc47da5af7d1fac58 (diff) |
cls_api.c: Fix dumping of non-existing actions' stats.
In tcf_exts_dump_stats(), ensure that exts->actions is not empty before
accessing the first element of that list and calling tcf_action_copy_stats()
on it. This fixes some random segvs when adding filters of type "basic" with
no particular action.
This also fixes the dumping of those "no-action" filters, which more often
than not made calls to tcf_action_copy_stats() fail and consequently netlink
attributes added by the caller to be removed by a call to nla_nest_cancel().
Fixes: 33be62715991 ("net_sched: act: use standard struct list_head")
Signed-off-by: Ignacy Gawędzki <ignacy.gawedzki@green-communications.fr>
Acked-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/sched/cls_api.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c index aad6a679fb13..baef987fe2c0 100644 --- a/net/sched/cls_api.c +++ b/net/sched/cls_api.c | |||
@@ -556,8 +556,9 @@ void tcf_exts_change(struct tcf_proto *tp, struct tcf_exts *dst, | |||
556 | } | 556 | } |
557 | EXPORT_SYMBOL(tcf_exts_change); | 557 | EXPORT_SYMBOL(tcf_exts_change); |
558 | 558 | ||
559 | #define tcf_exts_first_act(ext) \ | 559 | #define tcf_exts_first_act(ext) \ |
560 | list_first_entry(&(exts)->actions, struct tc_action, list) | 560 | list_first_entry_or_null(&(exts)->actions, \ |
561 | struct tc_action, list) | ||
561 | 562 | ||
562 | int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts) | 563 | int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts) |
563 | { | 564 | { |
@@ -603,7 +604,7 @@ int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts) | |||
603 | { | 604 | { |
604 | #ifdef CONFIG_NET_CLS_ACT | 605 | #ifdef CONFIG_NET_CLS_ACT |
605 | struct tc_action *a = tcf_exts_first_act(exts); | 606 | struct tc_action *a = tcf_exts_first_act(exts); |
606 | if (tcf_action_copy_stats(skb, a, 1) < 0) | 607 | if (a != NULL && tcf_action_copy_stats(skb, a, 1) < 0) |
607 | return -1; | 608 | return -1; |
608 | #endif | 609 | #endif |
609 | return 0; | 610 | return 0; |