From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Richard Henderson <richard.henderson@linaro.org>, qemu-devel@nongnu.org
Cc: alex.bennee@linaro.org, Laurent Vivier <laurent@vivier.eu>
Subject: Re: [PATCH for-8.0 v2 10/12] linux-user: Pass last not end to probe_guest_base
Date: Tue, 28 Mar 2023 19:53:51 +0200 [thread overview]
Message-ID: <85bbdb2a-6c3c-1982-3f00-a2217fb8b971@linaro.org> (raw)
In-Reply-To: <81ceba14-5003-4215-8f61-54c57fbc3378@linaro.org>
On 28/3/23 19:47, Richard Henderson wrote:
> On 3/28/23 06:51, Philippe Mathieu-Daudé wrote:
>> Hi Richard,
>>
>> On 27/3/23 23:18, Richard Henderson wrote:
>>> Pass the address of the last byte of the image, rather than
>>> the first address past the last byte. This avoids overflow
>>> when the last page of the address space is involved.
>>>
>>> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>>> ---
>>> linux-user/elfload.c | 24 ++++++++++++------------
>>> linux-user/flatload.c | 2 +-
>>> 2 files changed, 13 insertions(+), 13 deletions(-)
>>> index e99570ca18..5efec2630e 100644
>>> --- a/linux-user/flatload.c
>>> +++ b/linux-user/flatload.c
>>> @@ -448,7 +448,7 @@ static int load_flat_file(struct linux_binprm *
>>> bprm,
>>> * Allocate the address space.
>>> */
>>> probe_guest_base(bprm->filename, 0,
>>> - text_len + data_len + extra + indx_len);
>>> + text_len + data_len + extra + indx_len - 1);
>>
>> Per linux-user/user-internals.h:
>>
>> /**
>> * probe_guest_base:
>> * @image_name: the executable being loaded
>> * @loaddr: the lowest fixed address in the executable
>> * @hiaddr: the highest fixed address in the executable
>> *
>> * Creates the initial guest address space in the host memory space.
>> *
>> * If @loaddr == 0, then no address in the executable is fixed,
>> * i.e. it is fully relocatable. In that case @hiaddr is the size
>> * of the executable.
>> *
>> * This function will not return if a valid value for guest_base
>> * cannot be chosen. On return, the executable loader can expect
>> *
>> * target_mmap(loaddr, hiaddr - loaddr, ...)
>> *
>> * to succeed.
>> */
>>
>> Since here @loaddr == 0, "@hiaddr is the size of the executable",
>> not "the first address past the last byte".
>>
>> So we can not "Pass the address of the last byte of the image"
>> to this API. Maybe the API description is incorrect, in that
>> case your patch is right. Otherwise we might need to tune
>> probe_guest_base().
>
> I'll update the documentation.
Then:
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
next prev parent reply other threads:[~2023-03-28 17:54 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-27 21:18 [PATCH for-8.0 v2 00/12] tcg patch queue Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 01/12] util: import GTree as QTree Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 02/12] tcg: use QTree instead of GTree Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 03/12] linux-user: Diagnose misaligned -R size Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 04/12] accel/tcg: Pass last not end to page_set_flags Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 05/12] accel/tcg: Pass last not end to page_reset_target_data Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 06/12] accel/tcg: Pass last not end to PAGE_FOR_EACH_TB Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 07/12] accel/tcg: Pass last not end to page_collection_lock Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 08/12] accel/tcg: Pass last not end to tb_invalidate_phys_page_range__locked Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 09/12] accel/tcg: Pass last not end to tb_invalidate_phys_range Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 10/12] linux-user: Pass last not end to probe_guest_base Richard Henderson
2023-03-28 13:51 ` Philippe Mathieu-Daudé
2023-03-28 17:47 ` Richard Henderson
2023-03-28 17:53 ` Philippe Mathieu-Daudé [this message]
2023-03-27 21:18 ` [PATCH for-8.0 v2 11/12] include/exec: Change reserved_va semantics to last byte Richard Henderson
2023-03-27 21:18 ` [PATCH for-8.0 v2 12/12] linux-user/arm: Take more care allocating commpage Richard Henderson
2023-03-28 18:19 ` Philippe Mathieu-Daudé
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=85bbdb2a-6c3c-1982-3f00-a2217fb8b971@linaro.org \
--to=philmd@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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).