Bug 18383 - TLS blocks with very large alignment not handled right
Summary: TLS blocks with very large alignment not handled right
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: dynamic-link (show other bugs)
Version: 2.21
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-05-06 20:26 UTC by Roland McGrath
Modified: 2015-07-08 22:03 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Roland McGrath 2015-05-06 20:26:50 UTC
I'm going to add the test case to the test suite momentarily, so I won't
attach it here.

The test case contains:
	static __thread int tdata1 = 1;
	static __thread int tdata2 __attribute__ ((aligned (0x10))) = 2;
	static __thread int tdata3 __attribute__ ((aligned (0x1000))) = 4;
	static __thread int tbss1;
	static __thread int tbss2 __attribute__ ((aligned (0x10)));
	static __thread int tbss3 __attribute__ ((aligned (0x1000)));

On arm-linux-gnueabihf, tdata3 comes out with bad alignment and not
initialized with the right value and tbss3 comes out with bad alignment.
It's the same in the dynamic and static versions of the case.

On x86_64-linux-gnu, the dynamic version works right but the static version
crashes in startup.
Comment 1 Roland McGrath 2015-06-03 00:20:04 UTC
This now has test cases elf/tst-tlsalign{,-extern}{,-static} in the tree.
The ARM failures appear to be an assembler bug: https://sourceware.org/bugzilla/show_bug.cgi?id=18481

There are failures on x86 which are not yet explained.
Comment 2 Sourceware Commits 2015-06-24 23:32:01 UTC
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  a7fcc2f8edb26e4d54b6a740aaa3f3bb0caebd14 (commit)
      from  f9536db79065ad00efd877b4d80a1dd06938bd0a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=a7fcc2f8edb26e4d54b6a740aaa3f3bb0caebd14

commit a7fcc2f8edb26e4d54b6a740aaa3f3bb0caebd14
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Thu May 7 13:26:34 2015 -0700

    Align TCB offset to the maximum alignment
    
    We need to align TCB offset to the maximum alignment for TLS_TCB_AT_TP
    targets, as _dl_allocate_tls_storage (in elf/dl-tls.c) does using
    __libc_memalign and dl_tls_static_align.
    
    	[BZ #18383]
    	* csu/libc-tls.c (__libc_setup_tls) [TLS_TCB_AT_TP]: Align
    	TCB_OFFSET to MAX_ALIGN, not just TCBALIGN.  Add comment.
    	* elf/Makefile (test-xfail-tst-tlsalign{,-static}): Remove
    	comment for i386/x86-64.
    	(test-xfail-tst-tlsalign-extern-static): Removed.

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog      |    9 +++++++++
 csu/libc-tls.c |    5 ++++-
 elf/Makefile   |    5 +----
 3 files changed, 14 insertions(+), 5 deletions(-)
Comment 3 Roland McGrath 2015-07-08 22:03:08 UTC
The only known libc bug here was the x86 case shown fixed in comment#2.
The libc test suite now expects the ARM failures when the known assembler bug (bug #18481) is detected.