freebsd-dev/cddl/contrib/opensolaris/lib
Toomas Soome a14844e0d6 MFOpenZFS: Add basic zfs ioc input nvpair validation
We want newer versions of libzfs_core to run against an existing
zfs kernel module (i.e. a deferred reboot or module reload after
an update).

Programmatically document, via a zfs_ioc_key_t, the valid arguments
for the ioc commands that rely on nvpair input arguments (i.e. non
legacy commands from libzfs_core). Automatically verify the expected
pairs before dispatching a command.

This initial phase focuses on the non-legacy ioctls. A follow-on
change can address the legacy ioctl input from the zfs_cmd_t.

The zfs_ioc_key_t for zfs_keys_channel_program looks like:

static const zfs_ioc_key_t zfs_keys_channel_program[] = {
       {"program",     DATA_TYPE_STRING,               0},
       {"arg",         DATA_TYPE_UNKNOWN,              0},
       {"sync",        DATA_TYPE_BOOLEAN_VALUE,        ZK_OPTIONAL},
       {"instrlimit",  DATA_TYPE_UINT64,               ZK_OPTIONAL},
       {"memlimit",    DATA_TYPE_UINT64,               ZK_OPTIONAL},
};

Introduce four input errors to identify specific input failures
(in addition to generic argument value errors like EINVAL, ERANGE,
EBADF, and E2BIG).

ZFS_ERR_IOC_CMD_UNAVAIL the ioctl number is not supported by kernel
ZFS_ERR_IOC_ARG_UNAVAIL an input argument is not supported by kernel
ZFS_ERR_IOC_ARG_REQUIRED a required input argument is missing
ZFS_ERR_IOC_ARG_BADTYPE an input argument has an invalid type

Reviewed by:	allanjude
Obtained from:	OpenZFS
Sponsored by:	Netflix, Klara Inc.
Differential Revision:	https://reviews.freebsd.org/D25393
2020-06-23 06:42:39 +00:00
..
libcmdutils MFV r325013,r325034: 640 number_to_scaled_string is duplicated in several commands 2017-10-27 12:37:22 +00:00
libctf/common Reference stdint.h types in ctf.5. 2019-07-17 16:31:50 +00:00
libdtrace Restore the binary compatibility for link_map l_addr. 2020-05-21 22:24:23 +00:00
libgen/common Mechanically convert cddl sun #ifdef's to illumos 2015-01-17 14:44:59 +00:00
libnvpair MFV r337223: 2018-08-03 01:52:25 +00:00
libuutil/common cddl/contrib/opensolaris/lib/libuutil/common/uu_avl.c 2014-03-07 23:01:35 +00:00
libzfs/common MFOpenZFS: Add basic zfs ioc input nvpair validation 2020-06-23 06:42:39 +00:00
libzfs_core/common MFOpenZFS: Add basic zfs ioc input nvpair validation 2020-06-23 06:42:39 +00:00
libzpool/common vfs: add a file missed in r356337 2020-01-03 22:47:31 +00:00
pyzfs/common MFV r260154 + 260182: 2014-01-02 07:34:36 +00:00