summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordelphij <delphij@FreeBSD.org>2010-11-05 22:18:09 +0000
committerdelphij <delphij@FreeBSD.org>2010-11-05 22:18:09 +0000
commit070520ecc1bf32802f718d73dab306102fd0f0b9 (patch)
treec574fa491752c9b21107af56b0b020d618b9ef99
parent9b70c12cad6c8360756139b7b157ba9a9f1f7682 (diff)
downloadFreeBSD-src-070520ecc1bf32802f718d73dab306102fd0f0b9.zip
FreeBSD-src-070520ecc1bf32802f718d73dab306102fd0f0b9.tar.gz
Validate whether the zfs_cmd_t submitted from userland is not smaller than
what we have. Without the check the kernel could accessing memory that does not belong to the request struct. Note that we do not test if the struct equals in size at this time, which may faciliate forward compatibility with newer binaries. Reviewed by: pjd at MeetBSD CA '2010 MFC after: 1 week
-rw-r--r--sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
index 430a1b9..9a68adf 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_ioctl.c
@@ -3627,6 +3627,14 @@ zfsdev_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag,
uint_t vec;
int error;
+ /*
+ * Check if we have sufficient kernel memory allocated
+ * for the zfs_cmd_t request. Bail out if not so we
+ * will not access undefined memory region.
+ */
+ if (IOCPARM_LEN(cmd) < sizeof(zfs_cmd_t))
+ return (EINVAL);
+
vec = ZFS_IOC(cmd);
if (vec >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0]))
OpenPOWER on IntegriCloud