Skip to content

Commit 8a63cf1

Browse files
committed
ZIL: Do not encrypt block pointers in lr_clone_range_t
In case of crash cloned blocks need to be claimed on pool import. It is only possible if they (lr_bps) and their count (lr_nbps) are not encrypted but only authenticated, similar to block pointer in lr_write_t. Few other fields can be and are still encrypted. This should fix panic on ZIL claim after crash when block cloning is actively used. Reviewed-by: Richard Yao <[email protected]> Reviewed-by: Tom Caputi <[email protected]> Reviewed-by: Sean Eric Fagan <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Edmund Nadolski <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes openzfs#15543 Closes openzfs#15513
1 parent 55dd24c commit 8a63cf1

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

module/os/freebsd/zfs/zio_crypt.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1364,6 +1364,19 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
13641364
vec++;
13651365
total_len += crypt_len;
13661366
}
1367+
} else if (txtype == TX_CLONE_RANGE) {
1368+
const size_t o = offsetof(lr_clone_range_t, lr_nbps);
1369+
crypt_len = o - sizeof (lr_t);
1370+
dst_iovecs[vec].iov_base = (char *)dlrp + sizeof (lr_t);
1371+
dst_iovecs[vec].iov_len = crypt_len;
1372+
1373+
/* copy the bps now since they will not be encrypted */
1374+
memcpy(dlrp + o, slrp + o, lr_len - o);
1375+
memcpy(aadp, slrp + o, lr_len - o);
1376+
aadp += lr_len - o;
1377+
aad_len += lr_len - o;
1378+
vec++;
1379+
total_len += crypt_len;
13671380
} else {
13681381
crypt_len = lr_len - sizeof (lr_t);
13691382
dst_iovecs[vec].iov_base = (char *)dlrp +

module/os/linux/zfs/zio_crypt.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1543,6 +1543,21 @@ zio_crypt_init_uios_zil(boolean_t encrypt, uint8_t *plainbuf,
15431543
nr_iovecs++;
15441544
total_len += crypt_len;
15451545
}
1546+
} else if (txtype == TX_CLONE_RANGE) {
1547+
const size_t o = offsetof(lr_clone_range_t, lr_nbps);
1548+
crypt_len = o - sizeof (lr_t);
1549+
src_iovecs[nr_iovecs].iov_base = slrp + sizeof (lr_t);
1550+
src_iovecs[nr_iovecs].iov_len = crypt_len;
1551+
dst_iovecs[nr_iovecs].iov_base = dlrp + sizeof (lr_t);
1552+
dst_iovecs[nr_iovecs].iov_len = crypt_len;
1553+
1554+
/* copy the bps now since they will not be encrypted */
1555+
memcpy(dlrp + o, slrp + o, lr_len - o);
1556+
memcpy(aadp, slrp + o, lr_len - o);
1557+
aadp += lr_len - o;
1558+
aad_len += lr_len - o;
1559+
nr_iovecs++;
1560+
total_len += crypt_len;
15461561
} else {
15471562
crypt_len = lr_len - sizeof (lr_t);
15481563
src_iovecs[nr_iovecs].iov_base = slrp + sizeof (lr_t);

0 commit comments

Comments
 (0)