diff options
author | Ondrej Kozina <okozina@redhat.com> | 2023-08-08 14:19:54 +0200 |
---|---|---|
committer | Ondrej Kozina <okozina@redhat.com> | 2023-10-31 11:13:58 +0100 |
commit | fea8b82e8d5f27399553e934213a99b607bce5c2 (patch) | |
tree | 131e05f00db2941abf2f0e42729710d3733c7246 | |
parent | 32fbac17b1e9d1d01a1c3ec4a7fed1c89cfc72b1 (diff) | |
download | cryptsetup-fea8b82e8d5f27399553e934213a99b607bce5c2.tar.gz |
Add missing exclusive open check in crypt_format_luks2_opal.
-rw-r--r-- | lib/setup.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/setup.c b/lib/setup.c index ec870259..bf3ad419 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -2331,6 +2331,20 @@ int crypt_format_luks2_opal(struct crypt_device *cd, partition_offset_sectors = crypt_dev_partition_offset(device_path(crypt_data_device(cd))); + r = device_check_access(cd, crypt_metadata_device(cd), DEV_EXCL); + if (r < 0) + return r; + + /* + * Check both data and metadata devices for exclusive access since + * we don't want to setup locking range on already used partition. + */ + if (crypt_metadata_device(cd) != crypt_data_device(cd)) { + r = device_check_access(cd, crypt_data_device(cd), DEV_EXCL); + if (r < 0) + return r; + } + if (!(cd->type = strdup(CRYPT_LUKS2))) return -ENOMEM; |