]> git.proxmox.com Git - zfsonlinux.git/blob - debian/patches/0015-Fix-block-cloning-between-unencrypted-and-encrypted-.patch
pick bug-fixes staged for 2.2.1
[zfsonlinux.git] / debian / patches / 0015-Fix-block-cloning-between-unencrypted-and-encrypted-.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Martin=20Matu=C5=A1ka?= <mm@FreeBSD.org>
3 Date: Tue, 31 Oct 2023 21:49:41 +0100
4 Subject: [PATCH] Fix block cloning between unencrypted and encrypted datasets
5
6 Block cloning from an encrypted dataset into an unencrypted dataset
7 and vice versa is not possible. The current code did allow cloning
8 unencrypted files into an encrypted dataset causing a panic when
9 these were accessed. Block cloning between encrypted and encrypted
10 is currently supported on the same filesystem only.
11
12 Reviewed-by: Alexander Motin <mav@FreeBSD.org>
13 Reviewed-by: Kay Pedersen <mail@mkwg.de>
14 Reviewed-by: Rob N <robn@despairlabs.com>
15 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
16 Signed-off-by: Martin Matuska <mm@FreeBSD.org>
17 Closes #15464
18 Closes #15465
19 (cherry picked from commit 459c99ff2339a4a514abcf2255f9b3e5324ef09e)
20 Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
21 ---
22 module/zfs/zfs_vnops.c | 9 +++++++++
23 1 file changed, 9 insertions(+)
24
25 diff --git a/module/zfs/zfs_vnops.c b/module/zfs/zfs_vnops.c
26 index 40d6c87a7..84e6b10ef 100644
27 --- a/module/zfs/zfs_vnops.c
28 +++ b/module/zfs/zfs_vnops.c
29 @@ -1094,6 +1094,15 @@ zfs_clone_range(znode_t *inzp, uint64_t *inoffp, znode_t *outzp,
30
31 ASSERT(!outzfsvfs->z_replay);
32
33 + /*
34 + * Block cloning from an unencrypted dataset into an encrypted
35 + * dataset and vice versa is not supported.
36 + */
37 + if (inos->os_encrypted != outos->os_encrypted) {
38 + zfs_exit_two(inzfsvfs, outzfsvfs, FTAG);
39 + return (SET_ERROR(EXDEV));
40 + }
41 +
42 error = zfs_verify_zp(inzp);
43 if (error == 0)
44 error = zfs_verify_zp(outzp);