1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/wireless/ath/ath6kl
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
..
bmi.c ath6kl: replace GFP_ATOMIC with GFP_KERNEL in ath6kl_bmi_init() 2018-07-31 10:48:45 +03:00
bmi.h ath6kl: Fix ath6kl_bmi_read_hi32 macro 2014-07-14 15:49:23 +03:00
cfg80211.c for-4.21/block-20181221 2018-12-28 13:19:59 -08:00
cfg80211.h cfg80211: pass name_assign_type to rdev_add_virtual_intf() 2015-03-30 10:36:17 +02:00
common.h ath6kl: add ath6kl_ prefix to crypto_type 2018-12-13 09:58:52 +01:00
core.c ath6kl: add ability to set debug uart baud rate 2016-04-26 14:57:44 +03:00
core.h ath6kl: fix ath6kl_data_tx()'s return type 2018-04-27 14:34:32 +03:00
debug.c ath6kl: fix spelling mistake: "chache" -> "cache" 2018-04-19 18:56:40 +03:00
debug.h ath6kl: add __printf verification to ath6kl_dbg 2017-04-13 15:43:39 +03:00
hif-ops.h ath6kl: Add HTC pipe implementation 2012-03-26 16:36:46 +03:00
hif.c ath6kl: enable firmware crash dumps on the AR6004 2016-09-09 15:12:59 +03:00
hif.h ath6kl: fix struct hif_scatter_req list handling 2014-03-13 07:20:00 +02:00
htc-ops.h ath6kl: add htc ops 2012-03-26 16:36:46 +03:00
htc.h ath6kl: spell "distribution" correctly in a comment. 2015-07-29 11:14:04 +03:00
htc_mbox.c ath6kl: Don't print error message when recv is canceled 2015-12-08 16:50:21 +02:00
htc_pipe.c ath6kl: remove redundant variables netlen, orig_buf, orig_len, dropped and stats 2018-07-30 20:57:05 +03:00
init.c wireless: remove unneeded semicolon 2019-02-01 14:25:41 +02:00
Kconfig ath6kl: update Kconfig descriptions 2014-03-13 07:47:26 +02:00
main.c ath6kl: Mark expected switch fall-through 2018-11-05 13:22:13 +02:00
Makefile ath6kl: add tracing support and tracing points for wmi packets 2013-03-18 13:42:20 +02:00
recovery.c timer: Remove init_timer_deferrable() in favor of timer_setup() 2017-10-05 15:01:18 +02:00
sdio.c ath6kl: add support for Dell Wireless 1537 2018-06-13 14:42:54 +03:00
target.h ath6kl: remove spaces before semicolon 2014-03-13 07:47:05 +02:00
testmode.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
testmode.h cfg80211: add wdev to testmode cmd 2013-08-12 14:11:37 +02:00
trace.c ath6kl: add tracing points for sdio transfers 2013-03-18 13:42:20 +02:00
trace.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
txrx.c ath6kl: remove redundant variables netlen, orig_buf, orig_len, dropped and stats 2018-07-30 20:57:05 +03:00
usb.c ath6kl: constify usb_device_id 2017-08-11 16:59:01 +03:00
wmi.c ath6kl: return error code in ath6kl_wmi_set_roam_lrssi_cmd() 2019-01-10 15:29:24 +02:00
wmi.h ath6kl: add ath6kl_ prefix to crypto_type 2018-12-13 09:58:52 +01:00