]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
xen/eemi: proper bounds checks
authorStefano Stabellini <stefano.stabellini@xilinx.com>
Mon, 24 Sep 2018 23:07:33 +0000 (16:07 -0700)
committerStefano Stabellini <sstabellini@kernel.org>
Wed, 4 Dec 2019 23:58:09 +0000 (15:58 -0800)
ARRAY_SIZE(pm_node_access) and ARRAY_SIZE(pm_reset_access) are out of
bounds for indexes. addr == end in pm_mmio_access is also not valid.

Signed-off-by: Stefano Stabellini <stefanos@xilinx.com>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
xen/arch/arm/platforms/xilinx-zynqmp-eemi.c

index 44837bb48bdc833dd7cad45d4a4141606769b821..f729287c613765b4222a500b1db1688249e215a2 100644 (file)
@@ -570,7 +570,7 @@ static bool pm_check_access(const struct pm_access *acl, struct domain *d, int i
 /* Check if a domain has access to a node.  */
 static bool domain_has_node_access(struct domain *d, enum pm_node_id node)
 {
-    if ( node < 0 || node > ARRAY_SIZE(pm_node_access) )
+    if ( node < 0 || node >= ARRAY_SIZE(pm_node_access) )
         return false;
 
     /* NODE_UNKNOWN is treated as a wildcard.  */
@@ -585,7 +585,7 @@ static bool domain_has_reset_access(struct domain *d, enum pm_reset rst)
 {
     int rst_idx = PM_RESET_IDX(rst);
 
-    if ( rst_idx < 0 || rst_idx > ARRAY_SIZE(pm_reset_access) )
+    if ( rst_idx < 0 || rst_idx >= ARRAY_SIZE(pm_reset_access) )
         return false;
 
     return pm_check_access(pm_reset_access, d, rst_idx);
@@ -623,7 +623,7 @@ static bool domain_mediate_mmio_access(struct domain *d,
             /* Memory range.  */
             if ( addr < pm_mmio_access[i].start )
                 continue;
-            if ( addr > pm_mmio_access[i].end )
+            if ( addr >= pm_mmio_access[i].end )
                 continue;
         } else {
             /* Single register.  */