2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-05 10:41:32 -04:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-22 15:57:53 -08:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2016-07-25 16:09:41 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-25 16:09:42 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-25 16:09:41 -07:00
|
|
|
|
2016-07-25 16:09:42 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-06 05:18:04 -07:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2016-07-25 16:09:42 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-21 23:54:55 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2013-12-15 20:15:08 -08:00
|
|
|
|
|
|
|
|
|
2013-12-15 20:15:09 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-09 16:13:59 -08:00
|
|
|
|
2013-12-15 20:15:08 -08:00
|
|
|
|
2013-12-15 20:15:09 -08:00
|
|
|
|
2013-12-15 20:15:08 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-15 20:15:09 -08:00
|
|
|
|
|
|
|
|
|
2013-12-15 20:15:08 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-07-06 05:18:08 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-06 06:32:54 -04:00
|
|
|
|
|
|
|
|
|
2015-07-06 05:18:08 -07:00
|
|
|
|
|
|
|
|
|
2016-06-06 06:32:55 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-08 12:42:31 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-08-21 23:54:55 -07:00
|
|
|
|
2013-12-15 20:15:10 -08:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2016-07-25 16:09:41 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2016-06-05 10:41:32 -04:00
|
|
|
|
|
|
|
|
|
2006-08-21 23:54:55 -07:00
|
|
|
|
2014-02-11 17:07:32 -08:00
|
|
|
|
2016-07-25 16:09:41 -07:00
|
|
|
|
2013-01-14 05:15:39 +00:00
|
|
|
|
2016-07-25 16:09:41 -07:00
|
|
|
|
2013-01-14 05:15:39 +00:00
|
|
|
|
2016-02-22 15:57:53 -08:00
|
|
|
|
2016-07-25 16:09:41 -07:00
|
|
|
|
2016-05-13 12:55:35 +00:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
|
|
2016-02-22 15:57:53 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-06-05 10:41:32 -04:00
|
|
|
|
|
|
|
|
|
2016-02-22 15:57:53 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-04-04 10:32:48 -07:00
|
|
|
|
2016-02-22 15:57:53 -08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-07-25 16:09:41 -07:00
|
|
|
|
|
|
|
|
|
2016-02-22 15:57:53 -08:00
|
|
|
|
2016-07-25 16:09:41 -07:00
|
|
|
|
2016-06-13 13:46:28 -07:00
|
|
|
|
2016-02-22 15:57:53 -08:00
|
|
|
|
2016-07-25 16:09:41 -07:00
|
|
|
|
|
|
|
|
|
2014-02-11 17:07:31 -08:00
|
|
|
|
2016-02-22 15:57:53 -08:00
|
|
|
|
2006-08-21 23:54:55 -07:00
|
|
|
|
net: sched: fix refcount imbalance in actions
Since commit 55334a5db5cd ("net_sched: act: refuse to remove bound action
outside"), we end up with a wrong reference count for a tc action.
Test case 1:
FOO="1,6 0 0 4294967295,"
BAR="1,6 0 0 4294967294,"
tc filter add dev foo parent 1: bpf bytecode "$FOO" flowid 1:1 \
action bpf bytecode "$FOO"
tc actions show action bpf
action order 0: bpf bytecode '1,6 0 0 4294967295' default-action pipe
index 1 ref 1 bind 1
tc actions replace action bpf bytecode "$BAR" index 1
tc actions show action bpf
action order 0: bpf bytecode '1,6 0 0 4294967294' default-action pipe
index 1 ref 2 bind 1
tc actions replace action bpf bytecode "$FOO" index 1
tc actions show action bpf
action order 0: bpf bytecode '1,6 0 0 4294967295' default-action pipe
index 1 ref 3 bind 1
Test case 2:
FOO="1,6 0 0 4294967295,"
tc filter add dev foo parent 1: bpf bytecode "$FOO" flowid 1:1 action ok
tc actions show action gact
action order 0: gact action pass
random type none pass val 0
index 1 ref 1 bind 1
tc actions add action drop index 1
RTNETLINK answers: File exists [...]
tc actions show action gact
action order 0: gact action pass
random type none pass val 0
index 1 ref 2 bind 1
tc actions add action drop index 1
RTNETLINK answers: File exists [...]
tc actions show action gact
action order 0: gact action pass
random type none pass val 0
index 1 ref 3 bind 1
What happens is that in tcf_hash_check(), we check tcf_common for a given
index and increase tcfc_refcnt and conditionally tcfc_bindcnt when we've
found an existing action. Now there are the following cases:
1) We do a late binding of an action. In that case, we leave the
tcfc_refcnt/tcfc_bindcnt increased and are done with the ->init()
handler. This is correctly handeled.
2) We replace the given action, or we try to add one without replacing
and find out that the action at a specific index already exists
(thus, we go out with error in that case).
In case of 2), we have to undo the reference count increase from
tcf_hash_check() in the tcf_hash_check() function. Currently, we fail to
do so because of the 'tcfc_bindcnt > 0' check which bails out early with
an -EPERM error.
Now, while commit 55334a5db5cd prevents 'tc actions del action ...' on an
already classifier-bound action to drop the reference count (which could
then become negative, wrap around etc), this restriction only accounts for
invocations outside a specific action's ->init() handler.
One possible solution would be to add a flag thus we possibly trigger
the -EPERM ony in situations where it is indeed relevant.
After the patch, above test cases have correct reference count again.
Fixes: 55334a5db5cd ("net_sched: act: refuse to remove bound action outside")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2015-07-29 23:35:25 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-02-22 15:57:53 -08:00
|
|
|
|
2016-06-05 10:41:32 -04:00
|
|
|
|
|
|
|
|
|
2014-02-11 17:07:34 -08:00
|
|
|
|
2016-08-13 22:35:00 -07:00
|
|
|
|
|
|
|
|
|
2013-12-15 20:15:05 -08:00
|
|
|
|
2013-07-30 22:47:13 -07:00
|
|
|
|
2013-12-15 20:15:05 -08:00
|
|
|
|
2013-07-30 22:47:13 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-12-15 20:15:05 -08:00
|
|
|
|
2013-07-30 22:47:13 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-03-08 12:42:31 +02:00
|
|
|
|
2016-08-13 22:34:59 -07:00
|
|
|
|
2016-07-25 13:12:33 +03:00
|
|
|
|
2016-05-13 12:55:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-13 22:34:59 -07:00
|
|
|
|
2016-05-13 12:55:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2016-08-13 22:34:59 -07:00
|
|
|
|
2016-05-13 12:55:35 +00:00
|
|
|
|
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
|