Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9918b511 authored by Ignacy Gawędzki's avatar Ignacy Gawędzki Committed by Greg Kroah-Hartman
Browse files

cls_api.c: Fix dumping of non-existing actions' stats.



commit b057df24a7536cce6c372efe9d0e3d1558afedf4 upstream.

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: 33be6271 ("net_sched: act: use standard struct list_head")
Signed-off-by: default avatarIgnacy Gawędzki <ignacy.gawedzki@green-communications.fr>
Acked-by: default avatarCong Wang <cwang@twopensource.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Cc: J Pommnitz <jpo234@outlook.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 98c4e5ca
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -564,7 +564,8 @@ 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)
	list_first_entry_or_null(&(exts)->actions,		\
				 struct tc_action, list)

int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts)
{
@@ -610,7 +611,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;