From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1ZHCBN-0002vf-R6 for mharc-grub-devel@gnu.org; Mon, 20 Jul 2015 10:36:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHCBL-0002vZ-2r for grub-devel@gnu.org; Mon, 20 Jul 2015 10:36:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZHCBH-0003iU-SN for grub-devel@gnu.org; Mon, 20 Jul 2015 10:36:39 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:17370) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZHCBH-0003iO-L2 for grub-devel@gnu.org; Mon, 20 Jul 2015 10:36:35 -0400 Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t6KEaTJ8017095 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 Jul 2015 14:36:29 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.13.8/8.13.8) with ESMTP id t6KEaT9G009850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Mon, 20 Jul 2015 14:36:29 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t6KEaSub002843; Mon, 20 Jul 2015 14:36:28 GMT Received: from olila.local.net-space.pl (/10.175.255.176) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 Jul 2015 07:36:28 -0700 From: Daniel Kiper To: xen-devel@lists.xenproject.org, grub-devel@gnu.org Subject: [PATCH v2 2/6] relocator: Do not use memory region if its starta is smaller than size Date: Mon, 20 Jul 2015 16:35:50 +0200 Message-Id: <1437402954-7375-3-git-send-email-daniel.kiper@oracle.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1437402954-7375-1-git-send-email-daniel.kiper@oracle.com> References: <1437402954-7375-1-git-send-email-daniel.kiper@oracle.com> X-Source-IP: userv0021.oracle.com [156.151.31.71] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 156.151.31.81 Cc: jgross@suse.com, keir@xen.org, ian.campbell@citrix.com, andrew.cooper3@citrix.com, stefano.stabellini@eu.citrix.com, roy.franz@linaro.org, ning.sun@intel.com, david.vrabel@citrix.com, jbeulich@suse.com, phcoder@gmail.com, wei.liu2@citrix.com, qiaowei.ren@intel.com, richard.l.maliszewski@intel.com, gang.wei@intel.com, fu.wei@linaro.org X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 20 Jul 2015 14:36:40 -0000 malloc_in_range() should not use memory region if its starta is smaller than size. Otherwise target wraps around and points to region which is usually not a RAM, e.g.: loader/multiboot.c:93: segment 0: paddr=0x800000, memsz=0x3f800000, vaddr=0x800000 lib/relocator.c:1241: min_addr = 0x0, max_addr = 0xffffffffffffffff, target = 0x800000 lib/relocator.c:434: trying to allocate in 0x800000-0xffffffffffffffff aligned 0x1 size 0x3f800000 lib/relocator.c:434: trying to allocate in 0x0-0x800000 aligned 0x1 size 0x3f800000 lib/relocator.c:434: trying to allocate in 0x0-0xffffffffffffffff aligned 0x1 size 0x3f800000 lib/relocator.c:1188: allocated: 0xffffffffc07fffff+0x3f800000 lib/relocator.c:1277: allocated 0xffffffffc07fffff/0x800000 Signed-off-by: Daniel Kiper --- grub-core/lib/relocator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/lib/relocator.c b/grub-core/lib/relocator.c index f759c7f..4eee0c5 100644 --- a/grub-core/lib/relocator.c +++ b/grub-core/lib/relocator.c @@ -748,7 +748,7 @@ malloc_in_range (struct grub_relocator *rel, /* Found an usable address. */ goto found; } - if (isinsidebefore && !isinsideafter && !from_low_priv) + if (isinsidebefore && !isinsideafter && !from_low_priv && starta >= size) { target = starta - size; if (target > end - size) -- 1.7.10.4