<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/include/net/act_api.h, branch v5.1</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v5.1</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v5.1'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2019-03-21T20:26:42Z</updated>
<entry>
<title>net/sched: let actions use RCU to access 'goto_chain'</title>
<updated>2019-03-21T20:26:42Z</updated>
<author>
<name>Davide Caratti</name>
<email>dcaratti@redhat.com</email>
</author>
<published>2019-03-20T14:00:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=ee3bbfe806cdb46b02cda63626cb50a7a7b19fc5'/>
<id>urn:sha1:ee3bbfe806cdb46b02cda63626cb50a7a7b19fc5</id>
<content type='text'>
use RCU when accessing the action chain, to avoid use after free in the
traffic path when 'goto chain' is replaced on existing TC actions (see
script below). Since the control action is read in the traffic path
without holding the action spinlock, we need to explicitly ensure that
a-&gt;goto_chain is not NULL before dereferencing (i.e it's not sufficient
to rely on the value of TC_ACT_GOTO_CHAIN bits). Not doing so caused NULL
dereferences in tcf_action_goto_chain_exec() when the following script:

 # tc chain add dev dd0 chain 42 ingress protocol ip flower \
 &gt; ip_proto udp action pass index 4
 # tc filter add dev dd0 ingress protocol ip flower \
 &gt; ip_proto udp action csum udp goto chain 42 index 66
 # tc chain del dev dd0 chain 42 ingress
 (start UDP traffic towards dd0)
 # tc action replace action csum udp pass index 66

was run repeatedly for several hours.

Suggested-by: Cong Wang &lt;xiyou.wangcong@gmail.com&gt;
Suggested-by: Vlad Buslov &lt;vladbu@mellanox.com&gt;
Signed-off-by: Davide Caratti &lt;dcaratti@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/sched: prepare TC actions to properly validate the control action</title>
<updated>2019-03-21T20:26:41Z</updated>
<author>
<name>Davide Caratti</name>
<email>dcaratti@redhat.com</email>
</author>
<published>2019-03-20T13:59:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=85d0966fa57e0ef2d30d913c98ca93674f7a03c9'/>
<id>urn:sha1:85d0966fa57e0ef2d30d913c98ca93674f7a03c9</id>
<content type='text'>
- pass a pointer to struct tcf_proto in each actions's init() handler,
  to allow validating the control action, checking whether the chain
  exists and (eventually) refcounting it.
- remove code that validates the control action after a successful call
  to the action's init() handler, and replace it with a test that forbids
  addition of actions having 'goto_chain' and NULL goto_chain pointer at
  the same time.
- add tcf_action_check_ctrlact(), that will validate the control action
  and eventually allocate the action 'goto_chain' within the init()
  handler.
- add tcf_action_set_ctrlact(), that will assign the control action and
  swap the current 'goto_chain' pointer with the new given one.

This disallows 'goto_chain' on actions that don't initialize it properly
in their init() handler, i.e. calling tcf_action_check_ctrlact() after
successful IDR reservation and then calling tcf_action_set_ctrlact()
to assign 'goto_chain' and 'tcf_action' consistently.

By doing this, the kernel does not leak anymore refcounts when a valid
'goto chain' handle is replaced in TC actions, causing kmemleak splats
like the following one:

 # tc chain add dev dd0 chain 42 ingress protocol ip flower \
 &gt; ip_proto tcp action drop
 # tc chain add dev dd0 chain 43 ingress protocol ip flower \
 &gt; ip_proto udp action drop
 # tc filter add dev dd0 ingress matchall \
 &gt; action gact goto chain 42 index 66
 # tc filter replace dev dd0 ingress matchall \
 &gt; action gact goto chain 43 index 66
 # echo scan &gt;/sys/kernel/debug/kmemleak
 &lt;...&gt;
 unreferenced object 0xffff93c0ee09f000 (size 1024):
 comm "tc", pid 2565, jiffies 4295339808 (age 65.426s)
 hex dump (first 32 bytes):
   00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   00 00 00 00 08 00 06 00 00 00 00 00 00 00 00 00  ................
 backtrace:
   [&lt;000000009b63f92d&gt;] tc_ctl_chain+0x3d2/0x4c0
   [&lt;00000000683a8d72&gt;] rtnetlink_rcv_msg+0x263/0x2d0
   [&lt;00000000ddd88f8e&gt;] netlink_rcv_skb+0x4a/0x110
   [&lt;000000006126a348&gt;] netlink_unicast+0x1a0/0x250
   [&lt;00000000b3340877&gt;] netlink_sendmsg+0x2c1/0x3c0
   [&lt;00000000a25a2171&gt;] sock_sendmsg+0x36/0x40
   [&lt;00000000f19ee1ec&gt;] ___sys_sendmsg+0x280/0x2f0
   [&lt;00000000d0422042&gt;] __sys_sendmsg+0x5e/0xa0
   [&lt;000000007a6c61f9&gt;] do_syscall_64+0x5b/0x180
   [&lt;00000000ccd07542&gt;] entry_SYSCALL_64_after_hwframe+0x44/0xa9
   [&lt;0000000013eaa334&gt;] 0xffffffffffffffff

