Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: ld.elf_so i386 memcpy corruption - calligrawords hangs



Hi,

I have some concerns about the tls variant 2 implementation.

As it stands thread local storage will over write the tcb is this intentional 
or should it be like this:

Index: src/libexec/ld.elf_so/tls.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/tls.c,v
retrieving revision 1.7
diff -u -r1.7 tls.c
--- src/libexec/ld.elf_so/tls.c 23 Apr 2011 16:40:08 -0000      1.7
+++ src/libexec/ld.elf_so/tls.c 18 Oct 2013 05:08:26 -0000
@@ -142,7 +142,7 @@
 #ifdef __HAVE_TLS_VARIANT_I
                        q = p + obj->tlsoffset;
 #else
-                       q = p - obj->tlsoffset;
+                       q = p - obj->tlsoffset - obj->tlsinitsize;
 #endif
                        memcpy(q, obj->tlsinit, obj->tlsinitsize);
                        tcb->tcb_dtv[obj->tlsindex] = q;

that way the subsequent memcpy won't over write the tcb or should the tcb 
exist in the static space ie: 

Index: src/libexec/ld.elf_so/tls.c
===================================================================
RCS file: /cvsroot/src/libexec/ld.elf_so/tls.c,v
retrieving revision 1.7
diff -u -r1.7 tls.c
--- src/libexec/ld.elf_so/tls.c 23 Apr 2011 16:40:08 -0000      1.7
+++ src/libexec/ld.elf_so/tls.c 18 Oct 2013 05:21:12 -0000
@@ -128,8 +128,8 @@
        tcb = (struct tls_tcb *)p;
        p += sizeof(struct tls_tcb);
 #else
-       p += _rtld_tls_static_space;
        tcb = (struct tls_tcb *)p;
+       p += _rtld_tls_static_space;
        tcb->tcb_self = tcb;
 #endif
        tcb->tcb_dtv = xcalloc(sizeof(*tcb->tcb_dtv) * (2 + 
_rtld_tls_max_index));

I am just starting to read the documentation and as far as I know the 
allocation should not over write the tcb, but please let me know your 
comments and suggestions.

I was wondering if I made the first change which seem most applicable will I 
have to build the system again or is just building ld.elf_so sufficient.

Regards,

Nat.


Home | Main Index | Thread Index | Old Index