Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <f077a6d5-082c-c3a5-ce07-71b87a70dc12@linaro.org>
Date: Thu, 10 Dec 2020 14:51:23 -0300
From: Adhemerval Zanella <adhemerval.zanella@...aro.org>
To: Szabolcs Nagy <szabolcs.nagy@....com>, libc-alpha@...rceware.org
Cc: Mark Rutland <mark.rutland@....com>, kernel-hardening@...ts.openwall.com,
 Catalin Marinas <catalin.marinas@....com>, linux-kernel@...r.kernel.org,
 Jeremy Linton <jeremy.linton@....com>, Mark Brown <broonie@...nel.org>,
 Topi Miettinen <toiwoton@...il.com>, Will Deacon <will@...nel.org>,
 linux-arm-kernel@...ts.infradead.org
Subject: Re: [PATCH v2 1/6] aarch64: Fix missing BTI protection from
 dependencies [BZ #26926]



On 27/11/2020 10:19, Szabolcs Nagy via Libc-alpha wrote:
> The _dl_open_check and _rtld_main_check hooks are not called on the
> dependencies of a loaded module, so BTI protection was missed on
> every module other than the main executable and directly dlopened
> libraries.
> 
> The fix just iterates over dependencies to enable BTI.
> 
> Fixes bug 26926.

LGTM, modulus the argument name change.

I also think it would be better to add a testcase, for both DT_NEEDED
and dlopen case.

> ---
>  sysdeps/aarch64/dl-bti.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/sysdeps/aarch64/dl-bti.c b/sysdeps/aarch64/dl-bti.c
> index 196e462520..8f4728adce 100644
> --- a/sysdeps/aarch64/dl-bti.c
> +++ b/sysdeps/aarch64/dl-bti.c
> @@ -51,11 +51,24 @@ enable_bti (struct link_map *map, const char *program)
>    return 0;
>  }
>  
> -/* Enable BTI for L if required.  */
> +/* Enable BTI for MAP and its dependencies.  */
>  
>  void
> -_dl_bti_check (struct link_map *l, const char *program)
> +_dl_bti_check (struct link_map *map, const char *program)

I don't see much gain changing the argument name.

>  {
> -  if (GLRO(dl_aarch64_cpu_features).bti && l->l_mach.bti)
> -    enable_bti (l, program);
> +  if (!GLRO(dl_aarch64_cpu_features).bti)
> +    return;
> +
> +  if (map->l_mach.bti)
> +    enable_bti (map, program);
> +
> +  unsigned int i = map->l_searchlist.r_nlist;
> +  while (i-- > 0)
> +    {
> +      struct link_map *l = map->l_initfini[i];
> +      if (l->l_init_called)
> +	continue;
> +      if (l->l_mach.bti)
> +	enable_bti (l, program);
> +    }
>  }
> 

Ok.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.