Skip to content

Commit eca7b76

Browse files
ikozhukhovbehlendorf
authored andcommitted
OpenZFS 6314 - buffer overflow in dsl_dataset_name
Reviewed by: George Wilson <george.wilson@delphix.com> Reviewed by: Prakash Surya <prakash.surya@delphix.com> Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com> Approved by: Dan McDonald <danmcd@omniti.com> Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> OpenZFS-issue: https://www.illumos.org/issues/6314 OpenZFS-commit: openzfs/openzfs@d6160ee
1 parent 43e52ed commit eca7b76

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+298
-335
lines changed

cmd/zdb/zdb.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
#include <sys/ddt.h>
6161
#include <sys/zfeature.h>
6262
#include <zfs_comutil.h>
63-
#undef ZFS_MAXNAMELEN
6463
#include <libzfs.h>
6564

6665
#define ZDB_COMPRESS_NAME(idx) ((idx) < ZIO_COMPRESS_FUNCTIONS ? \
@@ -2005,7 +2004,7 @@ dump_dir(objset_t *os)
20052004
uint64_t refdbytes, usedobjs, scratch;
20062005
char numbuf[32];
20072006
char blkbuf[BP_SPRINTF_LEN + 20];
2008-
char osname[MAXNAMELEN];
2007+
char osname[ZFS_MAX_DATASET_NAME_LEN];
20092008
char *type = "UNKNOWN";
20102009
int verbosity = dump_opt['d'];
20112010
int print_header = 1;
@@ -3553,7 +3552,7 @@ find_zpool(char **target, nvlist_t **configp, int dirc, char **dirv)
35533552
nvlist_t *match = NULL;
35543553
char *name = NULL;
35553554
char *sepp = NULL;
3556-
char sep = 0;
3555+
char sep = '\0';
35573556
int count = 0;
35583557
importargs_t args = { 0 };
35593558

cmd/zfs/zfs_main.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ get_callback(zfs_handle_t *zhp, void *data)
14831483
char buf[ZFS_MAXPROPLEN];
14841484
char rbuf[ZFS_MAXPROPLEN];
14851485
zprop_source_t sourcetype;
1486-
char source[ZFS_MAXNAMELEN];
1486+
char source[ZFS_MAX_DATASET_NAME_LEN];
14871487
zprop_get_cbdata_t *cbp = data;
14881488
nvlist_t *user_props = zfs_get_user_props(zhp);
14891489
zprop_list_t *pl = cbp->cb_proplist;
@@ -1963,7 +1963,7 @@ typedef struct upgrade_cbdata {
19631963
uint64_t cb_version;
19641964
boolean_t cb_newer;
19651965
boolean_t cb_foundone;
1966-
char cb_lastfs[ZFS_MAXNAMELEN];
1966+
char cb_lastfs[ZFS_MAX_DATASET_NAME_LEN];
19671967
} upgrade_cbdata_t;
19681968

