From patchwork Wed Oct 14 12:12:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: roel kluin X-Patchwork-Id: 35956 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from bilbo.ozlabs.org (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 71ED3B7DE6 for ; Wed, 14 Oct 2009 23:03:00 +1100 (EST) Received: by ozlabs.org (Postfix) id D7136B7334; Wed, 14 Oct 2009 23:02:53 +1100 (EST) Delivered-To: linuxppc-dev@ozlabs.org Received: from mail-ew0-f214.google.com (mail-ew0-f214.google.com [209.85.219.214]) by ozlabs.org (Postfix) with ESMTP id 262EBB7B74 for ; Wed, 14 Oct 2009 23:02:52 +1100 (EST) Received: by ewy10 with SMTP id 10so11160382ewy.9 for ; Wed, 14 Oct 2009 05:02:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:content-type :content-transfer-encoding; bh=zLdjsJVMTDpsTXw8V9CuLIs+B33aJ5DOSH/Ux4T1hIE=; b=tZoG8MXXMoa1qyN5KUr+2PgHcT6kjRWUxlK7zOqbwTTENf41W6LnfMFBeyF7vpmFXC M2FzN7DZ9f6VUmXrJhbsRipqYoKyghPcnPrG0VEeZQk1TSaPHrcz9+93gkeDaX3CZL5h MO+5cfLR/GjT5H+UFCjwb92epiz4ROd/VIffA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=uwmghHYQWEyQXXs4rQH0PyxljrXXNeHpwGnnvKP5mNtldrrPszH1yP/qbQOQWpQxMs 69OQzYYqgHHIycPaEPckNln/zbRveZdWZNBEELpxZO2+qQ5rtonisjEG6Z5D3LFw9r7l M/dgSpSI9hmtKBAfu6cGkePZ1tma4/BoeaYzw= Received: by 10.216.89.80 with SMTP id b58mr1070779wef.73.1255521769948; Wed, 14 Oct 2009 05:02:49 -0700 (PDT) Received: from zoinx.mars (d133062.upc-d.chello.nl [213.46.133.62]) by mx.google.com with ESMTPS id 7sm2113633eyg.35.2009.10.14.05.02.47 (version=SSLv3 cipher=RC4-MD5); Wed, 14 Oct 2009 05:02:48 -0700 (PDT) Message-ID: <4AD5C01E.8000600@gmail.com> Date: Wed, 14 Oct 2009 14:12:14 +0200 From: Roel Kluin User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.4pre) Gecko/20090922 Fedora/3.0-2.7.b4.fc11 Thunderbird/3.0b4 MIME-Version: 1.0 To: paulus@samba.org, benh@kernel.crashing.org, linuxppc-dev@ozlabs.org Subject: [PATCH] powerpc: Prevent unsigned wrap in htab_dt_scan_page_sizes() Cc: Andrew Morton X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Errors-To: linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org Check to prevent unsigned wrap of size before subtraction. Signed-off-by: Roel Kluin Acked-by: Paul Mackerras --- 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;