From: "Chris (Christopher) Brand" <chris.brand@broadcom.com>
To: "xen-devel@lists.xen.org" <xen-devel@lists.xen.org>
Cc: Julien Grall <julien.grall@citrix.com>,
Ian Campbell <ian.campbell@citrix.com>,
Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Subject: [PATCH] xen: arm: Avoid reading beyond the last module
Date: Fri, 17 Jul 2015 20:48:08 +0000 [thread overview]
Message-ID: <4EE5B48738DDED408878C97C8E050A8B1D7D4CE3@SJEXCHMB05.corp.ad.broadcom.com> (raw)
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@broadcom.com>
---
xen/arch/arm/setup.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 06f8e54b1f04..5daa6db919ac 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;
--
1.9.1
next reply other threads:[~2015-07-17 20:48 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-17 20:48 Chris (Christopher) Brand [this message]
2015-07-20 12:32 ` [PATCH] xen: arm: Avoid reading beyond the last module Julien Grall
2015-07-21 14:49 ` Ian Campbell
-- strict thread matches above, loose matches on Subject: below --
2015-07-16 21:41 Chris (Christopher) Brand
2015-07-17 10:14 ` Julien Grall
2015-07-17 22:15 ` Chris (Christopher) Brand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EE5B48738DDED408878C97C8E050A8B1D7D4CE3@SJEXCHMB05.corp.ad.broadcom.com \
--to=chris.brand@broadcom.com \
--cc=ian.campbell@citrix.com \
--cc=julien.grall@citrix.com \
--cc=stefano.stabellini@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).