about summary refs log tree commit diff
Commit message (Collapse)AuthorAgeFilesLines
* nptl: Move pthread_getattr_default_np into libcFlorian Weimer2021-05-1766-35/+112
| | | | | | | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. A new placeholder symbol __libpthread_version_placeholder@GLIBC_2.18 is needed to keep the GLIBC_2.18 symbol version in libpthread. The __pthread_getattr_default_np@@GLIBC_PRIVATE export is used from pthread_create. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Move static TLS size and alignment into _rtld_global_roFlorian Weimer2021-05-174-18/+26
| | | | | | | This helps to clarify that the caching of these fields in libpthread (in __static_tls_size, __static_tls_align_m1) is unnecessary. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Remove DL_STATIC_INITFlorian Weimer2021-05-172-10/+0
| | | | | | All users have been converted to the __rtld_static_init mechanism. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* powerpc: Remove _dl_var_initFlorian Weimer2021-05-174-122/+10
| | | | | | | | | The generic __rtld_static_init code handles GLRO (dl_pagesize), GLRO (dl_auxv), GLRO (dl_hwcap), GLRO (dl_hwcap2). GLRO (dl_cache_line_size) is handled in an __rtld_static_init_arch override. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* mips: Remove _dl_var_initFlorian Weimer2021-05-174-100/+0
| | | | | | The generic __rtld_static_init code handles GLRO (dl_pagesize). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* m68k: Remove _dl_var_initFlorian Weimer2021-05-174-122/+0
| | | | | | The generic __rtld_static_init code handles GLRO (dl_pagesize). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* ia64: Remove _dl_var_initFlorian Weimer2021-05-174-102/+0
| | | | | | | The generic __rtld_static_init code handles GLRO (dl_pagesize) and GLRO (dl_clktck). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* arc: Remove _dl_var_initFlorian Weimer2021-05-174-129/+0
| | | | | | The generic __rtld_static_init code handles GLRO (dl_pagesize). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* aarch64: Remove _dl_var_initFlorian Weimer2021-05-174-130/+0
| | | | | | The generic __rtld_static_init code handles GLRO (dl_pagesize). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Partially initialize ld.so after static dlopen (bug 20802)Florian Weimer2021-05-178-13/+208
| | | | | | | | | | | | | | After static dlopen, a copy of ld.so is loaded into the inner namespace, but that copy is not initialized at all. Some architectures run into serious problems as result, which is why the _dl_var_init mechanism was invented. With libpthread moving into libc and parts into ld.so, more architectures impacted, so it makes sense to switch to a generic mechanism which performs the partial initialization. As a result, getauxval now works after static dlopen (bug 20802). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move __nptl_create_event, __nptl_death_event into libcFlorian Weimer2021-05-176-9/+15
| | | | | | | | In libthread_db, use the exported GLIBC_PRIVATE symbols directly instead of relying on _thread_db_* variables in libpthread (which used to be created by the DB_FUNCTION macros). Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move __nptl_initial_report_events into ld.so/startup codeFlorian Weimer2021-05-177-18/+24
| | | | | | | | | | | | The initialization of the report_events TCB field is now performed in __tls_init_tp instead of __pthread_initialize_minimal_internal (in libpthread). The events interface is difficult to test because GDB stopped using it in 2015. The td_thr_get_info change to ignore lookup issues is enough to support GDB with this change. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Enable support for GCC 11 -Wmismatched-dealloc.Martin Sebor2021-05-1613-41/+308
| | | | | | | | | | | | | | | | | | | | | | | To help detect common kinds of memory (and other resource) management bugs, GCC 11 adds support for the detection of mismatched calls to allocation and deallocation functions. At each call site to a known deallocation function GCC checks the set of allocation functions the former can be paired with and, if the two don't match, issues a -Wmismatched-dealloc warning (something similar happens in C++ for mismatched calls to new and delete). GCC also uses the same mechanism to detect attempts to deallocate objects not allocated by any allocation function (or pointers past the first byte into allocated objects) by -Wfree-nonheap-object. This support is enabled for built-in functions like malloc and free. To extend it beyond those, GCC extends attribute malloc to designate a deallocation function to which pointers returned from the allocation function may be passed to deallocate the allocated objects. Another, optional argument designates the positional argument to which the pointer must be passed. This change is the first step in enabling this extended support for Glibc.
* nptl: Fix tst-pthread-gdb-attach for ptrace_scope equal 1Adhemerval Zanella2021-05-141-17/+39
| | | | | | | | | This is similar to the fix for elf/tst-pldd (2f9046fb059e94fe25): it checks ptrace_scope value (values higher than 2 are too restrictive to allow the test to run) and it rearranges the spawned processes to make the target process the gdb child. Checked on x86_64-linux-gnu with ptrace_scope set to 1.
* stdlib: Fix data race in __run_exit_handlers [BZ #27749]Vitaly Buka2021-05-143-17/+133
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Keep __exit_funcs_lock almost all the time and unlock it only to execute callbacks. This fixed two issues. 1. f->func.cxa was modified outside the lock with rare data race like: thread 0: __run_exit_handlers unlock __exit_funcs_lock thread 1: __internal_atexit locks __exit_funcs_lock thread 0: f->flavor = ef_free; thread 1: sees ef_free and use it as new thread 1: new->func.cxa.fn = (void (*) (void *, int)) func; thread 1: new->func.cxa.arg = arg; thread 1: new->flavor = ef_cxa; thread 0: cxafct = f->func.cxa.fn; // it's wrong fn! thread 0: cxafct (f->func.cxa.arg, status); // it's wrong arg! thread 0: goto restart; thread 0: call the same exit_function again as it's ef_cxa 2. Don't unlock in main while loop after *listp = cur->next. If *listp is NULL and __exit_funcs_done is false another thread may fail in __new_exitfn on assert (l != NULL): thread 0: *listp = cur->next; // It can be the last: *listp = NULL. thread 0: __libc_lock_unlock thread 1: __libc_lock_lock in __on_exit thread 1: __new_exitfn thread 1: if (__exit_funcs_done) // false: thread 0 isn't there yet. thread 1: l = *listp thread 1: moves one and crashes on assert (l != NULL); The test needs multiple iterations to consistently fail without the fix. Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=27749 Checked on x86_64-linux-gnu. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* Make sysdeps/generic/libc.abilist emptyJoseph Myers2021-05-131-1/+0
| | | | | The __libc_single_threaded symbol was accidentally added to this file in commit 706ad1e7af37be1d25fc2359bda006d31fe0d11b.
* support: Free gdb_script_nameSiddhesh Poyarekar2021-05-131-0/+1
| | | | Identified by static analysis.
* support: Close fds in copy_funcSiddhesh Poyarekar2021-05-131-8/+13
| | | | | copy_func may leave file descriptors open on error, so close them on function exit.
* inet: Free result from getaddrinfoSiddhesh Poyarekar2021-05-132-8/+9
| | | | | Coverity discovered paths where the result from getaddrinfo was not freed.
* linux/check_native: Always close socket on returnSiddhesh Poyarekar2021-05-121-12/+11
| | | | | | The error paths of __check_native would leave the socket FD open on return, resulting in an FD leak. Rework function exit paths so that the fd is always closed on return.
* Remove all usage of @BASH@ or ${BASH} in installed files, and hardcode ↵Romain GEISSLER2021-05-128-15/+10
| | | | | | | | | | | | | | | | | | | /bin/bash instead (FYI, this is a repost of https://sourceware.org/pipermail/libc-alpha/2019-July/105035.html now that FSF papers have been signed and confirmed on FSF side). This trivial patch attemps to fix BZ 24106. Basically the bash locally used when building glibc on the host shall not leak on the installed glibc, as the system where it is installed might be different and use another bash location. So I have looked for all occurences of @BASH@ or $(BASH) in installed files, and replaced it by /bin/bash. This was suggested by Florian Weimer in the bug report. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
* nptl: Move pthread_getconcurrency, pthread_setconcurrency into libcFlorian Weimer2021-05-1165-66/+152
| | | | | | | | The symbols were moved using scripts/move-symbol-to-libc.py, in one commit due to their dependency on the internal __concurrency_level variable. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_cancel into libcFlorian Weimer2021-05-1165-33/+72
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move __pthread_register_cancel_defer, ↵Florian Weimer2021-05-1164-64/+149
| | | | | | | | __pthread_unregister_cancel_restore to libc The symbols were moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move __pthread_register_cancel, __pthread_unregister_cancel to libcFlorian Weimer2021-05-1165-77/+154
| | | | | | | | | The symbols were moved using scripts/move-symbol-to-libc.py. Also clean up some unwinder linking leftover in the same spot in nptl/pthreadP.h. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_setstacksize into libcFlorian Weimer2021-05-1168-56/+125
| | | | | | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. It is necessary to arrange for a __libpthread_version_placeholder@GLIBC_2.6 on some of the powerpc targets. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_setstackaddr into libcFlorian Weimer2021-05-1164-33/+74
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_setstack into libcFlorian Weimer2021-05-1164-52/+96
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_setguardsize into libcFlorian Weimer2021-05-1164-33/+75
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_getstacksize into libcFlorian Weimer2021-05-1164-33/+74
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_getstackaddr into libcFlorian Weimer2021-05-1164-33/+74
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_getstack into libcFlorian Weimer2021-05-1164-33/+74
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_getguardsize into libcFlorian Weimer2021-05-1164-33/+75
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_attr_getaffinity_np into libcFlorian Weimer2021-05-1164-50/+93
| | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Fix DTV gap reuse logic [BZ #27135]Szabolcs Nagy2021-05-113-15/+6
| | | | | | | | | | | | | | | | | | | | | | | For some reason only dlopen failure caused dtv gaps to be reused. It is possible that the intent was to never reuse modids for a different module, but after dlopen failure all gaps are reused not just the ones caused by the unfinished dlopened. So the code has to handle reused modids already which seems to work, however the data races at thread creation and tls access (see bug 19329 and bug 27111) may be more severe if slots are reused so this is scheduled after those fixes. I think fixing the races are not simpler if reuse is disallowed and reuse has other benefits, so set GL(dl_tls_dtv_gaps) whenever entries are removed from the middle of the slotinfo list. The value does not have to be correct: incorrect true value causes the next modid query to do a slotinfo walk, incorrect false will leave gaps and new entries are added at the end. Fixes bug 27135. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Add test case for [BZ #19329]Szabolcs Nagy2021-05-113-2/+76
| | | | | | | | | | | | | Test concurrent dlopen and pthread_create when the loaded modules have TLS. This triggers dl-tls assertion failures more reliably than the nptl/tst-stack4 test. The dlopened module has 100 DT_NEEDED dependencies with TLS, they were reused from an existing TLS test. The number of created threads during dlopen depends on filesystem speed and hardware, but at most 3 threads are alive at a time to limit resource usage. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Use relaxed atomics for racy accesses [BZ #19329]Szabolcs Nagy2021-05-114-17/+42
| | | | | | | | | | | | | | | | | | This is a follow up patch to the fix for bug 19329. This adds relaxed MO atomics to accesses that were previously data races but are now race conditions, and where relaxed MO is sufficient. The race conditions all follow the pattern that the write is behind the dlopen lock, but a read can happen concurrently (e.g. during tls access) without holding the lock. For slotinfo entries the read value only matters if it reads from a synchronized write in dlopen or dlclose, otherwise the related dtv entry is not valid to access so it is fine to leave it in an inconsistent state. The same applies for GL(dl_tls_max_dtv_idx) and GL(dl_tls_generation), but there the algorithm relies on the fact that the read of the last synchronized write is an increasing value. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* elf: Fix data races in pthread_create and TLS access [BZ #19329]Szabolcs Nagy2021-05-111-16/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | DTV setup at thread creation (_dl_allocate_tls_init) is changed to take the dlopen lock, GL(dl_load_lock). Avoiding data races here without locks would require design changes: the map that is accessed for static TLS initialization here may be concurrently freed by dlclose. That use after free may be solved by only locking around static TLS setup or by ensuring dlclose does not free modules with static TLS, however currently every link map with TLS has to be accessed at least to see if it needs static TLS. And even if that's solved, still a lot of atomics would be needed to synchronize DTV related globals without a lock. So fix both bug 19329 and bug 27111 with a lock that prevents DTV setup running concurrently with dlopen or dlclose. _dl_update_slotinfo at TLS access still does not use any locks so CONCURRENCY NOTES are added to explain the synchronization. The early exit from the slotinfo walk when max_modid is reached is not strictly necessary, but does not hurt either. An incorrect acquire load was removed from _dl_resize_dtv: it did not synchronize with any release store or fence and synchronization is now handled separately at thread creation and TLS access time. There are still a number of racy read accesses to globals that will be changed to relaxed MO atomics in a followup patch. This should not introduce regressions compared to existing behaviour and avoid cluttering the main part of the fix. Not all TLS access related data races got fixed here: there are additional races at lazy tlsdesc relocations see bug 27137. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* write_archive_locales: Fix memory leakSiddhesh Poyarekar2021-05-111-0/+2
| | | | Fix memory leak identified by coverity.
* nptl: Move thread join functions into libcFlorian Weimer2021-05-1171-178/+436
| | | | | | | | | | | The symbols pthread_clockjoin_np, pthread_join, pthread_timedjoin_np, pthread_tryjoin_np, thrd_join were moved using scripts/move-symbol-to-libc.py. Moving the symbols at the same time avoids the need for temporary exports. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_detach, thrd_detach into libcFlorian Weimer2021-05-1167-66/+157
| | | | | | The symbols were moved using scripts/move-symbol-to-libc.py. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move __free_tcb into libcFlorian Weimer2021-05-117-29/+52
| | | | | | Under the name __nptl_free_tcb. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move stack cache management, __libpthread_freeres into libcFlorian Weimer2021-05-1110-158/+212
| | | | | | | | | | | | | This replaces the FREE_P macro with the __nptl_stack_in_use inline function. stack_list_del is renamed to __nptl_stack_list_del, stack_list_add to __nptl_stack_list_add, __deallocate_stack to __nptl_deallocate_stack, free_stacks to __nptl_free_stacks. It is convenient to move __libpthread_freeres into libc at the same time. This removes the temporary __default_pthread_attr_freeres export and restores full freeres coverage for __default_pthread_attr. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Move pthread_setattr_default_np into libcFlorian Weimer2021-05-1165-35/+80
| | | | | | | | | | | The symbol was moved using scripts/move-symbol-to-libc.py. The export of __default_pthread_attr_freeres is temporary. There is a minor regression in freeres coverage because in the dynamic case, __default_pthread_attr_freeres is no longer called if libpthread is not linked in. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Remove always-disabled debugging supportFlorian Weimer2021-05-113-75/+5
| | | | | | | This removes the DEBUGGING_P macro and the __pthread_debug variable. The __find_in_stack_list function is now unused and deleted as well. Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* nptl: Replace pthread_sigqueue implementation with Linux oneFlorian Weimer2021-05-112-75/+38
| | | | Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
* get-translit.py: Fix typoSiddhesh Poyarekar2021-05-111-1/+1
|
* _dl_exception_create_format: Add missing va_endSiddhesh Poyarekar2021-05-111-0/+1
| | | | Coverity discovered a missing va_end.
* linux: Move funlockfile/_IO_funlockfile into libcAdhemerval Zanella2021-05-1032-92/+3
| | | | | | | | | | The nptl version is used as default, since now with symbol always present the single-thread optimization is tricky. Hurd is not change, it is used it own lock scheme (which call _cthreads_funlockfile). Checked on x86_64-linux-gnu.
* linux: Move ftrylockfile/_IO_ftrylockfile into libcAdhemerval Zanella2021-05-1032-94/+3
| | | | | | | | | | The nptl version is used as default, since now with symbol always present the single-thread optimization is tricky. Hurd is not change, it is used it own lock scheme (which call _cthreads_ftrylockfile). Checked on x86_64-linux-gnu.