zfs/lib/libzfs
наб ecd6ad66b0 libzfs: zfs_mount_at(): load key for encryption root if MS_CRYPT
zfs_crypto_load_key() only works on encryption roots,
and zfs mount -la would fail if it encounters a datasets that
is sorted before their encroots.

To trigger:
  truncate -s 40G /tmp/test
  dd if=/dev/urandom of=/tmp/k bs=128 count=1 status=none
  zpool create -O encryption=on -O keylocation=file:///tmp/k \
               -O keyformat=passphrase test /tmp/test
  zfs create -o mountpoint=/a test/a
  zfs create -o mountpoint=/b test/b
  zfs umount test
  zfs unload-key test
  zfs mount -la

The final mount errored out with:
  Key load error: Keys must be loaded for
    encryption root of 'test/a' (test).
  Key load error: Keys must be loaded for
    encryption root of 'test/b' (test).

And only /test was mounted

This technically breaks the libzfs API, but the previous behavior was
decidedly a bug.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #11870 
Closes #11875
2021-04-14 13:23:08 -07:00
..
os lib/: set O_CLOEXEC on all fds 2021-04-14 13:23:07 -07:00
.gitignore Clean up lib dependencies 2020-07-10 14:26:00 -07:00
Makefile.am Bump libzfs.so and libzpool.so versions 2021-04-07 13:25:13 -07:00
THIRDPARTYLICENSE.openssl Fix typos in lib/ 2019-09-02 17:53:27 -07:00
THIRDPARTYLICENSE.openssl.descrip Encryption patch follow-up 2017-10-11 16:54:48 -04:00
libzfs.abi Improvements to the 'compatibility' property 2021-04-14 13:23:08 -07:00
libzfs.pc.in Spruce up pkg-config files for libzfs/libzfs_core 2020-09-04 11:11:18 -07:00
libzfs.suppr Library ABI tracking with abigail 2020-11-17 09:18:52 -08:00
libzfs_changelist.c Add 'zfs rename -u' to rename without remounting 2020-09-01 16:14:16 -07:00
libzfs_config.c Use zfs_ioctl with zfs_cmd_t in libzfs 2019-10-23 17:29:43 -07:00
libzfs_crypto.c lib/: set O_CLOEXEC on all fds 2021-04-14 13:23:07 -07:00
libzfs_dataset.c libzfs{,_core}: set O_CLOEXEC on persistent (ZFS_DEV and MNTTAB) fds 2021-04-14 13:23:07 -07:00
libzfs_diff.c lib/: set O_CLOEXEC on all fds 2021-04-14 13:23:07 -07:00
libzfs_import.c zpool: speed up importing large pools (#11469) 2021-01-21 12:55:54 -08:00
libzfs_iter.c lib/: set O_CLOEXEC on all fds 2021-04-14 13:23:07 -07:00
libzfs_mount.c libzfs: zfs_mount_at(): load key for encryption root if MS_CRYPT 2021-04-14 13:23:08 -07:00
libzfs_pool.c Improvements to the 'compatibility' property 2021-04-14 13:23:08 -07:00
libzfs_sendrecv.c cmd/zfs receive: allow dry-run (-n) to check property args 2021-04-14 13:23:08 -07:00
libzfs_status.c Improvements to the 'compatibility' property 2021-04-14 13:23:08 -07:00
libzfs_util.c lib/: set O_CLOEXEC on all fds 2021-04-14 13:23:07 -07:00