qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] linux-user: Correctly start brk after executable


From: Laurent Vivier
Subject: Re: [PATCH] linux-user: Correctly start brk after executable
Date: Sat, 5 Sep 2020 22:51:55 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

Le 29/07/2020 à 00:46, Timothy E Baldwin a écrit :
> info->brk was erroneously set to the end of highest addressed
> writable segment which could result it in overlapping the executable.
> 
> As per load_elf_binary in fs/binfmt_elf.c in Linux, it should be
> set to end of highest addressed segment.
> 
> Signed-off-by: Timothy E Baldwin <T.E.Baldwin99@members.leeds.ac.uk>
> ---
>  linux-user/elfload.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/linux-user/elfload.c b/linux-user/elfload.c
> index 7e7f642332..d5d444f698 100644
> --- a/linux-user/elfload.c
> +++ b/linux-user/elfload.c
> @@ -2564,9 +2564,9 @@ static void load_elf_image(const char *image_name, int 
> image_fd,
>                  if (vaddr_ef > info->end_data) {
>                      info->end_data = vaddr_ef;
>                  }
> -                if (vaddr_em > info->brk) {
> -                    info->brk = vaddr_em;
> -                }
> +            }
> +            if (vaddr_em > info->brk) {
> +                info->brk = vaddr_em;
>              }
>          } else if (eppnt->p_type == PT_INTERP && pinterp_name) {
>              char *interp_name;
> @@ -2621,7 +2621,6 @@ static void load_elf_image(const char *image_name, int 
> image_fd,
>      if (info->end_data == 0) {
>          info->start_data = info->end_code;
>          info->end_data = info->end_code;
> -        info->brk = info->end_code;
>      }
>  
>      if (qemu_log_enabled()) {
> 

Applied to my linux-user-for-5.2 branch.

Thanks,
Laurent





reply via email to

[Prev in Thread] Current Thread [Next in Thread]