diff options
author | Jorgen Lundman <[email protected]> | 2018-05-07 17:35:50 +0900 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2018-05-25 17:24:57 -0700 |
commit | 561ba8d1b1bb1f74c0182fb95161adfec99e27a1 (patch) | |
tree | 4b3cc266cdb9511aa1e07347394927a8ecb9aeb7 /cmd/zdb/zdb.c | |
parent | 0dc2f70c5cece6ef2474e14552111ae098d9f5b4 (diff) |
OpenZFS 9523 - Large alloc in zdb can cause trouble
16MB alloc in zdb_embedded_block() can cause cores in certain
situations (clang, gcc55).
Authored by: Jorgen Lundman <[email protected]>
Reviewed by: Igor Kozhukhov <[email protected]>
Reviewed by: Andriy Gapon <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed-by: George Melikov <[email protected]>
Approved by: Dan McDonald <[email protected]>
Ported-by: Brian Behlendorf <[email protected]>
Porting Notes:
* Replaces an equivalent fix previously made for Linux.
OpenZFS-issue: https://illumos.org/issues/9523
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/2c1964a
Closes #7561
Diffstat (limited to 'cmd/zdb/zdb.c')
-rw-r--r-- | cmd/zdb/zdb.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index a7bd64ecd..5b50c4b39 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -4834,8 +4834,6 @@ zdb_embedded_block(char *thing) char *buf; int err; - buf = umem_alloc(SPA_MAXBLOCKSIZE, UMEM_NOFAIL); - bzero(&bp, sizeof (bp)); err = sscanf(thing, "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx:" "%llx:%llx:%llx:%llx:%llx:%llx:%llx:%llx", @@ -4844,17 +4842,22 @@ zdb_embedded_block(char *thing) words + 8, words + 9, words + 10, words + 11, words + 12, words + 13, words + 14, words + 15); if (err != 16) { - (void) printf("invalid input format\n"); + (void) fprintf(stderr, "invalid input format\n"); exit(1); } ASSERT3U(BPE_GET_LSIZE(&bp), <=, SPA_MAXBLOCKSIZE); + buf = malloc(SPA_MAXBLOCKSIZE); + if (buf == NULL) { + (void) fprintf(stderr, "out of memory\n"); + exit(1); + } err = decode_embedded_bp(&bp, buf, BPE_GET_LSIZE(&bp)); if (err != 0) { - (void) printf("decode failed: %u\n", err); + (void) fprintf(stderr, "decode failed: %u\n", err); exit(1); } zdb_dump_block_raw(buf, BPE_GET_LSIZE(&bp), 0); - umem_free(buf, SPA_MAXBLOCKSIZE); + free(buf); } int |