git: 613a08cfa2e0 - main - rtld: map without PROT_EXEC for relocation

Jessica Clarke jrtc27 at freebsd.org
Tue Jan 5 16:04:13 UTC 2021


On 5 Jan 2021, at 15:57, Ed Maste <emaste at FreeBSD.org> wrote:
> diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c
> index 27262ab9dbc5..7b8bfba84d7d 100644
> --- a/libexec/rtld-elf/rtld.c
> +++ b/libexec/rtld-elf/rtld.c
> @@ -2982,7 +2982,8 @@ reloc_textrel_prot(Obj_Entry *obj, bool before)
> 		base = obj->relocbase + trunc_page(ph->p_vaddr);
> 		sz = round_page(ph->p_vaddr + ph->p_filesz) -
> 		    trunc_page(ph->p_vaddr);
> -		prot = convert_prot(ph->p_flags) | (before ? PROT_WRITE : 0);
> +		prot = before ? (PROT_READ | PROT_WRITE) :
> +		    convert_prot(ph->p_flags);
> 		if (mprotect(base, sz, prot) == -1) {
> 			_rtld_error("%s: Cannot write-%sable text segment: %s",
> 			    obj->path, before ? "en" : "dis",

This error message could perhaps be improved now that both W and X are
varying? As it stands it reads like the code used to function.

Jess



More information about the dev-commits-src-all mailing list