linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Roel Kluin <roel.kluin@gmail.com>
To: paulus@samba.org, benh@kernel.crashing.org, linuxppc-dev@ozlabs.org
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] powerpc: Prevent unsigned wrap in htab_dt_scan_page_sizes()
Date: Wed, 14 Oct 2009 14:12:14 +0200	[thread overview]
Message-ID: <4AD5C01E.8000600@gmail.com> (raw)

Check to prevent unsigned wrap of size before subtraction.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Is this maybe better or are we certain that size can't wrap?

diff --git a/arch/powerpc/mm/hash_utils_64.c b/arch/powerpc/mm/hash_utils_64.c
index 1ade7eb..dd2d263 100644
--- a/arch/powerpc/mm/hash_utils_64.c
+++ b/arch/powerpc/mm/hash_utils_64.c
@@ -287,7 +287,7 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
 		DBG("Page sizes from device-tree:\n");
 		size /= 4;
 		cur_cpu_spec->cpu_features &= ~(CPU_FTR_16M_PAGE);
-		while(size > 0) {
+		while(size >= 3) {
 			unsigned int shift = prop[0];
 			unsigned int slbenc = prop[1];
 			unsigned int lpnum = prop[2];
@@ -296,7 +296,7 @@ static int __init htab_dt_scan_page_sizes(unsigned long node,
 			int idx = -1;
 
 			size -= 3; prop += 3;
-			while(size > 0 && lpnum) {
+			while(size >= 2 && lpnum) {
 				if (prop[0] == shift)
 					lpenc = prop[1];
 				prop += 2; size -= 2;

             reply	other threads:[~2009-10-14 12:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14 12:12 Roel Kluin [this message]
2009-10-14 21:29 ` [PATCH] powerpc: Prevent unsigned wrap in htab_dt_scan_page_sizes() Paul Mackerras

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=4AD5C01E.8000600@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=benh@kernel.crashing.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=paulus@samba.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).