<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/net/sched/act_api.c, branch linux-5.1.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.1.y</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-5.1.y'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2019-06-04T05:59:42Z</updated>
<entry>
<title>net: sched: don't use tc_action-&gt;order during action dump</title>
<updated>2019-06-04T05:59:42Z</updated>
<author>
<name>Vlad Buslov</name>
<email>vladbu@mellanox.com</email>
</author>
<published>2019-05-23T06:32:31Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=bfcfd6a494620976966ef13f400b76abbea7a0dd'/>
<id>urn:sha1:bfcfd6a494620976966ef13f400b76abbea7a0dd</id>
<content type='text'>
[ Upstream commit 4097e9d250fb17958c1d9b94538386edd3f20144 ]

Function tcf_action_dump() relies on tc_action-&gt;order field when starting
nested nla to send action data to userspace. This approach breaks in
several cases:

- When multiple filters point to same shared action, tc_action-&gt;order field
  is overwritten each time it is attached to filter. This causes filter
  dump to output action with incorrect attribute for all filters that have
  the action in different position (different order) from the last set
  tc_action-&gt;order value.

- When action data is displayed using tc action API (RTM_GETACTION), action
  order is overwritten by tca_action_gd() according to its position in
  resulting array of nl attributes, which will break filter dump for all
  filters attached to that shared action that expect it to have different
  order value.

Don't rely on tc_action-&gt;order when dumping actions. Set nla according to
action position in resulting array of actions instead.

Signed-off-by: Vlad Buslov &lt;vladbu@mellanox.com&gt;
Acked-by: Jamal Hadi Salim &lt;jhs@mojatatu.com&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<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://universe.0xinfinity.dev/distro/kernel/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://universe.0xinfinity.dev/distro/kernel/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://universe.0xinfinity.dev/distro/kernel/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://universe.0xinfinity.dev/distro/kernel/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: Add extack to nlmsg_parse</title>
<updated>2018-10-08T17:39:04Z</updated>
<author>
<name>David Ahern</name>
<email>dsahern@gmail.com</email>
</author>
<published>2018-10-08T03:16:24Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=dac9c9790e542777079999900594fd069ba10489'/>
<id>urn:sha1:dac9c9790e542777079999900594fd069ba10489</id>
<content type='text'>
Make sure extack is passed to nlmsg_parse where easy to do so.
Most of these are dump handlers and leveraging the extack in
the netlink_callback.

Signed-off-by: David Ahern &lt;dsahern@gmail.com&gt;
Acked-by: Christian Brauner &lt;christian@brauner.io&gt;
Signed-off-by: David S. Miller &lt;davem@davemloft.net&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://universe.0xinfinity.dev/distro/kernel/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://universe.0xinfinity.dev/distro/kernel/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>net_sched: change tcf_del_walker() to take idrinfo-&gt;lock</title>
<updated>2018-09-21T15:55:05Z</updated>
<author>
<name>Vlad Buslov</name>
<email>vladbu@mellanox.com</email>
</author>
<published>2018-09-19T23:37:29Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=ec3ed293e76656c1fb5388249e1e61c7d274abfc'/>
<id>urn:sha1:ec3ed293e76656c1fb5388249e1e61c7d274abfc</id>
<content type='text'>
Action API was changed to work with actions and action_idr in concurrency
safe manner, however tcf_del_walker() still uses actions without taking a
reference or idrinfo-&gt;lock first, and deletes them directly, disregarding
possible concurrent delete.

Change tcf_del_walker() to take idrinfo-&gt;lock while iterating over actions
and use new tcf_idr_release_unsafe() to release them while holding the
lock.

And the blocking function fl_hw_destroy_tmplt() could be called when we
put a filter chain, so defer it to a work queue.

Signed-off-by: Vlad Buslov &lt;vladbu@mellanox.com&gt;
[xiyou.wangcong@gmail.com: heavily modify the code and changelog]
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>Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net</title>
<updated>2018-09-05T04:33:03Z</updated>
<author>
<name>David S. Miller</name>
<email>davem@davemloft.net</email>
</author>
<published>2018-09-05T04:33:03Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=36302685f59345959de96d0d70a5ad20a3a3451b'/>
<id>urn:sha1:36302685f59345959de96d0d70a5ad20a3a3451b</id>
<content type='text'>
</content>
</entry>
</feed>
