aboutsummaryrefslogtreecommitdiffstats
path: root/module/zfs/dmu_send.c
diff options
context:
space:
mode:
authorLOLi <[email protected]>2017-10-27 01:58:38 +0200
committerBrian Behlendorf <[email protected]>2017-10-26 16:58:38 -0700
commitee45fbd89465f12b39e97173a088175d4b712b5f (patch)
tree811bc8bc132c6aef42e6d18f2a6ffde9abe20f7b /module/zfs/dmu_send.c
parent88f9c9396bcce596db56dc880260f95c49a51d67 (diff)
ZFS send fails to dump objects larger than 128PiB
When dumping objects larger than 128PiB it's possible for do_dump() to miscalculate the FREE_RECORD offset due to an integer overflow condition: this prevents the receiving end from correctly restoring the dumped object. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Fabian Grünbichler <[email protected]> Signed-off-by: loli10K <[email protected]> Closes #6760
Diffstat (limited to 'module/zfs/dmu_send.c')
-rw-r--r--module/zfs/dmu_send.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/module/zfs/dmu_send.c b/module/zfs/dmu_send.c
index cc6b97d53..1984e71b1 100644
--- a/module/zfs/dmu_send.c
+++ b/module/zfs/dmu_send.c
@@ -223,9 +223,6 @@ dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
(object == dsp->dsa_last_data_object &&
offset > dsp->dsa_last_data_offset));
- if (length != -1ULL && offset + length < offset)
- length = -1ULL;
-
/*
* If there is a pending op, but it's not PENDING_FREE, push it out,
* since free block aggregation can only be done for blocks of the
@@ -242,19 +239,22 @@ dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
if (dsp->dsa_pending_op == PENDING_FREE) {
/*
- * There should never be a PENDING_FREE if length is -1
- * (because dump_dnode is the only place where this
- * function is called with a -1, and only after flushing
- * any pending record).
+ * There should never be a PENDING_FREE if length is
+ * DMU_OBJECT_END (because dump_dnode is the only place where
+ * this function is called with a DMU_OBJECT_END, and only after
+ * flushing any pending record).
*/
- ASSERT(length != -1ULL);
+ ASSERT(length != DMU_OBJECT_END);
/*
* Check to see whether this free block can be aggregated
* with pending one.
*/
if (drrf->drr_object == object && drrf->drr_offset +
drrf->drr_length == offset) {
- drrf->drr_length += length;
+ if (offset + length < offset)
+ drrf->drr_length = DMU_OBJECT_END;
+ else
+ drrf->drr_length += length;
return (0);
} else {
/* not a continuation. Push out pending record */
@@ -268,9 +268,12 @@ dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
dsp->dsa_drr->drr_type = DRR_FREE;
drrf->drr_object = object;
drrf->drr_offset = offset;
- drrf->drr_length = length;
+ if (offset + length < offset)
+ drrf->drr_length = DMU_OBJECT_END;
+ else
+ drrf->drr_length = length;
drrf->drr_toguid = dsp->dsa_toguid;
- if (length == -1ULL) {
+ if (length == DMU_OBJECT_END) {
if (dump_record(dsp, NULL, 0) != 0)
return (SET_ERROR(EINTR));
} else {
@@ -587,7 +590,7 @@ dump_dnode(dmu_sendarg_t *dsp, const blkptr_t *bp, uint64_t object,
/* Free anything past the end of the file. */
if (dump_free(dsp, object, (dnp->dn_maxblkid + 1) *
- (dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT), -1ULL) != 0)
+ (dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT), DMU_OBJECT_END) != 0)
return (SET_ERROR(EINTR));
if (dsp->dsa_err != 0)
return (SET_ERROR(EINTR));
@@ -771,7 +774,9 @@ do_dump(dmu_sendarg_t *dsa, struct send_block_record *data)
} else if (BP_IS_HOLE(bp)) {
uint64_t span = BP_SPAN(dblkszsec, indblkshift, zb->zb_level);
uint64_t offset = zb->zb_blkid * span;
- err = dump_free(dsa, zb->zb_object, offset, span);
+ /* Don't dump free records for offsets > DMU_OBJECT_END */
+ if (zb->zb_blkid == 0 || span <= DMU_OBJECT_END / zb->zb_blkid)
+ err = dump_free(dsa, zb->zb_object, offset, span);
} else if (zb->zb_level > 0 || type == DMU_OT_OBJSET) {
return (0);
} else if (type == DMU_OT_DNODE) {
@@ -2860,7 +2865,7 @@ receive_free(struct receive_writer_arg *rwa, struct drr_free *drrf)
{
int err;
- if (drrf->drr_length != -1ULL &&
+ if (drrf->drr_length != DMU_OBJECT_END &&
drrf->drr_offset + drrf->drr_length < drrf->drr_offset)
return (SET_ERROR(EINVAL));