]> git.baikalelectronics.ru Git - arm-tf.git/commitdiff
fix(el3-spmc): fix detection of overlapping memory regions
authorMarc Bonnici <marc.bonnici@arm.com>
Tue, 18 Oct 2022 12:50:04 +0000 (13:50 +0100)
committerJoanna Farley <joanna.farley@arm.com>
Mon, 7 Nov 2022 13:39:26 +0000 (14:39 +0100)
The current logic does not cover all scenarios of overlapping
memory regions. Update the implementation to verify non-overlapping
regions instead. Reported by Matt Oh, Google Android Red Team.

Reported-by: mattoh@google.com
Signed-off-by: Marc Bonnici <marc.bonnici@arm.com>
Change-Id: I16c53d081e4455bc0e28399d28a1b27b1a9eb49c

services/std_svc/spm/el3_spmc/spmc_shared_mem.c

index f7911b9b31efaeea950bbaba7faf7f5e86ffa0e5..6f6d273d6b38ccdaf32f50febdff07709b274508 100644 (file)
@@ -330,10 +330,9 @@ overlapping_memory_regions(struct ffa_comp_mrd *region1,
                                PAGE_SIZE_4KB;
                        region2_end = region2_start + region2_size;
 
-                       if ((region1_start >= region2_start &&
-                            region1_start < region2_end) ||
-                           (region1_end > region2_start
-                            && region1_end < region2_end)) {
+                       /* Check if regions are not overlapping. */
+                       if (!((region2_end <= region1_start) ||
+                             (region1_end <= region2_start))) {
                                WARN("Overlapping mem regions 0x%lx-0x%lx & 0x%lx-0x%lx\n",
                                     region1_start, region1_end,
                                     region2_start, region2_end);