ion: Ensure secure HLOS accessible buffers are zeroed when allocated

Memory that is either pooled or permanently assigned to other VMIDs
is not always cleared when it is released back into the pools. This
is problematic when the memory is assigned such that HLOS can still
access the memory, as a userspace process can reallocate the
same buffer, and read data from when the buffer was previously
allocated. Thus, clear secure ION buffers before freeing them, if
they are HLOS accessible.

Change-Id: Iaae14fc32b10e0c6afca007a5ee78aacd5e013e6
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
This commit is contained in:
Isaac J. Manjarres 2020-04-16 10:08:05 -07:00
commit 3d85b42ad1
2 changed files with 3 additions and 1 deletions

View file

@ -379,6 +379,8 @@ static void ion_sc_heap_free(struct ion_buffer *buffer)
return;
}
if (hlos_accessible_buffer(buffer))
ion_buffer_zero(buffer);
ion_carveout_free(child, paddr, buffer->size);
sg_free_table(table);
kfree(table);

View file

@ -426,7 +426,7 @@ void ion_system_heap_free(struct ion_buffer *buffer)
if (!(buffer->private_flags & ION_PRIV_FLAG_SHRINKER_FREE) &&
!(buffer->flags & ION_FLAG_POOL_FORCE_ALLOC)) {
if (vmid < 0)
if (hlos_accessible_buffer(buffer))
ion_buffer_zero(buffer);
} else if (vmid > 0) {
if (ion_hyp_unassign_sg(table, &vmid, 1, true))