1 From foo@baz Fri 31 May 2019 03:16:57 PM PDT
2 From: Vlad Buslov <vladbu@mellanox.com>
3 Date: Thu, 23 May 2019 09:32:31 +0300
4 Subject: net: sched: don't use tc_action->order during action dump
6 From: Vlad Buslov <vladbu@mellanox.com>
8 [ Upstream commit 4097e9d250fb17958c1d9b94538386edd3f20144 ]
10 Function tcf_action_dump() relies on tc_action->order field when starting
11 nested nla to send action data to userspace. This approach breaks in
14 - When multiple filters point to same shared action, tc_action->order field
15 is overwritten each time it is attached to filter. This causes filter
16 dump to output action with incorrect attribute for all filters that have
17 the action in different position (different order) from the last set
18 tc_action->order value.
20 - When action data is displayed using tc action API (RTM_GETACTION), action
21 order is overwritten by tca_action_gd() according to its position in
22 resulting array of nl attributes, which will break filter dump for all
23 filters attached to that shared action that expect it to have different
26 Don't rely on tc_action->order when dumping actions. Set nla according to
27 action position in resulting array of actions instead.
29 Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
30 Acked-by: Jamal Hadi Salim <jhs@mojatatu.com>
31 Signed-off-by: David S. Miller <davem@davemloft.net>
32 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34 net/sched/act_api.c | 3 +--
35 1 file changed, 1 insertion(+), 2 deletions(-)
37 --- a/net/sched/act_api.c
38 +++ b/net/sched/act_api.c
39 @@ -766,7 +766,7 @@ int tcf_action_dump(struct sk_buff *skb,
41 for (i = 0; i < TCA_ACT_MAX_PRIO && actions[i]; i++) {
43 - nest = nla_nest_start(skb, a->order);
44 + nest = nla_nest_start(skb, i + 1);
47 err = tcf_action_dump_1(skb, a, bind, ref);
48 @@ -1283,7 +1283,6 @@ tca_action_gd(struct net *net, struct nl
53 attr_size += tcf_action_fill_size(act);