From 54d757a4c7de1e3fc1d4a13be05db2c7f9c40a94 Mon Sep 17 00:00:00 2001 From: Ondrej Kozina Date: Thu, 8 Aug 2019 14:46:01 +0200 Subject: [PATCH] Fix illegal access to deallocated memory. When deallocating context with LUKS2 reencryption handle we access data device structure after being free'd. --- lib/setup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/setup.c b/lib/setup.c index 36889643..bd25a0a7 100644 --- a/lib/setup.c +++ b/lib/setup.c @@ -2918,12 +2918,13 @@ void crypt_free(struct crypt_device *cd) dm_backend_exit(cd); crypt_free_volume_key(cd->volume_key); + crypt_free_type(cd); + device_free(cd, cd->device); device_free(cd, cd->metadata_device); free(CONST_CAST(void*)cd->pbkdf.type); free(CONST_CAST(void*)cd->pbkdf.hash); - crypt_free_type(cd); /* Some structures can contain keys (TCRYPT), wipe it */ crypt_memzero(cd, sizeof(*cd));