19691969
static int
@@ -2412,7 +2412,7 @@ userspace_cb(void *arg, const char *domain, uid_t rid, uint64_t space)
24122412
if (domain != NULL && domain[0] != '\0') {
24132413
#ifdef HAVE_IDMAP
24142414
/* SMB */
2415-
char sid[ZFS_MAXNAMELEN + 32];
2415+
char sid[MAXNAMELEN + 32];
24162416
uid_t id;
24172417
uint64_t classes;
24182418
int err;
@@ -2546,7 +2546,7 @@ print_us_node(boolean_t scripted, boolean_t parsable, int *fields, int types,
25462546
size_t *width, us_node_t *node)
25472547
{
25482548
nvlist_t *nvl = node->usn_nvl;
2549-
char valstr[ZFS_MAXNAMELEN];
2549+
char valstr[MAXNAMELEN];
25502550
boolean_t first = B_TRUE;
25512551
int cfield = 0;
25522552
int field;
@@ -3417,7 +3417,7 @@ zfs_do_rollback(int argc, char **argv)
34173417
boolean_t force = B_FALSE;
34183418
rollback_cbdata_t cb = { 0 };
34193419
zfs_handle_t *zhp, *snap;
3420-
char parentname[ZFS_MAXNAMELEN];
3420+
char parentname[ZFS_MAX_DATASET_NAME_LEN];
34213421
char *delim;
34223422

34233423
/* check options */
@@ -3818,7 +3818,7 @@ zfs_do_send(int argc, char **argv)
38183818
*/
38193819
if (strchr(argv[0], '@') == NULL ||
38203820
(fromname && strchr(fromname, '#') != NULL)) {
3821-
char frombuf[ZFS_MAXNAMELEN];
3821+
char frombuf[ZFS_MAX_DATASET_NAME_LEN];
38223822
enum lzc_send_flags lzc_flags = 0;
38233823

38243824
if (flags.replicate || flags.doall || flags.props ||
@@ -3870,7 +3870,7 @@ zfs_do_send(int argc, char **argv)
38703870
* case if they specify the origin.
38713871
*/
38723872
if (fromname && (cp = strchr(fromname, '@')) != NULL) {
3873-
char origin[ZFS_MAXNAMELEN];
3873+
char origin[ZFS_MAX_DATASET_NAME_LEN];
38743874
zprop_source_t src;
38753875

38763876
(void) zfs_prop_get(zhp, ZFS_PROP_ORIGIN,
@@ -4004,7 +4004,7 @@ zfs_do_receive(int argc, char **argv)
40044004
usage(B_FALSE);
40054005
}
40064006

4007-
char namebuf[ZFS_MAXNAMELEN];
4007+
char namebuf[ZFS_MAX_DATASET_NAME_LEN];
40084008
(void) snprintf(namebuf, sizeof (namebuf),
40094009
"%s/%%recv", argv[0]);
40104010

@@ -4860,7 +4860,7 @@ store_allow_perm(zfs_deleg_who_type_t type, boolean_t local, boolean_t descend,
48604860
{
48614861
int i;
48624862
char ld[2] = { '\0', '\0' };
4863-
char who_buf[ZFS_MAXNAMELEN+32];
4863+
char who_buf[MAXNAMELEN + 32];
48644864
char base_type = ZFS_DELEG_WHO_UNKNOWN;
48654865
char set_type = ZFS_DELEG_WHO_UNKNOWN;
48664866
nvlist_t *base_nvl = NULL;
@@ -5224,7 +5224,7 @@ static void
52245224
print_fs_perms(fs_perm_set_t *fspset)
52255225
{
52265226
fs_perm_node_t *node = NULL;
5227-
char buf[ZFS_MAXNAMELEN+32];
5227+
char buf[MAXNAMELEN + 32];
52285228
const char *dsname = buf;
52295229

52305230
for (node = uu_list_first(fspset->fsps_list); node != NULL;
@@ -5233,7 +5233,7 @@ print_fs_perms(fs_perm_set_t *fspset)
52335233
uu_avl_t *uge_avl = node->fspn_fsperm.fsp_uge_avl;
52345234
int left = 0;
52355235

5236-
(void) snprintf(buf, ZFS_MAXNAMELEN+32,
5236+
(void) snprintf(buf, sizeof (buf),
52375237
gettext("---- Permissions on %s "),
52385238
node->fspn_fsperm.fsp_name);
52395239
(void) printf("%s", dsname);
@@ -5430,7 +5430,7 @@ zfs_do_hold_rele_impl(int argc, char **argv, boolean_t holding)
54305430

54315431
for (i = 0; i < argc; ++i) {
54325432
zfs_handle_t *zhp;
5433-
char parent[ZFS_MAXNAMELEN];
5433+
char parent[ZFS_MAX_DATASET_NAME_LEN];
54345434
const char *delim;
54355435
char *path = argv[i];
54365436

@@ -5558,7 +5558,7 @@ holds_callback(zfs_handle_t *zhp, void *data)
55585558
nvlist_t *nvl = NULL;
55595559
nvpair_t *nvp = NULL;
55605560
const char *zname = zfs_get_name(zhp);
5561-
size_t znamelen = strnlen(zname, ZFS_MAXNAMELEN);
5561+
size_t znamelen = strlen(zname);
55625562

55635563
if (cbp->cb_recursive) {
55645564
const char *snapname;
@@ -5579,7 +5579,7 @@ holds_callback(zfs_handle_t *zhp, void *data)
55795579

55805580
while ((nvp = nvlist_next_nvpair(nvl, nvp)) != NULL) {
55815581
const char *tag = nvpair_name(nvp);
5582-
size_t taglen = strnlen(tag, MAXNAMELEN);
5582+
size_t taglen = strlen(tag);
55835583
if (taglen > cbp->cb_max_taglen)
55845584
cbp->cb_max_taglen = taglen;
55855585
}
@@ -6695,7 +6695,7 @@ zfs_do_diff(int argc, char **argv)
66956695
static int
66966696
zfs_do_bookmark(int argc, char **argv)
66976697
{
6698-
char snapname[ZFS_MAXNAMELEN];
6698+
char snapname[ZFS_MAX_DATASET_NAME_LEN];
66996699
zfs_handle_t *zhp;
67006700
nvlist_t *nvl;
67016701
int ret = 0;

cmd/zhack/zhack.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#include <sys/zio_compress.h>
4949
#include <sys/zfeature.h>
5050
#include <sys/dmu_tx.h>
51-
#undef ZFS_MAXNAMELEN
5251
#include <libzfs.h>
5352

5453
extern boolean_t zfeature_checks_disable;

0 commit comments

Comments
 (0)