Skip to content

Commit

Permalink
Fix zfs_ioc_pool_sync should not use fnvlist
Browse files Browse the repository at this point in the history
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 openzfs#6529
  • Loading branch information
tuxoko authored and tonyhutter committed Jan 18, 2018
1 parent 08a7fd9 commit 5724f3b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions module/zfs/zfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5724f3b

Please sign in to comment.