glibc/sysdeps
Mark Wielaard 9570bc53fc i386 TLS_INIT_TP might produce bogus asm changing stack pointer [BZ #17319]
TLS_INIT_TP in sysdeps/i386/nptl/tls.h uses some hand written asm to
generate a set_thread_area that might result in exchanging ebx and esp
around the syscall causing introspection tools like valgrind to loose
track of the user stack. Just use INTERNAL_SYSCALL which makes sure
esp isn't changed arbitrarily.

Before the patch the code would generate:

mov    $0xf3,%eax
movl   $0xfffff,0x8(%esp)
movl   $0x51,0xc(%esp)
xchg   %esp,%ebx
int    $0x80
xchg   %esp,%ebx

Using INTERNAL_SYSCALL instead will generate:

movl   $0xfffff,0x8(%esp)
movl   $0x51,0xc(%esp)
xchg   %ecx,%ebx
mov    $0xf3,%eax
int    $0x80
xchg   %ecx,%ebx

Thanks to Florian Weimer for analysing why the original code generated
the bogus esp usage:

  _segdescr.desc happens to be at the top of the stack, so its address
  is in %esp.  The asm statement says that %3 is an input, so its value
  will not change, and GCC can use %esp as the input register for the
  expression &_segdescr.desc.  But the constraints do not fully describe
  the asm statement because the %3 register is actually modified, albeit
  only temporarily.

	[BZ #17319]
	* sysdeps/i386/nptl/tls.h (TLS_INIT_TP): Use INTERNAL_SYSCALL
	to call set_thread_area instead of hand written asm.
	(__NR_set_thread_area): Removed define.
	(TLS_FLAG_WRITABLE): Likewise.
	(__ASSUME_SET_THREAD_AREA): Remove check.
	(TLS_EBX_ARG): Remove define.
	(TLS_LOAD_EBX): Likewise.
2014-08-28 09:53:08 +02:00
..
aarch64 Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30
alpha Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30
arm Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30
generic Add __safe_fatal and use it in __pthread_unwind forwarder fallback. 2014-07-31 14:00:33 -07:00
gnu Refactor handling of /lib64 etc. cases, move out of sysdeps/gnu/configure.ac. 2014-07-17 14:35:48 +00:00
hppa Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
i386 i386 TLS_INIT_TP might produce bogus asm changing stack pointer [BZ #17319] 2014-08-28 09:53:08 +02:00
ia64 IA64: Move NPTL public headers to sysdeps/ia64/nptl/. 2014-08-04 09:58:14 -04:00
ieee754 Fix missing <math_private.h> in ldbl-96 fma 2014-08-04 10:20:20 +02:00
init_array Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
m68k Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30
mach Simplify atomicity of socket creation in bind. 2014-08-28 00:46:44 +02:00
microblaze Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
mips Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
nptl Check value of futex before updating in __lll_timedlock 2014-08-12 12:57:27 +01:00
posix Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30
powerpc Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30
pthread Restore subdir conditional for tst-timer dependency. 2014-07-03 18:52:51 -07:00
s390 Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30
sh Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30
sparc Get rid of sparc specific NPTL internaltypes.h header. 2014-07-09 22:19:09 -07:00
tile Move architecture shlib-versions files to Linux-specific directories. 2014-07-17 14:31:12 +00:00
unix Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30
wordsize-32 Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
wordsize-64 Update copyright notices with scripts/update-copyrights 2014-01-01 22:00:23 +10:00
x86 Fix comment error that Jakub pointed out but I forgot to fix 2014-08-13 18:46:41 +05:30
x86_64 Remove unnecessary uses of NOT_IN_libc 2014-08-21 10:26:46 +05:30