glibc:hjl/pr22715/2.25

Last commit made on 2018-01-17
Get this branch:
git clone -b hjl/pr22715/2.25 https://git.launchpad.net/glibc

Branch merges

Branch information

Name:
hjl/pr22715/2.25
Repository:
lp:glibc

Recent commits

a802568... by "H.J. Lu" <email address hidden> on 2018-01-16

x86-64: Properly align La_x86_64_retval to VEC_SIZE [BZ #22715]

_dl_runtime_profile calls _dl_call_pltexit, passing a pointer to
La_x86_64_retval which is allocated on stack. The lrv_vector0
field in La_x86_64_retval must be aligned to size of vector register.
When allocating stack space for La_x86_64_retval, we need to make sure
that the address of La_x86_64_retval + RV_VECTOR0_OFFSET is aligned to
VEC_SIZE. This patch checks the alignment of the lrv_vector0 field
and pads the stack space if needed.

Tested with x32 and x86-64 on SSE4, AVX and AVX512 machines. It fixed

FAIL: elf/tst-audit10
FAIL: elf/tst-audit4
FAIL: elf/tst-audit5
FAIL: elf/tst-audit6
FAIL: elf/tst-audit7

on x32 AVX512 machine.

(cherry picked from commit 207a72e2988c6d6343f50fe0128eb4fc4edfdd15)

 [BZ #22715]
 * sysdeps/x86_64/dl-trampoline.h (_dl_runtime_profile): Properly
 align La_x86_64_retval to VEC_SIZE.

edcf13e... by Florian Weimer on 2018-01-16

nptl/tst-thread-exit-clobber: Run with any C++ compiler

We do not need thread_local support in the C++11 comiler, and the
minimum GCC version for glibc has C++11 support (if it has C++ support).

(cherry picked from commit 10d200dbace0ea5198006b313f40c3b884c88724)

abf2e34... by Florian Weimer on 2018-01-11

csu: Update __libgcc_s_init comment

Reviewed-by: Carlos O'Donell <email address hidden>
(cherry picked from commit 08c6e95234c60a5c2f37532d1111acf084f39345)

8343b9d... by Florian Weimer on 2018-01-16

nptl/tst-minstack-throw: Compile in C++11 mode with GNU extensions

(cherry picked from commit b725132d2b0aeddf970b1ce3e5a24f8637a7b4c2)

ea2da72... by Florian Weimer on 2018-01-15

nptl: Add PTHREAD_MIN_STACK C++ throw test [BZ #22636]

(cherry picked from commit 860b0240a5645edd6490161de3f8d1d1f2786025)

41acd32... by Florian Weimer on 2018-01-11

nptl: Add tst-minstack-cancel, tst-minstack-exit [BZ #22636]

I verified that without the guard accounting change in commit
630f4cc3aa019ede55976ea561f1a7af2f068639 (Fix stack guard size
accounting) and RTLD_NOW for libgcc_s introduced by commit
f993b8754080ac7572b692870e926d8b493db16c (nptl: Open libgcc.so with
RTLD_NOW during pthread_cancel), the tst-minstack-cancel test fails on
an AVX-512F machine. tst-minstack-exit still passes, and either of
the mentioned commit by itself frees sufficient stack space to make
tst-minstack-cancel pass, too.

Reviewed-by: Carlos O'Donell <email address hidden>
(cherry picked from commit d8b778907e5270fdeb70459842ffbc20bd2ca5e1)

3e75e67... by Florian Weimer on 2018-01-15

nptl: Open libgcc.so with RTLD_NOW during pthread_cancel [BZ #22636]

Disabling lazy binding reduces stack usage during unwinding.

Note that RTLD_NOW only makes a difference if libgcc.so has not
already been loaded, so this is only a partial fix.

Reviewed-by: Adhemerval Zanella <email address hidden>
(cherry picked from commit f993b8754080ac7572b692870e926d8b493db16c)

5d4c589... by Szabolcs Nagy <email address hidden> on 2018-01-15

[BZ #22637] Fix stack guard size accounting

Previously if user requested S stack and G guard when creating a
thread, the total mapping was S and the actual available stack was
S - G - static_tls, which is not what the user requested.

This patch fixes the guard size accounting by pretending the user
requested S+G stack. This way all later logic works out except
when reporting the user requested stack size (pthread_getattr_np)
or when computing the minimal stack size (__pthread_get_minstack).

Normally this will increase thread stack allocations by one page.
TLS accounting is not affected, that will require a separate fix.

 [BZ #22637]
 * nptl/descr.h (stackblock, stackblock_size): Update comments.
 * nptl/allocatestack.c (allocate_stack): Add guardsize to stacksize.
 * nptl/nptl-init.c (__pthread_get_minstack): Remove guardsize from
 stacksize.
 * nptl/pthread_getattr_np.c (pthread_getattr_np): Likewise.

(cherry picked from commit 630f4cc3aa019ede55976ea561f1a7af2f068639)

aedc861... by Florian Weimer on 2018-01-08

nptl: Add test for callee-saved register restore in pthread_exit

GCC PR 83641 results in a miscompilation of libpthread, which
causes pthread_exit not to restore callee-saved registers before
running destructors for objects on the stack. This test detects
this situation:

info: unsigned int, direct pthread_exit call
tst-thread-exit-clobber.cc:80: numeric comparison failure
   left: 4148288912 (0xf741dd90); from: value
  right: 1600833940 (0x5f6ac994); from: magic_values.v2
info: double, direct pthread_exit call
info: unsigned int, indirect pthread_exit call
info: double, indirect pthread_exit call
error: 1 test failures

(cherry picked from commit 579396ee082565ab5f42ff166a264891223b7b82)

771c846... by Dmitry V. Levin on 2018-01-07

linux: make getcwd(3) fail if it cannot obtain an absolute path [BZ #22679]

Currently getcwd(3) can succeed without returning an absolute path
because the underlying getcwd syscall, starting with linux commit
v2.6.36-rc1~96^2~2, may succeed without returning an absolute path.

This is a conformance issue because "The getcwd() function shall
place an absolute pathname of the current working directory
in the array pointed to by buf, and return buf".

This is also a security issue because a non-absolute path returned
by getcwd(3) causes a buffer underflow in realpath(3).

Fix this by checking the path returned by getcwd syscall and falling
back to generic_getcwd if the path is not absolute, effectively making
getcwd(3) fail with ENOENT. The error code is chosen for consistency
with the case when the current directory is unlinked.

[BZ #22679]
CVE-2018-1000001
* sysdeps/unix/sysv/linux/getcwd.c (__getcwd): Fall back to
generic_getcwd if the path returned by getcwd syscall is not absolute.
* io/tst-getcwd-abspath.c: New test.
* io/Makefile (tests): Add tst-getcwd-abspath.

(cherry picked from commit 52a713fdd0a30e1bd79818e2e3c4ab44ddca1a94)