linux/drivers/net/wireless/intel/iwlwifi/mvm
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
..
binding.c iwlwifi: remove all occurrences of the FSF address paragraph 2018-08-31 11:38:33 +03:00
coex.c iwlwifi: mvm: simplify some return conditions 2019-02-04 12:27:18 +02:00
constants.h iwlwifi: mvm: support non-transmitting AP 2019-02-20 20:47:57 +02:00
d3.c iwlwifi: mvm: use dump worker during restart instead of sync dump 2019-03-22 12:59:41 +02:00
debugfs-vif.c iwlwifi: mvm: no need to check return value of debugfs_create functions 2019-04-03 11:20:03 +03:00
debugfs.c iwlwifi: mvm: no need to check return value of debugfs_create functions 2019-04-03 11:20:03 +03:00
debugfs.h iwlwifi: remove all occurrences of the FSF address paragraph 2018-08-31 11:38:33 +03:00
ftm-initiator.c iwlwifi: fix 64-bit division 2019-03-07 19:15:06 +02:00
ftm-responder.c iwlwifi: mvm: support FTM responder 2019-02-14 11:29:43 +02:00
fw-api.h iwlwifi: mvm: add location APIs 2019-01-29 16:10:31 +02:00
fw.c iwlwifi: fix false-positive maybe-uninitialized warning 2019-02-20 20:47:54 +02:00
led.c iwlwifi: mvm: add fall through comments where needed 2019-02-04 12:27:20 +02:00
mac80211.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
mac-ctxt.c iwlwifi: mvm: use correct GP2 register address for 22000 family 2019-04-03 11:20:04 +03:00
Makefile iwlwifi: mvm: support FTM initiator 2019-02-14 11:29:43 +02:00
mvm.h wireless-drivers-next patches for 5.2 2019-04-18 11:07:55 -07:00
nvm.c iwlwifi: mvm: save and export regdb blob from the NVM 2019-01-29 16:10:30 +02:00
offloading.c iwlwifi: remove all occurrences of the FSF address paragraph 2018-08-31 11:38:33 +03:00
ops.c iwlwifi: mvm: no need to check return value of debugfs_create functions 2019-04-03 11:20:03 +03:00
phy-ctxt.c iwlwifi: mvm: add fall through comments where needed 2019-02-04 12:27:20 +02:00
power.c iwlwifi: mvm: add support for 32kHz external clock indication 2019-02-14 11:29:47 +02:00
quota.c iwlwifi: remove all occurrences of the FSF address paragraph 2018-08-31 11:38:33 +03:00
rs-fw.c iwlwifi: mvm: set max amsdu for TLC offload 2019-03-22 12:59:41 +02:00
rs.c iwlwifi: mvm: no need to check return value of debugfs_create functions 2019-04-03 11:20:03 +03:00
rs.h iwlwifi: mvm: always init rs_fw with 20MHz bandwidth rates 2018-08-31 11:38:38 +03:00
rx.c iwlwifi: mvm: add fall through comments where needed 2019-02-04 12:27:20 +02:00
rxmq.c iwlwifi: mvm: report all NO_DATA events to mac80211 2019-03-22 12:59:39 +02:00
scan.c iwlwifi: mvm: be more forgiving if num of channels is too big 2019-03-22 12:59:40 +02:00
sf.c iwlwifi: mvm: make num_active_macs unsigned 2019-01-25 20:57:21 +02:00
sta.c wireless-drivers-next patches for 5.2 2019-04-18 11:07:55 -07:00
sta.h iwlwifi: mvm: fix TX crypto on 22560+ devices 2019-03-22 12:49:03 +02:00
tdls.c iwlwifi: mvm: use correct GP2 register address for 22000 family 2019-04-03 11:20:04 +03:00
testmode.h iwlwifi: remove all occurrences of the FSF address paragraph 2018-08-31 11:38:33 +03:00
time-event.c iwlwifi: mvm: disconnect in case of bad channel switch parameters 2019-03-22 12:59:40 +02:00
time-event.h iwlwifi: remove all occurrences of the FSF address paragraph 2018-08-31 11:38:33 +03:00
tt.c iwlwifi: remove all occurrences of the FSF address paragraph 2018-08-31 11:38:33 +03:00
tx.c iwlwifi: mvm: add some debug data to TX path 2019-02-20 20:47:59 +02:00
utils.c iwlwifi: mvm: use correct GP2 register address for 22000 family 2019-04-03 11:20:04 +03:00