ion: Forbid multi-VMID allocation requests for the secure system heap

The secure system heap does not support multi-VMID allocations,
so do not allow them. Also, fortify the secure allocation check
for the system heap allocation path.

Change-Id: I51d53274c2374632db778461ba7505de4d723439
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
This commit is contained in:
Isaac J. Manjarres 2020-04-14 12:03:41 -07:00
commit 90e8284897
2 changed files with 3 additions and 2 deletions

View file

@ -288,7 +288,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap,
return -ENOMEM;
if (ion_heap_is_system_heap_type(buffer->heap->type) &&
is_secure_vmid_valid(vmid)) {
is_secure_allocation(buffer->flags)) {
pr_info("%s: System heap doesn't support secure allocations\n",
__func__);
return -EINVAL;

View file

@ -79,9 +79,10 @@ static int ion_system_secure_heap_allocate(struct ion_heap *heap,
struct ion_system_secure_heap *secure_heap =
to_system_secure_heap(heap);
enum ion_heap_type type = secure_heap->heap.ion_heap.type;
unsigned long cp_flags = buffer->flags & ION_FLAGS_CP_MASK;
if (!ion_heap_is_system_secure_heap_type(type) ||
!is_cp_flag_present(flags)) {
!is_cp_flag_present(flags) || (hweight_long(cp_flags) != 1)) {
pr_info("%s: Incorrect heap type or incorrect flags\n",
__func__);
return -EINVAL;