1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-01-03 05:18:29 +03:00

device_mapper: zero only secure buffers

Securely erase before free() only dm_tasks marked as secure_data.
TODO: think about also using this for libdm/.
This commit is contained in:
Zdenek Kabelac 2021-02-27 17:08:26 +01:00
parent 00531186fc
commit 73bea16c92

View File

@ -493,7 +493,10 @@ static void _dm_task_free_targets(struct dm_task *dmt)
for (t = dmt->head; t; t = n) { for (t = dmt->head; t; t = n) {
n = t->next; n = t->next;
_dm_zfree_string(t->params); if (dmt->secure_data)
_dm_zfree_string(t->params);
else
free(t->params);
free(t->type); free(t->type);
free(t); free(t);
} }
@ -504,7 +507,10 @@ static void _dm_task_free_targets(struct dm_task *dmt)
void dm_task_destroy(struct dm_task *dmt) void dm_task_destroy(struct dm_task *dmt)
{ {
_dm_task_free_targets(dmt); _dm_task_free_targets(dmt);
_dm_zfree_dmi(dmt->dmi.v4); if (dmt->secure_data)
_dm_zfree_dmi(dmt->dmi.v4);
else
free(dmt->dmi.v4);
free(dmt->dev_name); free(dmt->dev_name);
free(dmt->mangled_dev_name); free(dmt->mangled_dev_name);
free(dmt->newname); free(dmt->newname);