Revert deferred flag for keyslots and temp devices.

It could cause races later, replacing with error device is enough.
This commit is contained in:
Milan Broz
2017-06-24 09:57:22 +02:00
parent ea694a4588
commit 3efa00d59a
3 changed files with 6 additions and 10 deletions

View File

@@ -274,5 +274,5 @@ int INTEGRITY_format(struct crypt_device *cd,
if (r)
return r;
return dm_remove_device(cd, tmp_name, CRYPT_DEACTIVATE_FORCE|CRYPT_DEACTIVATE_DEFERRED);
return dm_remove_device(cd, tmp_name, CRYPT_DEACTIVATE_FORCE);
}

View File

@@ -754,12 +754,6 @@ int dm_remove_device(struct crypt_device *cd, const char *name, uint32_t flags)
if (dm_init_context(cd, DM_UNKNOWN))
return -ENOTSUP;
if (flags & CRYPT_DEACTIVATE_FORCE) {
r = dm_query_device(cd, name, 0, &dmd);
if (r)
return r;
}
do {
r = _dm_remove(name, 1, flags & CRYPT_DEACTIVATE_DEFERRED) ? 0 : -EINVAL;
if (--retries && r) {
@@ -773,8 +767,10 @@ int dm_remove_device(struct crypt_device *cd, const char *name, uint32_t flags)
* Anyway, if some process try to read temporary cryptsetup device,
* it is bug - no other process should try touch it (e.g. udev).
*/
_error_device(name, dmd.size);
error_target = 1;
if (!dm_query_device(cd, name, 0, &dmd)) {
_error_device(name, dmd.size);
error_target = 1;
}
}
}
} while (r == -EINVAL && retries);

View File

@@ -124,7 +124,7 @@ static int LUKS_endec_template(char *src, size_t srcLength,
out:
if (devfd != -1)
close(devfd);
dm_remove_device(ctx, name, CRYPT_DEACTIVATE_FORCE|CRYPT_DEACTIVATE_DEFERRED);
dm_remove_device(ctx, name, CRYPT_DEACTIVATE_FORCE);
return r;
}