6c0556
commit d2b997c7172e9a00895a9deb379f8782fbd2e36f
6c0556
Author: Szabolcs Nagy <szabolcs.nagy@arm.com>
6c0556
Date:   Wed Dec 30 23:40:14 2020 +0000
6c0556
6c0556
    elf: Fix a DTV setup issue [BZ #27136]
6c0556
    
6c0556
    The max modid is a valid index in the dtv, it should not be skipped.
6c0556
    
6c0556
    The bug is observable if the last module has modid == 64 and its
6c0556
    generation is same or less than the max generation of the previous
6c0556
    modules.  Then dtv[0].counter implies dtv[64] is initialized but
6c0556
    it isn't. Fixes bug 27136.
6c0556
    
6c0556
    Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
6c0556
6c0556
diff --git a/elf/dl-tls.c b/elf/dl-tls.c
6c0556
index cccf74b33481b866..0b96b1dceed99d58 100644
6c0556
--- a/elf/dl-tls.c
6c0556
+++ b/elf/dl-tls.c
6c0556
@@ -590,7 +590,7 @@ _dl_allocate_tls_init (void *result)
6c0556
 	}
6c0556
 
6c0556
       total += cnt;
6c0556
-      if (total >= GL(dl_tls_max_dtv_idx))
6c0556
+      if (total > GL(dl_tls_max_dtv_idx))
6c0556
 	break;
6c0556
 
6c0556
       listp = listp->next;