Page MenuHomeFreeBSD

Openzfs #7780: Add basic zfs ioc input nvpair validation
ClosedPublic

Authored by tsoome on Jun 21 2020, 7:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Nov 12, 6:31 AM
Unknown Object (File)
Wed, Nov 6, 8:35 PM
Unknown Object (File)
Sun, Oct 27, 6:21 PM
Unknown Object (File)
Oct 14 2024, 7:10 AM
Unknown Object (File)
Oct 4 2024, 9:53 PM
Unknown Object (File)
Sep 30 2024, 3:10 AM
Unknown Object (File)
Sep 22 2024, 3:00 PM
Unknown Object (File)
Sep 18 2024, 4:25 PM
Subscribers

Details

Summary

OpenZFS commit message:

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: Matthew Ahrens <mahrens@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Don Brady <don.brady@delphix.com>
Closes #7780
Test Plan

Tested by build/install/boot

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Jun 22 2020, 1:49 PM
sys/cddl/contrib/opensolaris/uts/common/sys/fs/zfs.h
979 ↗(On Diff #73446)

We need to maintain FreeBSD's original IOCTL ordering, and just add any new additions to the end of the list.

We will take care of resyncing with upstream when -current switches to OpenZFS in a few months.

We do not want to change IOC list ordering (yet).

This revision now requires review to proceed.Jun 22 2020, 7:25 PM
This revision is now accepted and ready to land.Jun 22 2020, 8:38 PM