]> git.proxmox.com Git - mirror_zfs.git/commit - lib/libzfs/libzfs_changelist.c
zfs_handle used after being closed/freed in change_one callback
authorPavel Zakharov <pavel.zakharov@delphix.com>
Wed, 28 Aug 2019 22:02:58 +0000 (18:02 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 28 Aug 2019 22:02:58 +0000 (15:02 -0700)
commite6cebbf86e769eba7c0e7b8834985682d1b38e7e
tree25d4f29d357a2cc29af735d068a9725655b5672a
parent8d042842815f33d2e4ab919a695139b11b7ed0c2
zfs_handle used after being closed/freed in change_one callback

This is a typical case of use after free. We would call zfs_close(zhp)
which would free the handle, and then call zfs_iter_children() on that
handle later.  This change ensures that the zfs_handle is only closed
when we are ready to return.

Running `zfs inherit -r sharenfs pool` was failing with an error
code without any error messages. After some debugging I've pinpointed
the issue to be memory corruption, which would cause zfs to try to
issue an ioctl to the wrong device and receive ENOTTY.

Reviewed-by: Paul Dagnelie <pcd@delphix.com>
Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: Sebastien Roy <sebastien.roy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alek Pinchuk <apinchuk@datto.com>
Signed-off-by: Pavel Zakharov <pavel.zakharov@delphix.com>
Issue #7967
Closes #9165
lib/libzfs/libzfs_changelist.c