From c497945ab34ad290d03481ae3f360af52d8ff236 Mon Sep 17 00:00:00 2001 From: Milan Broz Date: Thu, 6 Feb 2025 12:34:43 +0100 Subject: [PATCH] Make internal dm_flags 64bit. --- lib/bitlk/bitlk.c | 2 +- lib/integrity/integrity.c | 4 +-- lib/libdevmapper.c | 16 ++++----- lib/loopaes/loopaes.c | 2 +- lib/luks2/luks2_reencrypt.c | 2 +- lib/setup.c | 6 ++-- lib/tcrypt/tcrypt.c | 2 +- lib/utils_dm.h | 66 ++++++++++++++++++------------------- lib/verity/verity.c | 2 +- 9 files changed, 51 insertions(+), 51 deletions(-) diff --git a/lib/bitlk/bitlk.c b/lib/bitlk/bitlk.c index 6d07f216..308abd53 100644 --- a/lib/bitlk/bitlk.c +++ b/lib/bitlk/bitlk.c @@ -1241,7 +1241,7 @@ static int _activate(struct crypt_device *cd, uint64_t next_start = 0; uint64_t next_end = 0; uint64_t last_segment = 0; - uint32_t dmt_flags = 0; + uint64_t dmt_flags = 0; r = _activate_check(cd, params); if (r) diff --git a/lib/integrity/integrity.c b/lib/integrity/integrity.c index 2a927e6b..11600952 100644 --- a/lib/integrity/integrity.c +++ b/lib/integrity/integrity.c @@ -266,7 +266,7 @@ int INTEGRITY_activate_dmd_device(struct crypt_device *cd, uint32_t sb_flags) { int r; - uint32_t dmi_flags; + uint64_t dmi_flags; struct dm_target *tgt = &dmd->segment; if (!single_segment(dmd) || tgt->type != DM_INTEGRITY) @@ -394,7 +394,7 @@ int INTEGRITY_format(struct crypt_device *cd, struct volume_key *journal_mac_key, uint64_t backing_device_sectors) { - uint32_t dmi_flags; + uint64_t dmi_flags; char reduced_device_name[70], tmp_name[64], tmp_uuid[40]; struct crypt_dm_active_device dmdi = { .size = 8, diff --git a/lib/libdevmapper.c b/lib/libdevmapper.c index 14a3752d..a4f7d21f 100644 --- a/lib/libdevmapper.c +++ b/lib/libdevmapper.c @@ -36,7 +36,7 @@ static bool _dm_integrity_checked = false; static bool _dm_zero_checked = false; static int _quiet_log = 0; -static uint32_t _dm_flags = 0; +static uint64_t _dm_flags = 0; static struct crypt_device *_context = NULL; static int _dm_use_count = 0; @@ -364,7 +364,7 @@ out: return r; } -int dm_flags(struct crypt_device *cd, dm_target_type target, uint32_t *flags) +int dm_flags(struct crypt_device *cd, dm_target_type target, uint64_t *flags) { _dm_check_versions(cd, target); *flags = _dm_flags; @@ -1100,7 +1100,7 @@ int dm_remove_device(struct crypt_device *cd, const char *name, uint32_t flags) int retries = (flags & CRYPT_DEACTIVATE_FORCE) ? RETRY_COUNT : 1; int deferred = (flags & CRYPT_DEACTIVATE_DEFERRED) ? 1 : 0; int error_target = 0; - uint32_t dmt_flags; + uint64_t dmt_flags; if (!name) return -EINVAL; @@ -1683,7 +1683,7 @@ int dm_create_device(struct crypt_device *cd, const char *name, const char *type, struct crypt_dm_active_device *dmd) { - uint32_t dmt_flags = 0; + uint64_t dmt_flags = 0; int r = -EINVAL; if (!type || !dmd) @@ -1806,7 +1806,7 @@ int dm_reload_device(struct crypt_device *cd, const char *name, struct crypt_dm_active_device *dmd, uint32_t dmflags, unsigned resume) { int r; - uint32_t dmt_flags; + uint64_t dmt_flags; if (!dmd) return -EINVAL; @@ -3029,7 +3029,7 @@ out: int dm_suspend_device(struct crypt_device *cd, const char *name, uint32_t dmflags) { - uint32_t dmt_flags; + uint64_t dmt_flags; int r = -ENOTSUP; if (dm_init_context(cd, DM_UNKNOWN)) @@ -3078,7 +3078,7 @@ int dm_resume_device(struct crypt_device *cd, const char *name, uint32_t dmflags int dm_resume_and_reinstate_key(struct crypt_device *cd, const char *name, const struct volume_key *vk) { - uint32_t dmt_flags; + uint64_t dmt_flags; int msg_size; char *msg = NULL, *key = NULL; int r = -ENOTSUP; @@ -3236,7 +3236,7 @@ int dm_integrity_target_set(struct crypt_device *cd, struct volume_key *journal_crypt_key, struct volume_key *journal_mac_key, const struct crypt_params_integrity *ip) { - uint32_t dmi_flags; + uint64_t dmi_flags; if (!data_device) return -EINVAL; diff --git a/lib/loopaes/loopaes.c b/lib/loopaes/loopaes.c index e2c6821d..bdd9ded7 100644 --- a/lib/loopaes/loopaes.c +++ b/lib/loopaes/loopaes.c @@ -198,7 +198,7 @@ int LOOPAES_activate(struct crypt_device *cd, uint32_t flags) { int r; - uint32_t req_flags, dmc_flags; + uint64_t req_flags, dmc_flags; char *cipher = NULL; struct crypt_dm_active_device dmd = { .flags = flags, diff --git a/lib/luks2/luks2_reencrypt.c b/lib/luks2/luks2_reencrypt.c index 73ecba61..fcf92f84 100644 --- a/lib/luks2/luks2_reencrypt.c +++ b/lib/luks2/luks2_reencrypt.c @@ -4170,7 +4170,7 @@ static int reencrypt_wipe_unused_device_area(struct crypt_device *cd, struct luk static int reencrypt_teardown_ok(struct crypt_device *cd, struct luks2_hdr *hdr, struct luks2_reencrypt *rh) { int i, r; - uint32_t dmt_flags; + uint64_t dmt_flags; bool finished = !(rh->device_size > rh->progress); if (rh->rp.type == REENC_PROTECTION_NONE && diff --git a/lib/setup.c b/lib/setup.c index 6d6ffe26..c488acc3 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -1966,7 +1966,7 @@ static int LUKS2_check_encryption_sector(struct crypt_device *cd, uint64_t devic uint64_t data_offset_bytes, uint32_t sector_size, bool modify_sector_size, bool verify_data_area_alignment, uint32_t *ret_sector_size) { - uint32_t dmc_flags; + uint64_t dmc_flags; assert(ret_sector_size); @@ -3691,7 +3691,7 @@ int crypt_resize(struct crypt_device *cd, const char *name, uint64_t new_size) struct crypt_dm_active_device dmdq, dmd = {}; struct dm_target *tgt = &dmdq.segment; struct crypt_params_integrity params = {}; - uint32_t supported_flags = 0, dmflags = 0; + uint64_t supported_flags = 0, dmflags = 0; uint64_t old_size; int r; @@ -7436,7 +7436,7 @@ int crypt_keyslot_add_by_keyslot_context(struct crypt_device *cd, */ int crypt_use_keyring_for_vk(struct crypt_device *cd) { - uint32_t dmc_flags; + uint64_t dmc_flags; /* dm backend must be initialized */ if (!cd) diff --git a/lib/tcrypt/tcrypt.c b/lib/tcrypt/tcrypt.c index fc1fb4d9..c2a137c9 100644 --- a/lib/tcrypt/tcrypt.c +++ b/lib/tcrypt/tcrypt.c @@ -732,7 +732,7 @@ int TCRYPT_activate(struct crypt_device *cd, char *part_path; unsigned int i; int r; - uint32_t req_flags, dmc_flags; + uint64_t req_flags, dmc_flags; const struct tcrypt_algs *algs; enum devcheck device_check; uint64_t offset, iv_offset; diff --git a/lib/utils_dm.h b/lib/utils_dm.h index f5fa4d01..1a9cf5bc 100644 --- a/lib/utils_dm.h +++ b/lib/utils_dm.h @@ -33,43 +33,43 @@ static inline uint32_t act2dmflags(uint32_t act_flags) } /* Device mapper backend - kernel support flags */ -#define DM_KEY_WIPE_SUPPORTED (1 << 0) /* key wipe message */ -#define DM_LMK_SUPPORTED (1 << 1) /* lmk mode */ -#define DM_SECURE_SUPPORTED (1 << 2) /* wipe (secure) buffer flag */ -#define DM_PLAIN64_SUPPORTED (1 << 3) /* plain64 IV */ -#define DM_DISCARDS_SUPPORTED (1 << 4) /* discards/TRIM option is supported */ -#define DM_VERITY_SUPPORTED (1 << 5) /* dm-verity target supported */ -#define DM_TCW_SUPPORTED (1 << 6) /* tcw (TCRYPT CBC with whitening) */ -#define DM_SAME_CPU_CRYPT_SUPPORTED (1 << 7) /* same_cpu_crypt */ -#define DM_SUBMIT_FROM_CRYPT_CPUS_SUPPORTED (1 << 8) /* submit_from_crypt_cpus */ -#define DM_VERITY_ON_CORRUPTION_SUPPORTED (1 << 9) /* ignore/restart_on_corruption, ignore_zero_block */ -#define DM_VERITY_FEC_SUPPORTED (1 << 10) /* Forward Error Correction (FEC) */ -#define DM_KERNEL_KEYRING_SUPPORTED (1 << 11) /* dm-crypt allows loading kernel keyring keys */ -#define DM_INTEGRITY_SUPPORTED (1 << 12) /* dm-integrity target supported */ -#define DM_SECTOR_SIZE_SUPPORTED (1 << 13) /* support for sector size setting in dm-crypt/dm-integrity */ -#define DM_CAPI_STRING_SUPPORTED (1 << 14) /* support for cryptoapi format cipher definition */ -#define DM_DEFERRED_SUPPORTED (1 << 15) /* deferred removal of device */ -#define DM_INTEGRITY_RECALC_SUPPORTED (1 << 16) /* dm-integrity automatic recalculation supported */ -#define DM_INTEGRITY_BITMAP_SUPPORTED (1 << 17) /* dm-integrity bitmap mode supported */ -#define DM_GET_TARGET_VERSION_SUPPORTED (1 << 18) /* dm DM_GET_TARGET version ioctl supported */ -#define DM_INTEGRITY_FIX_PADDING_SUPPORTED (1 << 19) /* supports the parameter fix_padding that fixes a bug that caused excessive padding */ -#define DM_BITLK_EBOIV_SUPPORTED (1 << 20) /* EBOIV for BITLK supported */ -#define DM_BITLK_ELEPHANT_SUPPORTED (1 << 21) /* Elephant diffuser for BITLK supported */ -#define DM_VERITY_SIGNATURE_SUPPORTED (1 << 22) /* Verity option root_hash_sig_key_desc supported */ -#define DM_INTEGRITY_DISCARDS_SUPPORTED (1 << 23) /* dm-integrity discards/TRIM option is supported */ -#define DM_INTEGRITY_RESIZE_SUPPORTED (1 << 23) /* dm-integrity resize of the integrity device supported (introduced in the same version as discards)*/ -#define DM_VERITY_PANIC_CORRUPTION_SUPPORTED (1 << 24) /* dm-verity panic on corruption */ -#define DM_CRYPT_NO_WORKQUEUE_SUPPORTED (1 << 25) /* dm-crypt support for bypassing workqueues */ -#define DM_INTEGRITY_FIX_HMAC_SUPPORTED (1 << 26) /* hmac covers also superblock */ -#define DM_INTEGRITY_RESET_RECALC_SUPPORTED (1 << 27) /* dm-integrity automatic recalculation supported */ -#define DM_VERITY_TASKLETS_SUPPORTED (1 << 28) /* dm-verity tasklets supported */ -#define DM_CRYPT_HIGH_PRIORITY_SUPPORTED (1 << 29) /* dm-crypt high priority workqueue flag supported */ -#define DM_CRYPT_INTEGRITY_KEY_SIZE_OPT_SUPPORTED (1 << 30) /* dm-crypt support for integrity_key_size option */ +#define DM_KEY_WIPE_SUPPORTED (UINT64_C(1) << 0) /* key wipe message */ +#define DM_LMK_SUPPORTED (UINT64_C(1) << 1) /* lmk mode */ +#define DM_SECURE_SUPPORTED (UINT64_C(1) << 2) /* wipe (secure) buffer flag */ +#define DM_PLAIN64_SUPPORTED (UINT64_C(1) << 3) /* plain64 IV */ +#define DM_DISCARDS_SUPPORTED (UINT64_C(1) << 4) /* discards/TRIM option is supported */ +#define DM_VERITY_SUPPORTED (UINT64_C(1) << 5) /* dm-verity target supported */ +#define DM_TCW_SUPPORTED (UINT64_C(1) << 6) /* tcw (TCRYPT CBC with whitening) */ +#define DM_SAME_CPU_CRYPT_SUPPORTED (UINT64_C(1) << 7) /* same_cpu_crypt */ +#define DM_SUBMIT_FROM_CRYPT_CPUS_SUPPORTED (UINT64_C(1) << 8) /* submit_from_crypt_cpus */ +#define DM_VERITY_ON_CORRUPTION_SUPPORTED (UINT64_C(1) << 9) /* ignore/restart_on_corruption, ignore_zero_block */ +#define DM_VERITY_FEC_SUPPORTED (UINT64_C(1) << 10) /* Forward Error Correction (FEC) */ +#define DM_KERNEL_KEYRING_SUPPORTED (UINT64_C(1) << 11) /* dm-crypt allows loading kernel keyring keys */ +#define DM_INTEGRITY_SUPPORTED (UINT64_C(1) << 12) /* dm-integrity target supported */ +#define DM_SECTOR_SIZE_SUPPORTED (UINT64_C(1) << 13) /* support for sector size setting in dm-crypt/dm-integrity */ +#define DM_CAPI_STRING_SUPPORTED (UINT64_C(1) << 14) /* support for cryptoapi format cipher definition */ +#define DM_DEFERRED_SUPPORTED (UINT64_C(1) << 15) /* deferred removal of device */ +#define DM_INTEGRITY_RECALC_SUPPORTED (UINT64_C(1) << 16) /* dm-integrity automatic recalculation supported */ +#define DM_INTEGRITY_BITMAP_SUPPORTED (UINT64_C(1) << 17) /* dm-integrity bitmap mode supported */ +#define DM_GET_TARGET_VERSION_SUPPORTED (UINT64_C(1) << 18) /* dm DM_GET_TARGET version ioctl supported */ +#define DM_INTEGRITY_FIX_PADDING_SUPPORTED (UINT64_C(1) << 19) /* supports the parameter fix_padding that fixes a bug that caused excessive padding */ +#define DM_BITLK_EBOIV_SUPPORTED (UINT64_C(1) << 20) /* EBOIV for BITLK supported */ +#define DM_BITLK_ELEPHANT_SUPPORTED (UINT64_C(1) << 21) /* Elephant diffuser for BITLK supported */ +#define DM_VERITY_SIGNATURE_SUPPORTED (UINT64_C(1) << 22) /* Verity option root_hash_sig_key_desc supported */ +#define DM_INTEGRITY_DISCARDS_SUPPORTED (UINT64_C(1) << 23) /* dm-integrity discards/TRIM option is supported */ +#define DM_INTEGRITY_RESIZE_SUPPORTED (UINT64_C(1) << 23) /* dm-integrity resize of the integrity device supported (introduced in the same version as discards)*/ +#define DM_VERITY_PANIC_CORRUPTION_SUPPORTED (UINT64_C(1) << 24) /* dm-verity panic on corruption */ +#define DM_CRYPT_NO_WORKQUEUE_SUPPORTED (UINT64_C(1) << 25) /* dm-crypt support for bypassing workqueues */ +#define DM_INTEGRITY_FIX_HMAC_SUPPORTED (UINT64_C(1) << 26) /* hmac covers also superblock */ +#define DM_INTEGRITY_RESET_RECALC_SUPPORTED (UINT64_C(1) << 27) /* dm-integrity automatic recalculation supported */ +#define DM_VERITY_TASKLETS_SUPPORTED (UINT64_C(1) << 28) /* dm-verity tasklets supported */ +#define DM_CRYPT_HIGH_PRIORITY_SUPPORTED (UINT64_C(1) << 29) /* dm-crypt high priority workqueue flag supported */ +#define DM_CRYPT_INTEGRITY_KEY_SIZE_OPT_SUPPORTED (UINT64_C(1) << 30) /* dm-crypt support for integrity_key_size option */ typedef enum { DM_CRYPT = 0, DM_VERITY, DM_INTEGRITY, DM_LINEAR, DM_ERROR, DM_ZERO, DM_UNKNOWN } dm_target_type; enum tdirection { TARGET_EMPTY = 0, TARGET_SET, TARGET_QUERY }; -int dm_flags(struct crypt_device *cd, dm_target_type target, uint32_t *flags); +int dm_flags(struct crypt_device *cd, dm_target_type target, uint64_t *flags); #define DM_ACTIVE_DEVICE (1 << 0) #define DM_ACTIVE_UUID (1 << 1) diff --git a/lib/verity/verity.c b/lib/verity/verity.c index c583eb6a..175cb50f 100644 --- a/lib/verity/verity.c +++ b/lib/verity/verity.c @@ -301,7 +301,7 @@ int VERITY_activate(struct crypt_device *cd, struct crypt_params_verity *verity_hdr, uint32_t activation_flags) { - uint32_t dmv_flags; + uint64_t dmv_flags; int r; key_serial_t kid; char *description = NULL;