1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/wireless/ti/wlcore
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
..
acx.c wlcore: Add support for runtime PM 2018-06-27 18:44:47 +03:00
acx.h wlcore: fix unused function warning 2017-12-14 14:44:31 +02:00
boot.c wlcore: Fix config firmware loading issues 2016-09-26 18:13:45 +03:00
boot.h wlcore: create private static_data area and add operation to parse it 2012-06-05 15:58:20 +03:00
cmd.c wlcore: clean up an indentation issue 2019-02-01 14:27:13 +02:00
cmd.h cfg80211: remove enum ieee80211_band 2016-04-12 15:56:15 +02:00
conf.h wlcore: split wl12xx/wl18xx sg parameters 2015-12-11 13:10:59 +02:00
debug.h drivers/net: Convert remaining uses of pr_warning to pr_warn 2014-09-09 20:37:08 -07:00
debugfs.c wlcore: no need to check return value of debugfs_create functions 2019-02-01 14:29:50 +02:00
debugfs.h wlcore: no need to check return value of debugfs_create functions 2019-02-01 14:29:50 +02:00
event.c mac80211: Pass new RSSI level in CQM RSSI notification 2017-02-08 10:43:04 +01:00
event.h wlcore/wl18xx: fw logger over sdio 2015-12-31 10:19:47 +02:00
hw_ops.h wlcore: add dfs master restart calls 2015-01-09 15:48:01 +02:00
ini.h wlcore/wl12xx: add support for HP and SKW FEM radio manufacturers 2012-06-13 21:52:56 +03:00
init.c scripts/spelling.txt: add "intialization" pattern and fix typo instances 2017-02-27 18:43:47 -08:00
init.h wlcore: add p2p device support 2015-08-10 22:16:34 +03:00
io.c wlcore/wl12xx: Fix fw logger over sdio 2016-05-11 21:26:15 +03:00
io.h wlcore/wl12xx: Fix fw logger over sdio 2016-05-11 21:26:15 +03:00
Kconfig wlcore/wl12xx: spi: add device tree support 2016-01-29 11:10:10 +02:00
main.c wlcore: Fix memory leak in case wl12xx_fetch_firmware failure 2019-01-10 13:31:43 +02:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
ps.c wlcore: Add support for runtime PM 2018-06-27 18:44:47 +03:00
ps.h wlcore: Add support for runtime PM 2018-06-27 18:44:47 +03:00
rx.c wlcore: Set rx_status boottime_ns field on rx 2018-07-31 10:24:10 +03:00
rx.h cfg80211: remove enum ieee80211_band 2016-04-12 15:56:15 +02:00
scan.c wlcore: Enable runtime PM autosuspend support 2018-06-27 18:45:24 +03:00
scan.h wl18xx: use long intervals in sched scan 2015-08-10 22:16:21 +03:00
sdio.c wlcore: sdio: Fixup power on/off sequence 2019-01-22 18:23:49 +02:00
spi.c wlcore: add missing nvs file name info for wilink8 2017-08-24 12:51:22 +03:00
sysfs.c wlcore: Enable runtime PM autosuspend support 2018-06-27 18:45:24 +03:00
sysfs.h wlcore: move sysfs handling to a separate file 2013-06-17 11:56:59 +03:00
testmode.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
testmode.h mac80211: add vif to testmode cmd 2013-08-12 14:11:42 +02:00
tx.c wlcore: Enable runtime PM autosuspend support 2018-06-27 18:45:24 +03:00
tx.h cfg80211: remove enum ieee80211_band 2016-04-12 15:56:15 +02:00
vendor_cmd.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
vendor_cmd.h wlcore/wl18xx: handle smart config events 2014-07-15 15:59:57 -04:00
wl12xx_80211.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
wlcore.h wlcore: Add support for optional wakeirq 2018-10-05 11:33:31 +03:00
wlcore_i.h wlcore: Add support for runtime PM 2018-06-27 18:44:47 +03:00