From: "Ignacy Gawędzki" <ignacy.gawedzki@green-communications.fr>
To: netdev@vger.kernel.org
Subject: [PATCH net v2] cls_api.c: Fix dumping of non-existing actions' stats.
Date: Tue, 3 Feb 2015 19:05:18 +0100 [thread overview]
Message-ID: <20150203180518.GA3806@zenon.in.qult.net> (raw)
In-Reply-To: <CAHA+R7Pq6aUyCzc2HE+b4RU0RfYnM_cLPfRcV3jLmAZ+dFCsxw@mail.gmail.com>
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>
---
net/sched/cls_api.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index aad6a67..baef987 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,
}
EXPORT_SYMBOL(tcf_exts_change);
-#define tcf_exts_first_act(ext) \
- list_first_entry(&(exts)->actions, struct tc_action, list)
+#define tcf_exts_first_act(ext) \
+ list_first_entry_or_null(&(exts)->actions, \
+ struct tc_action, list)
int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts)
{
@@ -603,7 +604,7 @@ int tcf_exts_dump_stats(struct sk_buff *skb, struct tcf_exts *exts)
{
#ifdef CONFIG_NET_CLS_ACT
struct tc_action *a = tcf_exts_first_act(exts);
- if (tcf_action_copy_stats(skb, a, 1) < 0)
+ if (a != NULL && tcf_action_copy_stats(skb, a, 1) < 0)
return -1;
#endif
return 0;
--
2.1.0
next prev parent reply other threads:[~2015-02-03 18:05 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-03 14:11 RFC: Fix "tc filter show" for basic filters Ignacy Gawedzki
2015-02-03 17:32 ` [PATCH net 0/1] " Ignacy Gawędzki
2015-02-03 17:32 ` [PATCH net 1/1] cls_api.c: Fix dumping of non-existing actions' stats Ignacy Gawędzki
2015-02-03 17:39 ` Cong Wang
2015-02-03 17:51 ` Eric Dumazet
2015-02-03 18:05 ` Ignacy Gawędzki [this message]
2015-02-03 18:10 ` [PATCH net v2] " Cong Wang
2015-02-05 4:26 ` [PATCH net 1/1] " David Miller
2015-02-25 0:20 ` Cong Wang
2015-02-25 2:15 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150203180518.GA3806@zenon.in.qult.net \
--to=ignacy.gawedzki@green-communications.fr \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox