]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.1/net-sched-don-t-use-tc_action-order-during-action-dump.patch
cde8e7b5ac484092897dc9c199bf244eb7627121
[thirdparty/kernel/stable-queue.git] / queue-5.1 / net-sched-don-t-use-tc_action-order-during-action-dump.patch
1 From foo@baz Fri 31 May 2019 03:16:39 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
5
6 From: Vlad Buslov <vladbu@mellanox.com>
7
8 [ Upstream commit 4097e9d250fb17958c1d9b94538386edd3f20144 ]
9
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
12 several cases:
13
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.
19
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
24 order value.
25
26 Don't rely on tc_action->order when dumping actions. Set nla according to
27 action position in resulting array of actions instead.
28
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>
33 ---
34 net/sched/act_api.c | 3 +--
35 1 file changed, 1 insertion(+), 2 deletions(-)
36
37 --- a/net/sched/act_api.c
38 +++ b/net/sched/act_api.c
39 @@ -800,7 +800,7 @@ int tcf_action_dump(struct sk_buff *skb,
40
41 for (i = 0; i < TCA_ACT_MAX_PRIO && actions[i]; i++) {
42 a = actions[i];
43 - nest = nla_nest_start(skb, a->order);
44 + nest = nla_nest_start(skb, i + 1);
45 if (nest == NULL)
46 goto nla_put_failure;
47 err = tcf_action_dump_1(skb, a, bind, ref);
48 @@ -1300,7 +1300,6 @@ tca_action_gd(struct net *net, struct nl
49 ret = PTR_ERR(act);
50 goto err;
51 }
52 - act->order = i;
53 attr_size += tcf_action_fill_size(act);
54 actions[i - 1] = act;
55 }