grub-devel.gnu.org archive mirror
 help / color / mirror / Atom feed
From: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
To: Andrei Borzenkov <arvidjaar@gmail.com>,
	The development of GNU GRUB <grub-devel@gnu.org>
Cc: Juergen Gross <jgross@suse.com>,
	wei.liu2@citrix.com, keir@xen.org,
	Ian Campbell <ian.campbell@citrix.com>,
	Stefano Stabellini <stefano.stabellini@eu.citrix.com>,
	andrew.cooper3@citrix.com, Roy Franz <roy.franz@linaro.org>,
	"Sun, Ning" <ning.sun@intel.com>,
	david.vrabel@citrix.com, Jan Beulich <jbeulich@suse.com>,
	xen-devel@lists.xenproject.org, qiaowei.ren@intel.com,
	richard.l.maliszewski@intel.com, gang.wei@intel.com,
	Fu Wei <fu.wei@linaro.org>
Subject: Re: [PATCH v2 2/6] relocator: Do not use memory region if its starta is smaller than size
Date: Mon, 9 Nov 2015 19:44:23 +0100	[thread overview]
Message-ID: <5640E987.5080701@gmail.com> (raw)
In-Reply-To: <CAA91j0X_5N_=YeVHMJ-TCfQatR5xdYvXhxy+Ed+umEMUYaPdtQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2242 bytes --]

On 21.07.2015 08:42, Andrei Borzenkov wrote:
> On Mon, Jul 20, 2015 at 5:35 PM, Daniel Kiper <daniel.kiper@oracle.com> wrote:
>> 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 <daniel.kiper@oracle.com>
>> ---
>>  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)
> 
> That's too late, we need to check end of region on previous iteration.
> Consider region of 128 bytes, requested size 129 and alignment 256.
> Than starta still ends up high in memory.
> 
Agreed, we need a check earlier. It makes sense to split this block with
an if (from_low_priv) as both flows are completely separate and
splitting them will make it more readable
>>           {
>>             target = starta - size;
>>             if (target > end - size)
>> --
>> 1.7.10.4
>>
>>
>> _______________________________________________
>> Grub-devel mailing list
>> Grub-devel@gnu.org
>> https://lists.gnu.org/mailman/listinfo/grub-devel
> 



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

  reply	other threads:[~2015-11-09 18:44 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-20 14:35 [PATCH v2 0/6] multiboot2: Add two extensions and fix some issues Daniel Kiper
2015-07-20 14:35 ` [PATCH v2 1/6] gitignore: Ignore *.orig, *.rej and *.swp files Daniel Kiper
2015-08-11 17:00   ` Konrad Rzeszutek Wilk
2015-08-12  9:04   ` Ian Campbell
2015-11-04 12:03     ` Vladimir 'phcoder' Serbinenko
2015-11-09 15:29       ` Daniel Kiper
2015-11-09 15:34         ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-11-09 15:39           ` Daniel Kiper
2015-11-09 20:22             ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-07-20 14:35 ` [PATCH v2 2/6] relocator: Do not use memory region if its starta is smaller than size Daniel Kiper
2015-07-21  6:42   ` Andrei Borzenkov
2015-11-09 18:44     ` Vladimir 'φ-coder/phcoder' Serbinenko [this message]
2016-02-12 14:57   ` Vladimir 'φ-coder/phcoder' Serbinenko
2016-02-12 19:01     ` Daniel Kiper
2016-02-12 19:12       ` Vladimir 'phcoder' Serbinenko
2016-02-12 19:55         ` Daniel Kiper
2015-07-20 14:35 ` [PATCH v2 3/6] i386/relocator: Add grub_relocator64_efi relocator Daniel Kiper
2015-08-11 17:02   ` Konrad Rzeszutek Wilk
2015-11-09 20:05   ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-11-10 14:38     ` Daniel Kiper
2015-11-12 13:45       ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-07-20 14:35 ` [PATCH v2 4/6] multiboot2: Add tags used to pass ImageHandle to loaded image Daniel Kiper
2015-08-11 18:38   ` Konrad Rzeszutek Wilk
     [not found]     ` <CAEaD8JOPxLVECcUqjj2-x5AeXjbQ9Cd7bOaoe8UPU2t7wdoxpA@mail.gmail.com>
2015-11-09 19:12       ` Fwd: " Vladimir 'phcoder' Serbinenko
     [not found]   ` <CAEaD8JOaS=J22k+Sq=8Ou77pO6yvtgxSLiwuMjAoirSipJhW6g@mail.gmail.com>
2015-11-09 20:06     ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-07-20 14:35 ` [PATCH v2 5/6] multiboot2: Add support for relocatable images Daniel Kiper
2015-08-11 18:51   ` Konrad Rzeszutek Wilk
2015-11-09 20:08   ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-11-10 14:52     ` Daniel Kiper
     [not found]       ` <CAEaD8JMUUnSd7MMTANouZ1oQvYA00c49V8ENgUGUY+K8HcE_+Q@mail.gmail.com>
     [not found]         ` <20151112131555.GW26902@olila.local.net-space.pl>
2015-11-12 13:26           ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-11-12 13:33             ` Daniel Kiper
2015-07-20 14:35 ` [PATCH v2 6/6] multiboot2: Do not pass memory maps to image if EFI boot services are enabled Daniel Kiper
2015-08-11 18:59   ` Konrad Rzeszutek Wilk
2015-08-18 12:29     ` Daniel Kiper
2015-08-24 17:11 ` [PATCH v2 0/6] multiboot2: Add two extensions and fix some issues Daniel Kiper

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=5640E987.5080701@gmail.com \
    --to=phcoder@gmail.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=arvidjaar@gmail.com \
    --cc=david.vrabel@citrix.com \
    --cc=fu.wei@linaro.org \
    --cc=gang.wei@intel.com \
    --cc=grub-devel@gnu.org \
    --cc=ian.campbell@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jgross@suse.com \
    --cc=keir@xen.org \
    --cc=ning.sun@intel.com \
    --cc=qiaowei.ren@intel.com \
    --cc=richard.l.maliszewski@intel.com \
    --cc=roy.franz@linaro.org \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xenproject.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).