|
| 1 | +#!/bin/ksh -p |
| 2 | +# SPDX-License-Identifier: CDDL-1.0 |
| 3 | +# |
| 4 | +# CDDL HEADER START |
| 5 | +# |
| 6 | +# This file and its contents are supplied under the terms of the |
| 7 | +# Common Development and Distribution License ("CDDL"), version 1.0. |
| 8 | +# You may only use this file in accordance with the terms of version |
| 9 | +# 1.0 of the CDDL. |
| 10 | +# |
| 11 | +# A full copy of the text of the CDDL should have accompanied this |
| 12 | +# source. A copy of the CDDL is also available via the Internet at |
| 13 | +# http://www.illumos.org/license/CDDL. |
| 14 | +# |
| 15 | +# CDDL HEADER END |
| 16 | +# |
| 17 | + |
| 18 | +# |
| 19 | +# Copyright (c) 2025 by George Amanakis. All rights reserved. |
| 20 | +# |
| 21 | + |
| 22 | +. $STF_SUITE/tests/functional/rsend/rsend.kshlib |
| 23 | + |
| 24 | +# |
| 25 | +# DESCRIPTION: |
| 26 | +# Verify that an incremental non-raw zfs send from an encrypted filesystem |
| 27 | +# does not leak any keys or key mappings. |
| 28 | +# |
| 29 | +# STRATEGY: |
| 30 | +# 1. Create a new encrypted filesystem |
| 31 | +# 2. Write some files and create snapshots. |
| 32 | +# 3. Send to a new filesystem |
| 33 | +# 4. Do an incremental (-I) send and before that access all properties on the |
| 34 | +# sending filesystem (emulate sanoid) |
| 35 | +# 5. Export and re-import the pool. Upon exporting the pool if any keys/key |
| 36 | +# mappings leaked a panic will occur. |
| 37 | +# |
| 38 | + |
| 39 | +verify_runnable "both" |
| 40 | + |
| 41 | +function cleanup |
| 42 | +{ |
| 43 | + datasetexists $TESTPOOL/$TESTFS2 && \ |
| 44 | + destroy_dataset $TESTPOOL/$TESTFS2 -r |
| 45 | + datasetexists $TESTPOOL/recv && \ |
| 46 | + destroy_dataset $TESTPOOL/recv -r |
| 47 | + [[ -f $keyfile ]] && log_must rm $keyfile |
| 48 | +} |
| 49 | +log_onexit cleanup |
| 50 | + |
| 51 | +log_assert "Verify non-raw send with encryption does not leak any key mappings" |
| 52 | + |
| 53 | +typeset keyfile=/$TESTPOOL/pkey |
| 54 | + |
| 55 | +# Create an encrypted dataset |
| 56 | +log_must eval "echo 'password' > $keyfile" |
| 57 | +log_must zfs create -o encryption=on -o keyformat=passphrase \ |
| 58 | + -o keylocation=file://$keyfile $TESTPOOL/$TESTFS2 |
| 59 | + |
| 60 | +log_must dd if=/dev/urandom of=/$TESTPOOL/$TESTFS2/testfile bs=128K count=4 \ |
| 61 | + status=none |
| 62 | + |
| 63 | +for i in $(seq 0 20); do |
| 64 | + log_note "Taking snapshots" |
| 65 | + log_must zfs snapshot $TESTPOOL/$TESTFS2@snap_$i |
| 66 | + log_must dd if=/dev/urandom of=/$TESTPOOL/$TESTFS2/testfile bs=128K \ |
| 67 | + count=4 status=none |
| 68 | +done |
| 69 | + |
| 70 | +log_must eval "zfs send $TESTPOOL/$TESTFS2@snap_0 | zfs recv $TESTPOOL/recv" |
| 71 | + |
| 72 | +for i in $(seq 3 3 20); do |
| 73 | + log_note "Sending incremental snapshot snap_$((i - 3)) -> snap_$i" |
| 74 | + log_must zfs get -Hpd 1 -t snapshot all $TESTPOOL/$TESTFS2 &>/dev/null |
| 75 | + log_must eval "zfs send -I $TESTPOOL/$TESTFS2@snap_$((i - 3)) \ |
| 76 | + $TESTPOOL/$TESTFS2@snap_$i | zfs recv $TESTPOOL/recv" |
| 77 | +done |
| 78 | + |
| 79 | +log_must zpool export $TESTPOOL |
| 80 | +log_must zpool import $TESTPOOL |
| 81 | + |
| 82 | +log_pass "Verify non-raw send with encryption does not leak any key mappings" |
0 commit comments