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