2019-06-04 10:11:33 +02:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-20 15:00:09 +01:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
net/sched: prepare TC actions to properly validate the control action
- 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 \
> ip_proto tcp action drop
# tc chain add dev dd0 chain 43 ingress protocol ip flower \
> ip_proto udp action drop
# tc filter add dev dd0 ingress matchall \
> action gact goto chain 42 index 66
# tc filter replace dev dd0 ingress matchall \
> action gact goto chain 43 index 66
# echo scan >/sys/kernel/debug/kmemleak
<...>
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:
[<000000009b63f92d>] tc_ctl_chain+0x3d2/0x4c0
[<00000000683a8d72>] rtnetlink_rcv_msg+0x263/0x2d0
[<00000000ddd88f8e>] netlink_rcv_skb+0x4a/0x110
[<000000006126a348>] netlink_unicast+0x1a0/0x250
[<00000000b3340877>] netlink_sendmsg+0x2c1/0x3c0
[<00000000a25a2171>] sock_sendmsg+0x36/0x40
[<00000000f19ee1ec>] ___sys_sendmsg+0x280/0x2f0
[<00000000d0422042>] __sys_sendmsg+0x5e/0xa0
[<000000007a6c61f9>] do_syscall_64+0x5b/0x180
[<00000000ccd07542>] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[<0000000013eaa334>] 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 <dcaratti@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-03-20 14:59:59 +01:00
|
|
|
|
2018-07-05 17:24:25 +03:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-01 13:02:51 +00:00
|
|
|
|
2019-03-20 15:00:09 +01:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-05 17:24:32 +03:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
netlink: make validation more configurable for future strictness
We currently have two levels of strict validation:
1) liberal (default)
- undefined (type >= max) & NLA_UNSPEC attributes accepted
- attribute length >= expected accepted
- garbage at end of message accepted
2) strict (opt-in)
- NLA_UNSPEC attributes accepted
- attribute length >= expected accepted
Split out parsing strictness into four different options:
* TRAILING - check that there's no trailing data after parsing
attributes (in message or nested)
* MAXTYPE - reject attrs > max known type
* UNSPEC - reject attributes with NLA_UNSPEC policy entries
* STRICT_ATTRS - strictly validate attribute size
The default for future things should be *everything*.
The current *_strict() is a combination of TRAILING and MAXTYPE,
and is renamed to _deprecated_strict().
The current regular parsing has none of this, and is renamed to
*_parse_deprecated().
Additionally it allows us to selectively set one of the new flags
even on old policies. Notably, the UNSPEC flag could be useful in
this case, since it can be arranged (by filling in the policy) to
not be an incompatible userspace ABI change, but would then going
forward prevent forgetting attribute entries. Similar can apply
to the POLICY flag.
We end up with the following renames:
* nla_parse -> nla_parse_deprecated
* nla_parse_strict -> nla_parse_deprecated_strict
* nlmsg_parse -> nlmsg_parse_deprecated
* nlmsg_parse_strict -> nlmsg_parse_deprecated_strict
* nla_parse_nested -> nla_parse_nested_deprecated
* nla_validate_nested -> nla_validate_nested_deprecated
Using spatch, of course:
@@
expression TB, MAX, HEAD, LEN, POL, EXT;
@@
-nla_parse(TB, MAX, HEAD, LEN, POL, EXT)
+nla_parse_deprecated(TB, MAX, HEAD, LEN, POL, EXT)
@@
expression NLH, HDRLEN, TB, MAX, POL, EXT;
@@
-nlmsg_parse(NLH, HDRLEN, TB, MAX, POL, EXT)
+nlmsg_parse_deprecated(NLH, HDRLEN, TB, MAX, POL, EXT)
@@
expression NLH, HDRLEN, TB, MAX, POL, EXT;
@@
-nlmsg_parse_strict(NLH, HDRLEN, TB, MAX, POL, EXT)
+nlmsg_parse_deprecated_strict(NLH, HDRLEN, TB, MAX, POL, EXT)
@@
expression TB, MAX, NLA, POL, EXT;
@@
-nla_parse_nested(TB, MAX, NLA, POL, EXT)
+nla_parse_nested_deprecated(TB, MAX, NLA, POL, EXT)
@@
expression START, MAX, POL, EXT;
@@
-nla_validate_nested(START, MAX, POL, EXT)
+nla_validate_nested_deprecated(START, MAX, POL, EXT)
@@
expression NLH, HDRLEN, MAX, POL, EXT;
@@
-nlmsg_validate(NLH, HDRLEN, MAX, POL, EXT)
+nlmsg_validate_deprecated(NLH, HDRLEN, MAX, POL, EXT)
For this patch, don't actually add the strict, non-renamed versions
yet so that it breaks compile if I get it wrong.
Also, while at it, make nla_validate and nla_parse go down to a
common __nla_validate_parse() function to avoid code duplication.
Ultimately, this allows us to have very strict validation for every
new caller of nla_parse()/nlmsg_parse() etc as re-introduced in the
next patch, while existing things will continue to work as is.
In effect then, this adds fully strict validation for any new command.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-04-26 14:07:28 +02:00
|
|
|
|
|
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-01 13:02:51 +00:00
|
|
|
|
|
|
|
|
|
2018-07-05 17:24:32 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-08-01 13:02:51 +00:00
|
|
|
|
2018-09-14 12:03:18 +02:00
|
|
|
|
2018-07-05 17:24:32 +03:00
|
|
|
|
2019-08-01 13:02:51 +00:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
2018-07-05 17:24:32 +03:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
2018-07-05 17:24:30 +03:00
|
|
|
|
2017-08-30 02:31:59 -04:00
|
|
|
|
2018-07-05 17:24:30 +03:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
2019-03-20 15:00:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
2019-04-04 12:31:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-14 21:46:16 +03:00
|
|
|
|
|
|
|
|
|
2017-01-31 11:33:53 +02:00
|
|
|
|
2019-03-20 15:00:09 +01:00
|
|
|
|
|
|
|
|
|
2017-01-31 11:33:53 +02:00
|
|
|
|
2018-08-14 21:46:16 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-03-20 15:00:09 +01:00
|
|
|
|
2019-04-04 12:31:35 +02:00
|
|
|
|
2018-08-14 21:46:16 +03:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-14 21:46:16 +03:00
|
|
|
|
2019-03-20 15:00:09 +01:00
|
|
|
|
|
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
2017-08-30 02:31:59 -04:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
2019-03-20 15:00:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
2017-12-05 12:53:07 -08:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
2017-11-29 16:07:51 -08:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
2018-08-10 20:51:47 +03:00
|
|
|
|
|
|
|
|
|
2017-11-29 16:07:51 -08:00
|
|
|
|
2018-03-16 00:00:56 +01:00
|
|
|
|
|
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-30 14:30:43 +02:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-05 17:24:24 +03:00
|
|
|
|
|
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-14 21:46:16 +03:00
|
|
|
|
2018-08-10 20:51:47 +03:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-14 21:46:16 +03:00
|
|
|
|
2018-08-10 20:51:47 +03:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-08-14 21:46:16 +03:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-15 10:54:58 -05:00
|
|
|
|
|
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-02-15 10:54:59 -05:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
2018-08-29 10:15:35 -07:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-08-30 02:31:59 -04:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-02-10 14:25:00 +02:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-11-06 13:47:18 -08:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
2017-12-11 15:35:03 -08:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
2017-12-11 15:35:03 -08:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-12-11 15:35:03 -08:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-10-30 11:41:36 +02:00
|
|
|
|
2017-01-23 11:07:09 +01:00
|
|
|
|
|
|
|
|
|