From fc581e05072c21d82729091ebe34248fd0777460 Mon Sep 17 00:00:00 2001 From: Josef 'Jeff' Sipek Date: Sat, 9 Jan 2016 18:37:15 +0100 Subject: [PATCH] Illumos 5515 - dataset user hold doesn't reject empty tags 5515 dataset user hold doesn't reject empty tags Reviewed by: Matthew Ahrens Reviewed by: Yuri Pankov Reviewed by: Saso Kiselkov Approved by: Matthew Ahrens References: https://www.illumos.org/issues/5515 https://github.com/illumos/illumos-gate/commit/752fd8d Ported-by: kernelOfTruth kerneloftruth@gmail.com Signed-off-by: Brian Behlendorf --- module/zfs/zfs_ioctl.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/module/zfs/zfs_ioctl.c b/module/zfs/zfs_ioctl.c index d026e92d69..0030799023 100644 --- a/module/zfs/zfs_ioctl.c +++ b/module/zfs/zfs_ioctl.c @@ -24,12 +24,11 @@ * Portions Copyright 2011 Martin Matuska * Portions Copyright 2012 Pawel Jakub Dawidek * Copyright (c) 2012, Joyent, Inc. All rights reserved. - * Copyright 2011 Nexenta Systems, Inc. All rights reserved. + * Copyright 2015 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2014, Joyent, Inc. All rights reserved. * Copyright (c) 2011, 2014 by Delphix. All rights reserved. * Copyright (c) 2013 by Saso Kiselkov. All rights reserved. * Copyright (c) 2013 Steven Hartland. All rights reserved. - * Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved. */ /* @@ -4900,6 +4899,7 @@ zfs_ioc_smb_acl(zfs_cmd_t *zc) static int zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist) { + nvpair_t *pair; nvlist_t *holds; int cleanup_fd = -1; int error; @@ -4909,6 +4909,19 @@ zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist) if (error != 0) return (SET_ERROR(EINVAL)); + /* make sure the user didn't pass us any invalid (empty) tags */ + for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL; + pair = nvlist_next_nvpair(holds, pair)) { + char *htag; + + error = nvpair_value_string(pair, &htag); + if (error != 0) + return (SET_ERROR(error)); + + if (strlen(htag) == 0) + return (SET_ERROR(EINVAL)); + } + if (nvlist_lookup_int32(args, "cleanup_fd", &cleanup_fd) == 0) { error = zfs_onexit_fd_hold(cleanup_fd, &minor); if (error != 0)