linux/drivers/block
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
..
aoe aoe: add __exit annotation 2018-12-16 09:01:38 -07:00
drbd netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
mtip32xx for-5.1/block-20190302 2019-03-08 14:12:17 -08:00
paride paride/pcd: Fix potential NULL pointer dereference and mem leak 2019-04-05 09:24:34 -06:00
rsxx pci-v4.20-changes 2018-10-25 06:50:48 -07:00
xen-blkback xen/blkback: rework connect_ring() to avoid inconsistent xenstore 'ring-page-order' set by malicious blkfront 2019-02-24 10:17:56 -05:00
zram drivers/block/zram/zram_drv.c: fix idle/writeback string compare 2019-03-29 10:01:37 -07:00
amiflop.c block/amiflop: Don't log error message on invalid ioctl 2018-12-31 10:19:11 -07:00
ataflop.c ataflop: implement mq_ops->commit_rqs() hook 2018-11-29 10:12:27 -07:00
brd.c block: brd: associate with queue until adding disk 2018-11-01 19:59:51 -06:00
cryptoloop.c block: cryptoloop: Remove VLA usage of skcipher 2018-09-28 12:46:07 +08:00
floppy.c for-5.1/block-20190302 2019-03-08 14:12:17 -08:00
Kconfig drivers/block: Remove DAC960 driver 2018-10-17 09:42:30 -06:00
loop.c loop: access lo_backing_file only when the loop device is Lo_bound 2019-03-18 08:20:53 -06:00
loop.h block/loop: Use global lock for ioctl() operation. 2018-11-08 06:30:11 -07:00
Makefile drivers/block: Remove DAC960 driver 2018-10-17 09:42:30 -06:00
nbd.c netlink: make validation more configurable for future strictness 2019-04-27 17:07:21 -04:00
null_blk.h null_blk: add zoned config support information 2019-01-06 10:58:27 -07:00
null_blk_main.c null_blk: prevent crash from bad home_node value 2019-04-06 10:51:08 -06:00
null_blk_zoned.c null_blk: Add conventional zone configuration for zoned support 2018-11-07 13:41:50 -07:00
pktcdvd.c pktcdvd: remove queue_lock around blk_queue_max_hw_sectors 2018-11-16 09:16:59 -07:00
ps3disk.c ps3disk: convert to blk-mq 2018-10-15 20:07:56 -06:00
ps3vram.c block: genhd: add 'groups' argument to device_add_disk 2018-09-28 08:30:28 -06:00
rbd.c rbd: drop wait_for_latest_osdmap() 2019-03-20 16:27:40 +01:00
rbd_types.h rbd: RBD_V{1,2}_DATA_FORMAT macros 2017-02-20 12:16:15 +01:00
skd_main.c block: kill BLK_MQ_F_SG_MERGE 2019-02-15 08:40:12 -07:00
skd_s1120.h skd: Use __packed only when needed 2017-08-18 08:45:29 -06:00
sunvdc.c block: sunvdc: don't run hw queue synchronously from irq context 2019-01-03 08:21:47 -07:00
swim.c swim: convert to blk-mq 2018-10-16 09:49:18 -06:00
swim3.c block/swim3: Fix regression on PowerBook G3 2018-12-31 10:19:19 -07:00
swim_asm.S
sx8.c sx8: use a per-host tag_set 2018-11-09 08:14:14 -07:00
umem.c block: remove the lock argument to blk_alloc_queue_node 2018-11-15 12:13:35 -07:00
umem.h
virtio_blk.c virtio-blk: limit number of hw queues by nr_cpu_ids 2019-04-10 08:18:24 -06:00
xen-blkfront.c block: kill BLK_MQ_F_SG_MERGE 2019-02-15 08:40:12 -07:00
xsysace.c xsysace: Fix error handling in ace_setup 2019-04-06 10:51:12 -06:00
z2ram.c powerpc updates for 4.20 2018-10-26 14:36:21 -07:00