[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen master] xen: arm: Avoid reading beyond the last module



commit 04425e40b427d9f0469d9db9321839d434a3580b
Author:     Chris (Christopher) Brand <chris.brand@xxxxxxxxxxxx>
AuthorDate: Fri Jul 17 20:48:08 2015 +0000
Commit:     Ian Campbell <ian.campbell@xxxxxxxxxx>
CommitDate: Tue Jul 21 15:08:07 2015 +0100

    xen: arm: Avoid reading beyond the last module
    
    nr_mods is set in add_boot_module() to the number of module
    array elements used. This function also ensures that nr_mods
    never exceeds MAX_MODULES (the size of the array). When looping
    through the array, the correct maximum index is "nr_mods-1",
    not "nr_mods". If the array is full, using the latter will in
    fact access beyond the end of the array.
    This was done correctly in boot_module_find_by_kind() and
    consider_modules() but incorrectly in discard_initial_modules()
    and next_module().
    
    Signed-off-by: Chris Brand <chris.brand@xxxxxxxxxxxx>
    Reviewed-by: Julien Grall <julien.grall@xxxxxxxxxx>
    Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
---
 xen/arch/arm/setup.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index a46c583..6626eba 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -250,7 +250,7 @@ void __init discard_initial_modules(void)
     struct bootmodules *mi = &bootinfo.modules;
     int i;
 
-    for ( i = 0; i <= mi->nr_mods; i++ )
+    for ( i = 0; i < mi->nr_mods; i++ )
     {
         paddr_t s = mi->module[i].start;
         paddr_t e = s + PAGE_ALIGN(mi->module[i].size);
@@ -350,7 +350,7 @@ static paddr_t __init next_module(paddr_t s, paddr_t *end)
     paddr_t lowest = ~(paddr_t)0;
     int i;
 
-    for ( i = 0; i <= mi->nr_mods; i++ )
+    for ( i = 0; i < mi->nr_mods; i++ )
     {
         paddr_t mod_s = mi->module[i].start;
         paddr_t mod_e = mod_s + mi->module[i].size;
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.