Fixes: db50514f9a9c ("net: sched: add termination action to allow goto chain")
Fixes: 97763dc0f401 ("net_sched: reject unknown tcfa_action values")
Signed-off-by: Davide Caratti &lt;dcaratti@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net: Change TCA_ACT_* to TCA_ID_* to match that of TCA_ID_POLICE</title>
<updated>2019-02-10T17:28:43Z</updated>
<author>
<name>Eli Cohen</name>
<email>eli@mellanox.com</email>
</author>
<published>2019-02-10T12:25:00Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=eddd2cf195d6fb5e4bbc91a0fe4be55110f559ab'/>
<id>urn:sha1:eddd2cf195d6fb5e4bbc91a0fe4be55110f559ab</id>
<content type='text'>
Modify the kernel users of the TCA_ACT_* macros to use TCA_ID_*. For
example, use TCA_ID_GACT instead of TCA_ACT_GACT. This will align with
TCA_ID_POLICE and also differentiates these identifier, used in struct
tc_action_ops type field, from other macros starting with TCA_ACT_.

To make things clearer, we name the enum defining the TCA_ID_*
identifiers and also change the "type" field of struct tc_action to
id.

Signed-off-by: Eli Cohen &lt;eli@mellanox.com&gt;
Acked-by: Jiri Pirko &lt;jiri@mellanox.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/sched: Remove egdev mechanism</title>
<updated>2018-12-10T23:54:34Z</updated>
<author>
<name>Oz Shlomo</name>
<email>ozsh@mellanox.com</email>
</author>
<published>2018-11-06T07:58:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=69bd48404f251b9c45a15799fdcfc87a7ad6ab8a'/>
<id>urn:sha1:69bd48404f251b9c45a15799fdcfc87a7ad6ab8a</id>
<content type='text'>
The egdev mechanism was replaced by the TC indirect block notifications
platform.

Signed-off-by: Oz Shlomo &lt;ozsh@mellanox.com&gt;
Reviewed-by: Eli Britstein &lt;elibr@mellanox.com&gt;
Reviewed-by: Jiri Pirko &lt;jiri@mellanox.com&gt;
Cc: John Hurley &lt;john.hurley@netronome.com&gt;
Cc: Jakub Kicinski &lt;jakub.kicinski@netronome.com&gt;
Signed-off-by: Saeed Mahameed &lt;saeedm@mellanox.com&gt;
</content>
</entry>
<entry>
<title>net_sched: convert idrinfo-&gt;lock from spinlock to a mutex</title>
<updated>2018-10-05T07:36:31Z</updated>
<author>
<name>Cong Wang</name>
<email>xiyou.wangcong@gmail.com</email>
</author>
<published>2018-10-02T19:50:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=95278ddaa15cfa23e4a06ee9ed7b6ee0197c500b'/>
<id>urn:sha1:95278ddaa15cfa23e4a06ee9ed7b6ee0197c500b</id>
<content type='text'>
In commit ec3ed293e766 ("net_sched: change tcf_del_walker() to take idrinfo-&gt;lock")
we move fl_hw_destroy_tmplt() to a workqueue to avoid blocking
with the spinlock held. Unfortunately, this causes a lot of
troubles here:

1. tcf_chain_destroy() could be called right after we queue the work
   but before the work runs. This is a use-after-free.

2. The chain refcnt is already 0, we can't even just hold it again.
   We can check refcnt==1 but it is ugly.

3. The chain with refcnt 0 is still visible in its block, which means
   it could be still found and used!

4. The block has a refcnt too, we can't hold it without introducing a
   proper API either.

We can make it working but the end result is ugly. Instead of wasting
time on reviewing it, let's just convert the troubling spinlock to
a mutex, which allows us to use non-atomic allocations too.

