diff options
author | Chunwei Chen <[email protected]> | 2017-08-21 13:11:11 -0700 |
---|---|---|
committer | Tony Hutter <[email protected]> | 2018-01-30 10:27:30 -0600 |
commit | 7192ec7942f233e267bf631b433eb2414dc5f332 (patch) | |
tree | 584d4ea325f25168bc1fbe9ef55be6b964efb397 | |
parent | 06acbbc429bfe7197e5fc3a49acfeef5c37b64c8 (diff) |
Fix zfs_ioc_pool_sync should not use fnvlist
Use fnvlist on user input would allow user to easily panic zfs.
Reviewed-by: Brian Behlendorf <[email protected]>
Reviewed-by: Giuseppe Di Natale <[email protected]>
Reviewed-by: Alek Pinchuk <[email protected]>
Signed-off-by: Chunwei Chen <[email protected]>
Closes #6529
-rw-r--r-- | module/zfs/zfs_ioctl.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index d195eded7..f4f509a7e 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -5901,20 +5901,26 @@ static int zfs_ioc_pool_sync(const char *pool, nvlist_t *innvl, nvlist_t *onvl) { int err; - boolean_t force; + boolean_t force = B_FALSE; spa_t *spa; if ((err = spa_open(pool, &spa, FTAG)) != 0) return (err); - force = fnvlist_lookup_boolean_value(innvl, "force"); + if (innvl) { + if (nvlist_lookup_boolean_value(innvl, "force", &force) != 0) { + err = SET_ERROR(EINVAL); + goto out; + } + } + if (force) { spa_config_enter(spa, SCL_CONFIG, FTAG, RW_WRITER); vdev_config_dirty(spa->spa_root_vdev); spa_config_exit(spa, SCL_CONFIG, FTAG); } txg_wait_synced(spa_get_dsl(spa), 0); - +out: spa_close(spa, FTAG); return (err); |