1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/wireless/ath/wil6210
Johannes Berg 8cb081746c 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-27 17:07:21 -04:00
..
boot_loader.h wil6210: fix random failure to bring network interface up 2018-01-25 07:32:23 +02:00
cfg80211.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
debug.c wil6210: infrastructure for multiple virtual interfaces 2018-02-27 18:50:19 +02:00
debugfs.c wil6210: support up to 20 stations in AP mode 2019-02-28 11:24:29 +02:00
ethtool.c wil6210: initialize TX and RX enhanced DMA rings 2018-07-02 17:24:19 +03:00
fw.c wil6210: support Talyn specific board file 2018-07-31 11:01:26 +03:00
fw.h wil6210: support concurrency record in FW file 2018-02-27 18:50:11 +02:00
fw_inc.c wil6210: fix min() compilation errors 2018-07-31 11:00:41 +03:00
interrupt.c wil6210: ignore HALP ICR if already handled 2019-02-28 11:24:59 +02:00
Kconfig wil6210: disable tracing config option 2018-05-12 12:26:47 +03:00
main.c wil6210: ignore HALP ICR if already handled 2019-02-28 11:24:59 +02:00
Makefile wil6210: initialize TX and RX enhanced DMA rings 2018-07-02 17:24:19 +03:00
netdev.c wil6210: refactor disconnect flow 2018-11-06 18:03:00 +02:00
p2p.c wil6210: rename p2p_wdev_mutex to vif_mutex 2018-02-27 18:50:40 +02:00
pcie_bus.c wil6210: set edma variables only for Talyn-MB devices 2018-08-28 16:48:26 +03:00
pm.c wil6210: remove set but not used variable 'start' 2018-10-01 17:08:34 +03:00
pmc.c wil6210: infrastructure for multiple virtual interfaces 2018-02-27 18:50:19 +02:00
pmc.h wil6210: Add pmc debug mechanism memory management 2015-05-04 20:55:43 +03:00
rx_reorder.c wil6210: support up to 20 stations in AP mode 2019-02-28 11:24:29 +02:00
trace.c wil6210: trace support 2013-05-22 15:08:27 -04:00
trace.h wil6210: support up to 20 stations in AP mode 2019-02-28 11:24:29 +02:00
txrx.c wil6210: accessing 802.3 addresses via utility functions 2019-02-28 11:24:39 +02:00
txrx.h wil6210: accessing 802.3 addresses via utility functions 2019-02-28 11:24:39 +02:00
txrx_edma.c wil6210: fix invalid sta statistics update 2019-02-28 11:24:50 +02:00
txrx_edma.h wil6210: increase RX rings and RX buff array size 2018-11-06 18:02:21 +02:00
wil6210.h wil6210: ignore HALP ICR if already handled 2019-02-28 11:24:59 +02:00
wil_crash_dump.c wil6210: remove crash dump collection from OTP section 2018-07-02 17:25:10 +03:00
wil_platform.c wil6210: support for platform specific crash recovery 2016-01-07 15:00:44 +02:00
wil_platform.h wil6210: add 3-MSI support 2018-07-31 11:00:33 +03:00
wmi.c wil6210: support up to 20 stations in AP mode 2019-02-28 11:24:29 +02:00
wmi.h wil6210: add FT roam support for AP and station 2018-08-28 16:49:05 +03:00