Fixes: ec3ed293e766 ("net_sched: change tcf_del_walker() to take idrinfo-&gt;lock")
Reported-by: Ido Schimmel &lt;idosch@idosch.org&gt;
Cc: Jamal Hadi Salim &lt;jhs@mojatatu.com&gt;
Cc: Vlad Buslov &lt;vladbu@mellanox.com&gt;
Cc: Jiri Pirko &lt;jiri@mellanox.com&gt;
Signed-off-by: Cong Wang &lt;xiyou.wangcong@gmail.com&gt;
Tested-by: Ido Schimmel &lt;idosch@mellanox.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net/sched: Add hardware specific counters to TC actions</title>
<updated>2018-09-24T19:18:42Z</updated>
<author>
<name>Eelco Chaudron</name>
<email>echaudro@redhat.com</email>
</author>
<published>2018-09-21T11:14:02Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=28169abadb08333eb607621faa3a1dd7109e0d45'/>
<id>urn:sha1:28169abadb08333eb607621faa3a1dd7109e0d45</id>
<content type='text'>
Add additional counters that will store the bytes/packets processed by
hardware. These will be exported through the netlink interface for
displaying by the iproute2 tc tool

Signed-off-by: Eelco Chaudron &lt;echaudro@redhat.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>Revert "net: sched: act: add extack for lookup callback"</title>
<updated>2018-09-01T05:50:15Z</updated>
<author>
<name>Cong Wang</name>
<email>xiyou.wangcong@gmail.com</email>
</author>
<published>2018-08-29T17:15:35Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=f061b48c1787e6fece2190e27da6878f4f1796d0'/>
<id>urn:sha1:f061b48c1787e6fece2190e27da6878f4f1796d0</id>
<content type='text'>
This reverts commit 331a9295de23 ("net: sched: act: add extack for lookup callback").

This extack is never used after 6 months... In fact, it can be just
set in the caller, right after -&gt;lookup().

Cc: Alexander Aring &lt;aring@mojatatu.com&gt;
Signed-off-by: Cong Wang &lt;xiyou.wangcong@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net_sched: remove unused tcfa_capab</title>
<updated>2018-08-21T19:45:45Z</updated>
<author>
<name>Cong Wang</name>
<email>xiyou.wangcong@gmail.com</email>
</author>
<published>2018-08-19T19:22:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=a0c2e90fe131d9a7440ac05c9c31fc35dfac2fa8'/>
<id>urn:sha1:a0c2e90fe131d9a7440ac05c9c31fc35dfac2fa8</id>
<content type='text'>
Cc: Jamal Hadi Salim &lt;jhs@mojatatu.com&gt;
Signed-off-by: Cong Wang &lt;xiyou.wangcong@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net_sched: remove list_head from tc_action</title>
<updated>2018-08-21T19:45:44Z</updated>
<author>
<name>Cong Wang</name>
<email>xiyou.wangcong@gmail.com</email>
</author>
<published>2018-08-19T19:22:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=244cd96adb5f5ab39551081fb1f9009a54bb12ee'/>
<id>urn:sha1:244cd96adb5f5ab39551081fb1f9009a54bb12ee</id>
<content type='text'>
After commit 90b73b77d08e, list_head is no longer needed.
Now we just need to convert the list iteration to array
iteration for drivers.

Fixes: 90b73b77d08e ("net: sched: change action API to use array of pointers to actions")
Cc: Jiri Pirko &lt;jiri@mellanox.com&gt;
Cc: Vlad Buslov &lt;vladbu@mellanox.com&gt;
Signed-off-by: Cong Wang &lt;xiyou.wangcong@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
<entry>
<title>net_sched: remove unused tcf_idr_check()</title>
<updated>2018-08-21T19:45:44Z</updated>
<author>
<name>Cong Wang</name>
<email>xiyou.wangcong@gmail.com</email>
</author>
<published>2018-08-19T19:22:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=7d485c451fc82f8ae431cdb379521bc6d0641064'/>
<id>urn:sha1:7d485c451fc82f8ae431cdb379521bc6d0641064</id>
<content type='text'>
tcf_idr_check() is replaced by tcf_idr_check_alloc(),
and __tcf_idr_check() now can be folded into tcf_idr_search().

Fixes: 0190c1d452a9 ("net: sched: atomically check-allocate action")
Cc: Jiri Pirko &lt;jiri@mellanox.com&gt;
Cc: Vlad Buslov &lt;vladbu@mellanox.com&gt;
Signed-off-by: Cong Wang &lt;xiyou.wangcong@gmail.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
</content>
</entry>
</feed>
