Skip to content

Commit

Permalink
Avoid panic with recordsize > 128k, raw sending and no large_blocks
Browse files Browse the repository at this point in the history
The current codebase does not support raw sending buffers with block
size > 128kB when large_blocks is not active. Instead of panicking
due to a NULL pointer dereference in dmu_dump_write() print out an
error message.

Signed-off-by: George Amanakis <gamanakis@gmail.com>
  • Loading branch information
gamanakis committed Jul 27, 2021
1 parent 9776838 commit 99c0720
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/libzfs/libzfs_sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -852,6 +852,11 @@ dump_ioctl(zfs_handle_t *zhp, const char *fromsnap, uint64_t fromsnap_obj,
case EINVAL:
zfs_error_aux(hdl, "%s", strerror(errno));
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
case ENOTSUP:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"large blocks detected but large_blocks feature "
"is inactive; raw send unsupported"));
return (zfs_error(hdl, EZFS_NOTSUP, errbuf));

default:
return (zfs_standard_error(hdl, errno, errbuf));
Expand Down Expand Up @@ -2567,6 +2572,11 @@ zfs_send_one(zfs_handle_t *zhp, const char *from, int fd, sendflags_t *flags,
case EROFS:
zfs_error_aux(hdl, "%s", strerror(errno));
return (zfs_error(hdl, EZFS_BADBACKUP, errbuf));
case ENOTSUP:
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"large blocks detected but large_blocks feature "
"is inactive; raw send unsupported"));
return (zfs_error(hdl, EZFS_NOTSUP, errbuf));

default:
return (zfs_standard_error(hdl, errno, errbuf));
Expand Down
4 changes: 4 additions & 0 deletions module/zfs/dmu_send.c
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,7 @@ dmu_dump_write(dmu_send_cookie_t *dscp, dmu_object_type_t type, uint64_t object,

/* only set the compression fields if the buf is compressed or raw */
if (raw || lsize != psize) {
ASSERT(bp != NULL);
ASSERT(raw || dscp->dsc_featureflags &
DMU_BACKUP_FEATURE_COMPRESSED);
ASSERT(!BP_IS_EMBEDDED(bp));
Expand Down Expand Up @@ -1010,6 +1011,9 @@ do_dump(dmu_send_cookie_t *dscp, struct send_range *range)
if (srdp->datablksz > SPA_OLD_MAXBLOCKSIZE &&
!(dscp->dsc_featureflags &
DMU_BACKUP_FEATURE_LARGE_BLOCKS)) {
if (dscp->dsc_featureflags & DMU_BACKUP_FEATURE_RAW)
return (SET_ERROR(ENOTSUP));

while (srdp->datablksz > 0 && err == 0) {
int n = MIN(srdp->datablksz,
SPA_OLD_MAXBLOCKSIZE);
Expand Down

0 comments on commit 99c0720

Please sign in to comment.