]> granicus.if.org Git - zfs/commitdiff
Failure of userland copy should return EFAULT
authorRichard Yao <richard.yao@clusterhq.com>
Fri, 3 Jul 2015 16:20:17 +0000 (12:20 -0400)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Tue, 14 Jul 2015 17:20:35 +0000 (10:20 -0700)
Many key internal functions pass system return codes that are safe to
return to userland. In the case of ddi_copyin(9F), an error passes -1
and the documentation states very clearly that drivers should pass
EFAULT to userland when this happens.

http://illumos.org/man/9F/ddi_copyin

This does not happen in the ZFS source code. I believe it should be
changed to pass EFAULT. I caught this when writing man pages for the
libzfs_core API.

Signed-off-by: Richard Yao <ryao@gentoo.org>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #3575

module/zfs/zfs_ioctl.c

index d997616ae4c2040ea72ccb558033ec13a67c7202..a7bfecea6f18364b61a475080ce7421758a5184f 100644 (file)
@@ -1334,7 +1334,7 @@ get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp)
        if ((error = ddi_copyin((void *)(uintptr_t)nvl, packed, size,
            iflag)) != 0) {
                vmem_free(packed, size);
-               return (error);
+               return (SET_ERROR(EFAULT));
        }
 
        if ((error = nvlist_unpack(packed, size, &list, 0)) != 0) {