All of lore.kernel.org
 help / color / mirror / Atom feed
From: enrico.scholz@sigma-chemnitz.de (Enrico Scholz)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: poison_init_mem: fixed underflow in loop
Date: Wed, 20 Feb 2013 12:52:55 +0100	[thread overview]
Message-ID: <1361361175-26600-1-git-send-email-enrico.scholz@sigma-chemnitz.de> (raw)

When initmemory ends at an odd address, the loop variable in
poison_init_mem() will underflow which causes overriding of valid
memory. Such situations are not a theoretical issue only but
exist in practice:

| [    0.000000]       .init : 0xc0634000 - 0xc0c215ab   (6070 kB)

Patch makes a simple division instead of DIV_ROUND_UP() because latter
can override some bytes after .init.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 arch/arm/mm/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index ad722f1..c431a2d 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -449,7 +449,8 @@ static inline int free_area(unsigned long pfn, unsigned long end, char *s)
 static inline void poison_init_mem(void *s, size_t count)
 {
 	u32 *p = (u32 *)s;
-	for (; count != 0; count -= 4)
+	count /= sizeof(*p);
+	for (; count != 0; count--)
 		*p++ = 0xe7fddef0;
 }
 
-- 
1.8.1.2

             reply	other threads:[~2013-02-20 11:52 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-20 11:52 Enrico Scholz [this message]
2013-02-20 21:56 ` [PATCH] ARM: poison_init_mem: fixed underflow in loop Stephen Boyd

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=1361361175-26600-1-git-send-email-enrico.scholz@sigma-chemnitz.de \
    --to=enrico.scholz@sigma-chemnitz.de \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.