mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-12 03:10:08 +01:00
Fix api-test with older kernel.
This commit is contained in:
@@ -302,6 +302,9 @@ static int _setup(void)
|
|||||||
_system("modprobe dm-verity >/dev/null 2>&1", 0);
|
_system("modprobe dm-verity >/dev/null 2>&1", 0);
|
||||||
_system("modprobe dm-integrity >/dev/null 2>&1", 0);
|
_system("modprobe dm-integrity >/dev/null 2>&1", 0);
|
||||||
|
|
||||||
|
if (t_dm_check_versions())
|
||||||
|
return 1;
|
||||||
|
|
||||||
_fips_mode = fips_mode();
|
_fips_mode = fips_mode();
|
||||||
if (_debug)
|
if (_debug)
|
||||||
printf("FIPS MODE: %d\n", _fips_mode);
|
printf("FIPS MODE: %d\n", _fips_mode);
|
||||||
@@ -1856,6 +1859,11 @@ static void ResizeIntegrity(void)
|
|||||||
int ret;
|
int ret;
|
||||||
uint64_t r_size, whole_device_size = 0;
|
uint64_t r_size, whole_device_size = 0;
|
||||||
|
|
||||||
|
if (!t_dm_integrity_resize_support()) {
|
||||||
|
printf("WARNING: integrity device resize not supported, skipping test.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
OK_(crypt_init(&cd, DEVICE_2));
|
OK_(crypt_init(&cd, DEVICE_2));
|
||||||
ret = crypt_format(cd,CRYPT_INTEGRITY,NULL,NULL,NULL,NULL,0,¶ms);
|
ret = crypt_format(cd,CRYPT_INTEGRITY,NULL,NULL,NULL,NULL,0,¶ms);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -1935,6 +1943,11 @@ static void ResizeIntegrityWithKey(void)
|
|||||||
params.journal_crypt_key_size = journal_crypt_key_size;
|
params.journal_crypt_key_size = journal_crypt_key_size;
|
||||||
params.journal_crypt_key = journal_crypt_key;
|
params.journal_crypt_key = journal_crypt_key;
|
||||||
|
|
||||||
|
if (!t_dm_integrity_resize_support()) {
|
||||||
|
printf("WARNING: integrity device resize not supported, skipping test.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
OK_(crypt_init(&cd, DEVICE_2));
|
OK_(crypt_init(&cd, DEVICE_2));
|
||||||
ret = crypt_format(cd,CRYPT_INTEGRITY,NULL,NULL,NULL,NULL,0,¶ms);
|
ret = crypt_format(cd,CRYPT_INTEGRITY,NULL,NULL,NULL,NULL,0,¶ms);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -2032,11 +2045,13 @@ static void IntegrityTest(void)
|
|||||||
OK_(strcmp(ip.integrity,params.integrity));
|
OK_(strcmp(ip.integrity,params.integrity));
|
||||||
OK_(strcmp(CRYPT_INTEGRITY,crypt_get_type(cd)));
|
OK_(strcmp(CRYPT_INTEGRITY,crypt_get_type(cd)));
|
||||||
|
|
||||||
|
if (t_dm_integrity_recalculate_support()) {
|
||||||
OK_(crypt_get_active_device(cd, CDEVICE_1, &cad));
|
OK_(crypt_get_active_device(cd, CDEVICE_1, &cad));
|
||||||
EQ_(cad.flags & CRYPT_ACTIVATE_RECALCULATE, 0);
|
EQ_(cad.flags & CRYPT_ACTIVATE_RECALCULATE, 0);
|
||||||
OK_(crypt_activate_by_volume_key(cd, CDEVICE_1, NULL, 0, CRYPT_ACTIVATE_REFRESH | CRYPT_ACTIVATE_RECALCULATE));
|
OK_(crypt_activate_by_volume_key(cd, CDEVICE_1, NULL, 0, CRYPT_ACTIVATE_REFRESH | CRYPT_ACTIVATE_RECALCULATE));
|
||||||
OK_(crypt_get_active_device(cd, CDEVICE_1, &cad));
|
OK_(crypt_get_active_device(cd, CDEVICE_1, &cad));
|
||||||
EQ_(cad.flags & CRYPT_ACTIVATE_RECALCULATE, CRYPT_ACTIVATE_RECALCULATE);
|
EQ_(cad.flags & CRYPT_ACTIVATE_RECALCULATE, CRYPT_ACTIVATE_RECALCULATE);
|
||||||
|
}
|
||||||
|
|
||||||
OK_(crypt_deactivate(cd, CDEVICE_1));
|
OK_(crypt_deactivate(cd, CDEVICE_1));
|
||||||
CRYPT_FREE(cd);
|
CRYPT_FREE(cd);
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ int t_dm_check_versions(void);
|
|||||||
int t_dm_crypt_keyring_support(void);
|
int t_dm_crypt_keyring_support(void);
|
||||||
int t_dm_crypt_cpu_switch_support(void);
|
int t_dm_crypt_cpu_switch_support(void);
|
||||||
int t_dm_crypt_discard_support(void);
|
int t_dm_crypt_discard_support(void);
|
||||||
|
int t_dm_integrity_resize_support(void);
|
||||||
|
int t_dm_integrity_recalculate_support(void);
|
||||||
int t_set_readahead(const char *device, unsigned value);
|
int t_set_readahead(const char *device, unsigned value);
|
||||||
|
|
||||||
int fips_mode(void);
|
int fips_mode(void);
|
||||||
@@ -122,7 +124,23 @@ void xlog(const char *msg, const char *tst, const char *func, int line, const ch
|
|||||||
#define T_DM_VERITY_FEC_SUPPORTED (1 << 10) /* Forward Error Correction (FEC) */
|
#define T_DM_VERITY_FEC_SUPPORTED (1 << 10) /* Forward Error Correction (FEC) */
|
||||||
#define T_DM_KERNEL_KEYRING_SUPPORTED (1 << 11) /* dm-crypt allows loading kernel keyring keys */
|
#define T_DM_KERNEL_KEYRING_SUPPORTED (1 << 11) /* dm-crypt allows loading kernel keyring keys */
|
||||||
#define T_DM_INTEGRITY_SUPPORTED (1 << 12) /* dm-integrity target supported */
|
#define T_DM_INTEGRITY_SUPPORTED (1 << 12) /* dm-integrity target supported */
|
||||||
//FIXME add T_DM_SECTOR_SIZE once we have version
|
#define T_DM_SECTOR_SIZE_SUPPORTED (1 << 13) /* support for sector size setting in dm-crypt/dm-integrity */
|
||||||
|
#define T_DM_CAPI_STRING_SUPPORTED (1 << 14) /* support for cryptoapi format cipher definition */
|
||||||
|
#define T_DM_DEFERRED_SUPPORTED (1 << 15) /* deferred removal of device */
|
||||||
|
#define T_DM_INTEGRITY_RECALC_SUPPORTED (1 << 16) /* dm-integrity automatic recalculation supported */
|
||||||
|
#define T_DM_INTEGRITY_BITMAP_SUPPORTED (1 << 17) /* dm-integrity bitmap mode supported */
|
||||||
|
#define T_DM_GET_TARGET_VERSION_SUPPORTED (1 << 18) /* dm DM_GET_TARGET version ioctl supported */
|
||||||
|
#define T_DM_INTEGRITY_FIX_PADDING_SUPPORTED (1 << 19) /* supports the parameter fix_padding that fixes a bug that caused excessive padding */
|
||||||
|
#define T_DM_BITLK_EBOIV_SUPPORTED (1 << 20) /* EBOIV for BITLK supported */
|
||||||
|
#define T_DM_BITLK_ELEPHANT_SUPPORTED (1 << 21) /* Elephant diffuser for BITLK supported */
|
||||||
|
#define T_DM_VERITY_SIGNATURE_SUPPORTED (1 << 22) /* Verity option root_hash_sig_key_desc supported */
|
||||||
|
#define T_DM_INTEGRITY_DISCARDS_SUPPORTED (1 << 23) /* dm-integrity discards/TRIM option is supported */
|
||||||
|
#define T_DM_INTEGRITY_RESIZE_SUPPORTED (1 << 23) /* dm-integrity resize of the integrity device supported (introduced in the same version as discards)*/
|
||||||
|
#define T_DM_VERITY_PANIC_CORRUPTION_SUPPORTED (1 << 24) /* dm-verity panic on corruption */
|
||||||
|
#define T_DM_CRYPT_NO_WORKQUEUE_SUPPORTED (1 << 25) /* dm-crypt suppot for bypassing workqueues */
|
||||||
|
#define T_DM_INTEGRITY_FIX_HMAC_SUPPORTED (1 << 26) /* hmac covers also superblock */
|
||||||
|
#define T_DM_INTEGRITY_RESET_RECALC_SUPPORTED (1 << 27) /* dm-integrity automatic recalculation supported */
|
||||||
|
#define T_DM_VERITY_TASKLETS_SUPPORTED (1 << 28) /* dm-verity tasklets supported */
|
||||||
|
|
||||||
/* loop helpers */
|
/* loop helpers */
|
||||||
int loop_device(const char *loop);
|
int loop_device(const char *loop);
|
||||||
|
|||||||
@@ -540,6 +540,20 @@ static void t_dm_set_crypt_compat(const char *dm_version, unsigned crypt_maj,
|
|||||||
|
|
||||||
if (t_dm_satisfies_version(1, 18, 1, crypt_maj, crypt_min, crypt_patch) && _keyring_check())
|
if (t_dm_satisfies_version(1, 18, 1, crypt_maj, crypt_min, crypt_patch) && _keyring_check())
|
||||||
t_dm_crypt_flags |= T_DM_KERNEL_KEYRING_SUPPORTED;
|
t_dm_crypt_flags |= T_DM_KERNEL_KEYRING_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 17, 0, crypt_maj, crypt_min, crypt_patch)) {
|
||||||
|
t_dm_crypt_flags |= T_DM_SECTOR_SIZE_SUPPORTED;
|
||||||
|
t_dm_crypt_flags |= T_DM_CAPI_STRING_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 19, 0, crypt_maj, crypt_min, crypt_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_BITLK_EBOIV_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 20, 0, crypt_maj, crypt_min, crypt_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_BITLK_ELEPHANT_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 22, 0, crypt_maj, crypt_min, crypt_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_CRYPT_NO_WORKQUEUE_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void t_dm_set_verity_compat(const char *dm_version __attribute__((unused)),
|
static void t_dm_set_verity_compat(const char *dm_version __attribute__((unused)),
|
||||||
@@ -561,6 +575,15 @@ static void t_dm_set_verity_compat(const char *dm_version __attribute__((unused)
|
|||||||
t_dm_crypt_flags |= T_DM_VERITY_ON_CORRUPTION_SUPPORTED;
|
t_dm_crypt_flags |= T_DM_VERITY_ON_CORRUPTION_SUPPORTED;
|
||||||
t_dm_crypt_flags |= T_DM_VERITY_FEC_SUPPORTED;
|
t_dm_crypt_flags |= T_DM_VERITY_FEC_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 5, 0, verity_maj, verity_min, verity_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_VERITY_SIGNATURE_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 7, 0, verity_maj, verity_min, verity_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_VERITY_PANIC_CORRUPTION_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 9, 0, verity_maj, verity_min, verity_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_VERITY_TASKLETS_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void t_dm_set_integrity_compat(const char *dm_version __attribute__((unused)),
|
static void t_dm_set_integrity_compat(const char *dm_version __attribute__((unused)),
|
||||||
@@ -570,6 +593,24 @@ static void t_dm_set_integrity_compat(const char *dm_version __attribute__((unus
|
|||||||
{
|
{
|
||||||
if (integrity_maj > 0)
|
if (integrity_maj > 0)
|
||||||
t_dm_crypt_flags |= T_DM_INTEGRITY_SUPPORTED;
|
t_dm_crypt_flags |= T_DM_INTEGRITY_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 2, 0, integrity_maj, integrity_min, integrity_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_INTEGRITY_RECALC_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 3, 0, integrity_maj, integrity_min, integrity_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_INTEGRITY_BITMAP_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 4, 0, integrity_maj, integrity_min, integrity_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_INTEGRITY_FIX_PADDING_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 6, 0, integrity_maj, integrity_min, integrity_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_INTEGRITY_DISCARDS_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 7, 0, integrity_maj, integrity_min, integrity_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_INTEGRITY_FIX_HMAC_SUPPORTED;
|
||||||
|
|
||||||
|
if (t_dm_satisfies_version(1, 8, 0, integrity_maj, integrity_min, integrity_patch))
|
||||||
|
t_dm_crypt_flags |= T_DM_INTEGRITY_RESET_RECALC_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int t_dm_check_versions(void)
|
int t_dm_check_versions(void)
|
||||||
@@ -634,6 +675,16 @@ int t_dm_crypt_discard_support(void)
|
|||||||
return t_dm_crypt_flags & T_DM_DISCARDS_SUPPORTED;
|
return t_dm_crypt_flags & T_DM_DISCARDS_SUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int t_dm_integrity_resize_support(void)
|
||||||
|
{
|
||||||
|
return t_dm_crypt_flags & T_DM_INTEGRITY_RESIZE_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
|
int t_dm_integrity_recalculate_support(void)
|
||||||
|
{
|
||||||
|
return t_dm_crypt_flags & T_DM_INTEGRITY_RECALC_SUPPORTED;
|
||||||
|
}
|
||||||
|
|
||||||
/* loop helpers */
|
/* loop helpers */
|
||||||
|
|
||||||
#define LOOP_DEV_MAJOR 7
|
#define LOOP_DEV_MAJOR 7
|
||||||
|
|||||||
Reference in New Issue
Block a user