diff mbox series

[05/15] elf: Fix a DTV setup issue [BZ #27136]

Message ID 49bb4560b2afb4174c7086e24b0fb7be9d73ab5d.1613390045.git.szabolcs.nagy@arm.com
State Superseded
Delegated to: Adhemerval Zanella Netto
Headers show
Series Dynamic TLS related data race fixes | expand

Commit Message

Szabolcs Nagy Feb. 15, 2021, 11:59 a.m. UTC
The max modid is a valid index in the dtv, it should not be skipped.

The bug is observable if the last module has modid == 64 and its
generation is same or less than the max generation of the previous
modules.  Then dtv[0].counter implies dtv[64] is initialized but
it isn't. Fixes bug 27136.
---
 elf/dl-tls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Adhemerval Zanella April 2, 2021, 7:46 p.m. UTC | #1
On 15/02/2021 08:59, Szabolcs Nagy via Libc-alpha wrote:
> The max modid is a valid index in the dtv, it should not be skipped.
> 
> The bug is observable if the last module has modid == 64 and its
> generation is same or less than the max generation of the previous
> modules.  Then dtv[0].counter implies dtv[64] is initialized but
> it isn't. Fixes bug 27136.

LGTM, thank. 

I think it would be better to either squash the testcase into this patch
(which would require to rework the testcase make rules, since it uses
the objects from B#19329) or move the test after this patch.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  elf/dl-tls.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/elf/dl-tls.c b/elf/dl-tls.c
> index dd76829e74..79b93ad91b 100644
> --- a/elf/dl-tls.c
> +++ b/elf/dl-tls.c
> @@ -590,7 +590,7 @@ _dl_allocate_tls_init (void *result)
>  	}
>  
>        total += cnt;
> -      if (total >= GL(dl_tls_max_dtv_idx))
> +      if (total > GL(dl_tls_max_dtv_idx))
>  	break;
>  
>        listp = listp->next;
> 

Ok, it align on how dl_tls_max_dtv_idx is used on this file
(such as _dl_count_modids).
diff mbox series

Patch

diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index dd76829e74..79b93ad91b 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -590,7 +590,7 @@  _dl_allocate_tls_init (void *result)
 	}
 
       total += cnt;
-      if (total >= GL(dl_tls_max_dtv_idx))
+      if (total > GL(dl_tls_max_dtv_idx))
 	break;
 
       listp = listp->next;