#
92771bc0 |
|
23-Apr-2024 |
Konstantin Belousov <kib@FreeBSD.org> |
libc: make strerror_rl() usable for libc Reviewed by: imp Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D44916
|
#
7dd9070e |
|
16-Apr-2024 |
Brooks Davis <brooks@FreeBSD.org> |
libc: INTERPOS_SYS macro for interposed syscalls This macro makes uses the __sys_<foo>_t typedefs from libsys.h to greatly simplify calling functions in the interposing table. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44389
|
#
792081a7 |
|
16-Apr-2024 |
Brooks Davis <brooks@FreeBSD.org> |
lib{c,rt}: use libsys.h for __sys_* declerations Use the genreated source of truth for system call declerations. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44388
|
#
d0efabdf |
|
19-Mar-2024 |
Brooks Davis <brooks@FreeBSD.org> |
syscalls.master: make __sys_fcntl take an intptr_t The (optional) third argument of fcntl is sometimes a pointer so change the type to intptr_t. Update the libc-internal defintion (actually used by libthr) to take a fixed intptr_t argument rather than pretending it's a variadic function. (That worked because all supported architectures pass variadic arguments as though the function was declared with those types. In CheriBSD that changes because variadic arguments are passed via a bounded array.) Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44381
|
#
ef5fddd3 |
|
13-Mar-2024 |
Brooks Davis <brooks@FreeBSD.org> |
libsys: make __libsys_interposing static Access __libsys_interposing with __libc_interposing_slot() in all cases to support a move of these wrappers back to libc. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44239
|
#
f7dbbbd1 |
|
13-Mar-2024 |
Brooks Davis <brooks@FreeBSD.org> |
libsys: don't expose sigwait wrapper Long ago (e129c18a83ef) __sys_sigwait was wrapped to prevent sigwait() from returning with EINTR. Through a series of changes this wrapper become __libc_sigwait which was internal to libc and used solely in the interposing table. To support a move of sigwait back to libc, move this wrapper into libsys and rename it with an __libsys_ prefix. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D44238
|
#
a3a4bea4 |
|
13-Mar-2024 |
Brooks Davis <brooks@FreeBSD.org> |
libc: remove remnants of __fcntl_compat Reviewed by: kib Fixes: 60b2e2d3ee82 libc: stop exposing __fcntl_compat Differential Revision: https://reviews.freebsd.org/D44326
|
#
9cbd9658 |
|
16-Jan-2024 |
Brooks Davis <brooks@FreeBSD.org> |
libc: split libc and syscall interposing (1/2) System calls or their wrappers are now interposed by __libsys_interposing with purely libc entries remaining in __libc_interposing. Use __libsys_interposing_slot in libthr to update __libsys_interposing, but also make __libc_interposing_slot fall back to __libsys_interposing_slot so an out of date libc has a chance of working during updates. Reviewed by: kib, emaste, imp Pull Request: https://github.com/freebsd/freebsd-src/pull/908
|
#
8ccd0b87 |
|
11-Dec-2023 |
Brooks Davis <brooks@FreeBSD.org> |
libc: expose execvpe for Linux compat We already implemented execvpe internally with an _ prefix in libc so go ahead and expose it for compatibility with Linux. This reverts c605eea952146348e5e1ad5cab6c127d7a1bd164. Bump __FreeBSD_version for the addition and add definitions to supress compat shims in libzfs (zfs changes were merged from upstream). PR: 275370 (request and exp-run (thanks antoine!)) Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D42846
|
#
0dc52b72 |
|
14-Aug-2023 |
Minsoo Choo <minsoochoo0122@proton.me> |
libc: export pthread_getname_np stub pthread_getname_np needs to be provided by libc in order to import jemalloc 5.3.0. A stub implementation for libc pthread_getname_np() is added for _pthread_stubs.c, which always reports empty name for the main thread. Internal _pthread_getname_np() is not exported, but provided for libc own use. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41461
|
#
b3e76948 |
|
16-Aug-2023 |
Warner Losh <imp@FreeBSD.org> |
Remove $FreeBSD$: two-line .h pattern Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
|
#
0c6f0c0d |
|
05-Nov-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
libc: move declaration of 'char **environ' to common private header Suggested by: imp Reviewed by: markj Tested by: markj (aarch64) Sponsored by: The FreeBSD Foundation MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D37220
|
#
51015e6d |
|
30-Oct-2022 |
Konstantin Belousov <kib@FreeBSD.org> |
csu: move common code to libc Why? Most trivial point, it shaves around 600 bytes from the dynamic binaries on amd64. Less trivial, the removed code is no longer part of the ABI, and we can ship updates to it with libc updates. Right now most of the csu is linked into the binaries and require us to do somewhat tricky ABI compat when it needs to change. For instance, the init_array change would be much simpler and does not require note tagging if we have init calling code in libc. This could be improved more, by splitting dynamic and static initialization. For instance, &_DYNAMIC tests can be removed then. Such change, nonetheless, would require building libc three times. I left this for later, after this change stabilizes, if ever. Reviewed by: markj Discussed with: jrtc27 (some objections, see the review), imp Tested by: markj (aarch64) Sponsored by: The FreeBSD Foundation MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D37220
|
#
cbc32e4c |
|
14-Feb-2023 |
Dmitry Chagin <dchagin@FreeBSD.org> |
cpuset: Add compat shim to the sched_affinity functions To allow to run a newer world on a pre-1400079 kernel a compat shims to the sched_affinity functions has beed added. Reported by: antoine Tested by: antoine Reviewed by: kib Differential revision: https://reviews.freebsd.org/D38555 MFC after: 3 days
|
#
ae67737a |
|
09-Dec-2021 |
John Baldwin <jhb@FreeBSD.org> |
libc: Remove _get_tp() and _set_tp(). Their uses have been replaced by _tcb_get() and _tcb_set() from <machine/tls.h>. Reviewed by: kib, jrtc27 Sponsored by: The University of Cambridge, Google Inc. Differential Revision: https://reviews.freebsd.org/D33354
|
#
77b2c2f8 |
|
22-Oct-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
Add sched_getcpu() for compatibility with Linux. Reviewed by: jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32901
|
#
06d8a116 |
|
04-Apr-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
libc: add _get_tp() private function which returns pointer to tcb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D29623
|
#
21f749da |
|
10-Jan-2021 |
Konstantin Belousov <kib@FreeBSD.org> |
libthr: wrap pdfork(2), same as fork(2). Without wrapping, rtld services and malloc(3) are not guaranteed to operate correctly in the forked child. Reviewed by: markj MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28088
|
#
44c5db52 |
|
23-Dec-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
Add eventfd(3) wrappers to libc. eventfd_read/write one-liners are from musl libc. Submitted by: greg@unrelenting.technology Reviewed by: markj (previous version) MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D26668
|
#
675079b1 |
|
16-Dec-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
Implement strerror_l(). Only for the arches that provide user-mode TLS. PR: 251651 Requested by: yuri Discussed with: emaste, jilles, tijl Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D27495 MFC after: 2 weeks
|
#
412ef5da |
|
27-Nov-2020 |
Konstantin Belousov <kib@FreeBSD.org> |
libc: Add pthread_attr_get_np(3) stub, reporting ESRCH. This seems to be required by recent clang asan. I do not see other way than put the symbol under FBSD_1.0 version. PR: 251112 Reported by: Andrew Stitcher <astitcher@apache.org> Reviewed by: emaste Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D27389
|
#
7d03e081 |
|
14-Apr-2020 |
Kyle Evans <kevans@FreeBSD.org> |
Mark closefrom(2) COMPAT12, reimplement in libc to wrap close_range Include a temporarily compatibility shim as well for kernels predating close_range, since closefrom is used in some critical areas. Reviewed by: markj (previous version), kib Differential Revision: https://reviews.freebsd.org/D24399
|
#
3e25d1fb |
|
25-Sep-2019 |
Kyle Evans <kevans@FreeBSD.org> |
Add linux-compatible memfd_create memfd_create is effectively a SHM_ANON shm_open(2) mapping with optional CLOEXEC and file sealing support. This is used by some mesa parts, some linux libs, and qemu can also take advantage of it and uses the sealing to prevent resizing the region. This reimplements shm_open in terms of shm_open2(2) at the same time. shm_open(2) will be moved to COMPAT12 shortly. Reviewed by: markj, kib Differential Revision: https://reviews.freebsd.org/D21393
|
#
2d8c3eeb |
|
23-Jun-2019 |
Konstantin Belousov <kib@FreeBSD.org> |
Add libc stub for pthread_getthreadid_np(3). Requested by: jbeich PR: 238650 Sponsored by: The FreeBSD Foundation MFC after: 1 week
|
#
5d00c5a6 |
|
29-Mar-2019 |
Konstantin Belousov <kib@FreeBSD.org> |
Fix initial exec TLS mode for dynamically loaded shared objects. If dso uses initial exec TLS mode, rtld tries to allocate TLS in static space. If there is no space left, the dlopen(3) fails. If space if allocated, initial content from PT_TLS segment is distributed to all threads' pcbs, which was missed and caused un-initialized TLS segment for such dso after dlopen(3). The mode is auto-detected either due to the relocation used, or if the DF_STATIC_TLS dynamic flag is set. In the later case, the TLS segment is tried to allocate earlier, which increases chance of the dlopen(3) to succeed. LLD was recently fixed to properly emit the flag, ld.bdf did it always. Initial test by: dumbbell Tested by: emaste (amd64), ian (arm) Tested by: Gerald Aryeetey <aryeeteygerald_rogers.com> (arm64) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D19072
|
#
c1e80940 |
|
19-Aug-2018 |
Xin LI <delphij@FreeBSD.org> |
Update userland arc4random() with OpenBSD's Chacha20 based arc4random(). ObsoleteFiles.inc: Remove manual pages for arc4random_addrandom(3) and arc4random_stir(3). contrib/ntp/lib/isc/random.c: contrib/ntp/sntp/libevent/evutil_rand.c: Eliminate in-tree usage of arc4random_addrandom(). crypto/heimdal/lib/roken/rand.c: crypto/openssh/config.h: Eliminate in-tree usage of arc4random_stir(). include/stdlib.h: Remove arc4random_stir() and arc4random_addrandom() prototypes, provide temporary shims for transistion period. lib/libc/gen/Makefile.inc: Hook arc4random-compat.c to build, add hint for Chacha20 source for kernel, and remove arc4random_addrandom(3) and arc4random_stir(3) links. lib/libc/gen/arc4random.c: Adopt OpenBSD arc4random.c,v 1.54 with bare minimum changes, use the sys/crypto/chacha20 implementation of keystream. lib/libc/gen/Symbol.map: Remove arc4random_stir and arc4random_addrandom interfaces. lib/libc/gen/arc4random.h: Adopt OpenBSD arc4random.h,v 1.4 but provide _ARC4_LOCK of our own. lib/libc/gen/arc4random.3: Adopt OpenBSD arc4random.3,v 1.35 but keep FreeBSD r114444 and r118247. lib/libc/gen/arc4random-compat.c: Compatibility shims for arc4random_stir and arc4random_addrandom functions to preserve ABI. Log once when called but do nothing otherwise. lib/libc/gen/getentropy.c: lib/libc/include/libc_private.h: Fold __arc4_sysctl into getentropy.c (renamed to arnd_sysctl). Remove from libc_private.h as a result. sys/crypto/chacha20/chacha.c: sys/crypto/chacha20/chacha.h: Make it possible to use the kernel implementation in libc. PR: 182610 Reviewed by: cem, markm Obtained from: OpenBSD Relnotes: yes Differential Revision: https://reviews.freebsd.org/D16760
|
#
08a7e74c |
|
21-Mar-2018 |
Conrad Meyer <cem@FreeBSD.org> |
getentropy(3): Fallback to kern.arandom sysctl on older kernels On older kernels, when userspace program disables SIGSYS, catch ENOSYS and emulate getrandom(2) syscall with the kern.arandom sysctl (via existing arc4_sysctl wrapper). Special care is taken to faithfully emulate EFAULT on NULL pointers, because sysctl(3) as used by kern.arandom ignores NULL oldp. (This was caught by getentropy(3) ATF tests.) Reported by: kib Reviewed by: kib Discussed with: delphij Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D14785
|
#
8a16b7a1 |
|
20-Nov-2017 |
Pedro F. Giffuni <pfg@FreeBSD.org> |
General further adoption of SPDX licensing ID tags. Mainly focus on files that use BSD 3-Clause license. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point.
|
#
b73ac668 |
|
30-Jun-2017 |
Konstantin Belousov <kib@FreeBSD.org> |
In the stdio cleanup push and pop wrappers, always call libc stubs for __pthread_cleanup_push/pop_imp instead of symbols also exported from libthr. This prevents calls into libthr if libthr is not yet initialized. The situation occurs e.g. when an LD_PRELOADed object is not linked against libthr, but the main binary is. Reported and tested by: jbeich PR: 220381 Discussed with: vangyzen Sponsored by: The FreeBSD Foundation MFC after: 13 days
|
#
5ab191c4 |
|
23-Jun-2017 |
Warner Losh <imp@FreeBSD.org> |
Forward compatibility for ino64. Add forward compatibility so that new binaries can run on old kernels. If the new system call from ino64 isn't available on your system, then the old one will be used and the results translated. The stat and statfs families of functions are fully emulated. While not required by policy, in this case it is helpful to our users to provide this compatibility. In this case, it allows rollback of the kernel after installing a new userland should a problem be discovered. It also prevents foot-shooting if a user does an install before rebooting with the new kernel. Finally, it allows the use case where one needs to run new binaries on an old kernel as part of an upgrade process. The getdirentries family uses tricks that may not work on remote filesystems. Specifically, it uses a buffer 1/4 the size requested to get the data from he old syscall. The code carefully uses direct syscalls for old system calls to avoid referencing freebsd11_* symbols, which contaminate ld-elf.so.1's export table due to its use of stat functions, which causes errno to be incorrect in client programs due to the wrong *stat* function being resolved in some cases. This code should removed sometime after 12 is branched. Tested on: 12-current binaries on a 10.3-beta kernel run and return consistent results. 12-current kernel and userland with packages from before ino64 was committed also work. Differential Revision: https://reviews.freebsd.org/D11185 Reviewed by: kib@, emaste@
|
#
5a6d7b72 |
|
23-May-2017 |
Eric van Gyzen <vangyzen@FreeBSD.org> |
libthr: fix warnings from GCC when WARNS=6 Fix warnings about: - redundant declarations - a local variable shadowing a global function (dlinfo) - an old-style function definition (with an empty parameter list) - a variable that is possibly used uninitialized "make tinderbox" passes this time, except for a few unrelated kernel failures. Reviewed by: kib MFC after: 3 days Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10870
|
#
69921123 |
|
23-May-2017 |
Konstantin Belousov <kib@FreeBSD.org> |
Commit the 64-bit inode project. Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify struct dirent layout to add d_off, increase the size of d_fileno to 64-bits, increase the size of d_namlen to 16-bits, and change the required alignment. Increase struct statfs f_mntfromname[] and f_mntonname[] array length MNAMELEN to 1024. ABI breakage is mitigated by providing compatibility using versioned symbols, ingenious use of the existing padding in structures, and by employing other tricks. Unfortunately, not everything can be fixed, especially outside the base system. For instance, third-party APIs which pass struct stat around are broken in backward and forward incompatible ways. Kinfo sysctl MIBs ABI is changed in backward-compatible way, but there is no general mechanism to handle other sysctl MIBS which return structures where the layout has changed. It was considered that the breakage is either in the management interfaces, where we usually allow ABI slip, or is not important. Struct xvnode changed layout, no compat shims are provided. For struct xtty, dev_t tty device member was reduced to uint32_t. It was decided that keeping ABI compat in this case is more useful than reporting 64-bit dev_t, for the sake of pstat. Update note: strictly follow the instructions in UPDATING. Build and install the new kernel with COMPAT_FREEBSD11 option enabled, then reboot, and only then install new world. Credits: The 64-bit inode project, also known as ino64, started life many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick (mckusick) then picked up and updated the patch, and acted as a flag-waver. Feedback, suggestions, and discussions were carried by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles), and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial ports investigation followed by an exp-run by Antoine Brodin (antoine). Essential and all-embracing testing was done by Peter Holm (pho). The heavy lifting of coordinating all these efforts and bringing the project to completion were done by Konstantin Belousov (kib). Sponsored by: The FreeBSD Foundation (emaste, kib) Differential revision: https://reviews.freebsd.org/D10439
|
#
9851b340 |
|
29-Mar-2017 |
Konstantin Belousov <kib@FreeBSD.org> |
Implement the memset_s(3) function as specified by the C11 ISO/IEC 9899:2011 Appendix K 3.7.4.1. Other needed supporting types, defines and constraint_handler infrastructure is added as specified in the C11 spec. Submitted by: Tom Rix <trix@juniper.net> Sponsored by: Juniper Networks Discussed with: ed MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D9903 Differential revision: https://reviews.freebsd.org/D10161
|
#
3f8455b0 |
|
18-Mar-2017 |
Eric van Gyzen <vangyzen@FreeBSD.org> |
Add clock_nanosleep() Add a clock_nanosleep() syscall, as specified by POSIX. Make nanosleep() a wrapper around it. Attach the clock_nanosleep test from NetBSD. Adjust it for the FreeBSD behavior of updating rmtp only when interrupted by a signal. I believe this to be POSIX-compliant, since POSIX mentions the rmtp parameter only in the paragraph about EINTR. This is also what Linux does. (NetBSD updates rmtp unconditionally.) Copy the whole nanosleep.2 man page from NetBSD because it is complete and closely resembles the POSIX description. Edit, polish, and reword it a bit, being sure to keep any relevant text from the FreeBSD page. Reviewed by: kib, ngie, jilles MFC after: 3 weeks Relnotes: yes Sponsored by: Dell EMC Differential Revision: https://reviews.freebsd.org/D10020
|
#
b7c7684a |
|
07-Jan-2017 |
Konstantin Belousov <kib@FreeBSD.org> |
Export __cxa_thread_atexit_impl as an alias for __cxa_thread_atexit. libstdc++ before gcc r244057 expected that libc provided __cxa_thread_atexit_impl, and libstdc++ implemented __cxa_thread_atexit, by forwarding the calls to _impl. Mentioned gcc revision checks for __cxa_thread_atexit in libc and does not provide the symbol from libstdc++ if found. This change helps older gcc, in particular, all released versions which implement thread_local, by consolidating the implementation into libc. For that versions, if configured with the current libc, the __cxa_thread_atexit is exported from libstdc++ as a trivial wrapper around libc::__cxa_thread_atexit_impl. The __cxa_thread_atexit implementation is put into separate source file to allow for static linking with older libstdc++.a. gcc bugzilla: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78968 Reported by: Hannes Hauswedell <h2+fbsdports@fsfe.org> PR: 215709 Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
|
#
afd3e268 |
|
29-Aug-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
Rewrite ptrace(2) wrappers in C. Besides removing hand-translation to assembler, this also adds missing wrappers for arm64 and risc-v. Reviewed by: emaste, jhb Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D7694
|
#
1c1cc895 |
|
16-Aug-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
The fdatasync(2) call must be cancellation point. Sponsored by: The FreeBSD Foundation MFC after: 13 days
|
#
b585cd3e |
|
06-Aug-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
Add __cxa_thread_atexit(3) API implementation. This is the backing feature to implement C++11 thread storage duration specified by the thread_local keyword. A destructor for given thread-local object is registered to be executed at the thread termination time using __cxa_thread_atexit(). Libc calls the __cxa_thread_calls_dtors() during exit(3), before finalizers and atexit functions, and libthr calls the function at the thread termination time, after the stack unwinding and thread-specific key destruction. There are several uncertainties in the API which lacks a formal specification. Among them: - is it allowed to register destructors during destructing; we allow, but limiting the nesting level. If too many iterations detected, a diagnostic is issued to stderr and thread forcibly terminates for now. - how to handle destructors which belong to an unloading dso; for now, we ignore destructor calls for such entries, and issue a diagnostic. Linux does prevent dso unload until all threads with destructors from the dso terminated. It is supposed that the diagnostics allow to detect real-world applications relying on the above details and possibly adjust our implementation. Right now the choices were to provide the slim API (but that rarely stands the practice test). Tests are added to check generic functionality and to specify some of the above implementation choices. Submitted by: Mahdi Mokhtari <mokhi64_gmail.com> Reviewed by: theraven Discussed with: dim (detection of -std=c++11 supoort for tests) Sponsored by: The FreeBSD Foundation (my involvement) MFC after: 2 weeks Differential revisions: https://reviews.freebsd.org/D7224, https://reviews.freebsd.org/D7427
|
#
2a339d9e |
|
17-May-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
Add implementation of robust mutexes, hopefully close enough to the intention of the POSIX IEEE Std 1003.1TM-2008/Cor 1-2013. A robust mutex is guaranteed to be cleared by the system upon either thread or process owner termination while the mutex is held. The next mutex locker is then notified about inconsistent mutex state and can execute (or abandon) corrective actions. The patch mostly consists of small changes here and there, adding neccessary checks for the inconsistent and abandoned conditions into existing paths. Additionally, the thread exit handler was extended to iterate over the userspace-maintained list of owned robust mutexes, unlocking and marking as terminated each of them. The list of owned robust mutexes cannot be maintained atomically synchronous with the mutex lock state (it is possible in kernel, but is too expensive). Instead, for the duration of lock or unlock operation, the current mutex is remembered in a special slot that is also checked by the kernel at thread termination. Kernel must be aware about the per-thread location of the heads of robust mutex lists and the current active mutex slot. When a thread touches a robust mutex for the first time, a new umtx op syscall is issued which informs about location of lists heads. The umtx sleep queues for PP and PI mutexes are split between non-robust and robust. Somewhat unrelated changes in the patch: 1. Style. 2. The fix for proper tdfind() call use in umtxq_sleep_pi() for shared pi mutexes. 3. Removal of the userspace struct pthread_mutex m_owner field. 4. The sysctl kern.ipc.umtx_vnode_persistent is added, which controls the lifetime of the shared mutex associated with a vnode' page. Reviewed by: jilles (previous version, supposedly the objection was fixed) Discussed with: brooks, Martin Simmons <martin@lispworks.com> (some aspects) Tested by: pho Sponsored by: The FreeBSD Foundation
|
#
c5dd49af |
|
08-Feb-2016 |
Mark Johnston <markj@FreeBSD.org> |
Fix the gcc build after r295407. X-MFC-With: r295407
|
#
bd43f069 |
|
08-Feb-2016 |
Konstantin Belousov <kib@FreeBSD.org> |
If libthr.so is dlopened without RTLD_GLOBAL flag, the libthr symbols do not participate in the global symbols namespace, but rtld locks are still replaced and functions are interposed. In particular, __pthread_map_stacks_exec is resolved to the libc version. If a library is loaded later, which requires adjustment of the stack protection mode, rtld calls into libc __pthread_map_stacks_exec due to the symbols scope. The libc version might recurse into binder and recursively acquire rtld bind lock, causing the hang. Make libc __pthread_map_stacks_exec() interposed, which synchronizes rtld locks and version of the stack exec hook when libthr loaded, regardless of the symbol scope control or symbol resolution order. The __pthread_map_stacks_exec() symbol is removed from the private version in libthr since libc symbol now operates correctly in presence of libthr. Reported and tested by: markj Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
|
#
bd6060a1 |
|
29-Aug-2015 |
Konstantin Belousov <kib@FreeBSD.org> |
Switch libc from using _sig{procmask,action,suspend} symbols, which are aliases for the syscall stubs and are plt-interposed, to the libc-private aliases of internally interposed sigprocmask() etc. Since e.g. _sigaction is not interposed by libthr, calling signal() removes thr_sighandler() from the handler slot etc. The result was breaking signal semantic and rtld locking. The added __libc_sigprocmask and other symbols are hidden, they are not exported and cannot be called through PLT. The setjmp/longjmp functions for x86 were changed to use direct calls, and since PIC_PROLOGUE only needed for functional PLT indirection on i386, it is removed as well. The PowerPC bug of calling the syscall directly in the setjmp/longjmp implementation is kept as is. Reported by: Pete French <petefrench@ingresso.co.uk> Tested by: Michiel Boland <boland37@xs4all.nl> Reviewed by: jilles (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week
|
#
0538aafc |
|
18-Apr-2015 |
Konstantin Belousov <kib@FreeBSD.org> |
The lseek(2), mmap(2), truncate(2), ftruncate(2), pread(2), and pwrite(2) syscalls are wrapped to provide compatibility with pre-7.x kernels which required padding before the off_t parameter. The fcntl(2) contains compatibility code to handle kernels before the struct flock was changed during the 8.x CURRENT development. The shims were reasonable to allow easier revert to the older kernel at that time. Now, two or three major releases later, shims do not serve any purpose. Such old kernels cannot handle current libc, so revert the compatibility code. Make padded syscalls support conditional under the COMPAT6 config option. For COMPAT32, the syscalls were under COMPAT6 already. Remove WITHOUT_SYSCALL_COMPAT build option, which only purpose was to (partially) disable the removed shims. Reviewed by: jhb, imp (previous versions) Discussed with: peter Sponsored by: The FreeBSD Foundation MFC after: 1 week
|
#
3d0045bb |
|
18-Apr-2015 |
Konstantin Belousov <kib@FreeBSD.org> |
Make wait6(2), waitid(3) and ppoll(2) cancellation points. The waitid() function is required to be cancellable by the standard. The wait6() and ppoll() follow the other syscalls in their groups. Reviewed by: jhb, jilles (previous versions) Sponsored by: The FreeBSD Foundation MFC after: 1 week
|
#
b072e86d |
|
29-Mar-2015 |
Konstantin Belousov <kib@FreeBSD.org> |
Make kevent(2) a cancellation point. Note that to cancel blocked kevent(2) call, changelist must be empty, since we cannot cancel a call which already made changes to the process state. And in reverse, call which only makes changes to the kqueue state, without waiting for an event, is not cancellable. This makes a natural usage model to migrate kqueue loop to support cancellation, where existing single kevent(2) call must be split into two: first uncancellable update of kqueue, then cancellable wait for events. Note that this is ABI-incompatible change, but it is believed that there is no cancel-safe code that relies on kevent(2) not being a cancellation point. Option to preserve the ABI would be to keep kevent(2) as is, but add new call with flags to specify cancellation behaviour, which only value seems to add complications. Suggested and reviewed by: jilles Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
|
#
5aed3eff |
|
17-Feb-2015 |
Konstantin Belousov <kib@FreeBSD.org> |
Restore the extern qualifier on __cleanup. Sponsored by: The FreeBSD Foundation MFC after: 3 days
|
#
45468c53 |
|
14-Feb-2015 |
Konstantin Belousov <kib@FreeBSD.org> |
Properly interpose libc spinlocks, was missed in r276630. In particular, stdio locking was affected. Reported and tested by: "Matthew D. Fuller" <fullermd@over-yonder.net> Sponsored by: The FreeBSD Foundation MFC after: 3 days
|
#
2205e0d1 |
|
23-Jan-2015 |
Jilles Tjoelker <jilles@FreeBSD.org> |
Add futimens and utimensat system calls. The core kernel part is patch file utimes.2008.4.diff from pluknet@FreeBSD.org. I updated the code for API changes, added the manual page and added compatibility code for old kernels. There is also audit and Capsicum support. A new UTIME_* constant might allow setting birthtimes in future. Differential Revision: https://reviews.freebsd.org/D1426 Submitted by: pluknet (partially) Reviewed by: delphij, pluknet, rwatson Relnotes: yes
|
#
397d851d |
|
11-Jan-2015 |
Konstantin Belousov <kib@FreeBSD.org> |
Reduce the size of the interposing table and amount of cancellation-handling code in the libthr. Translate some syscalls into their more generic counterpart, and remove translated syscalls from the table. List of the affected syscalls: creat, open -> openat raise -> thr_kill sleep, usleep -> nanosleep pause -> sigsuspend wait, wait3, waitpid -> wait4 Suggested and reviewed by: jilles (previous version) Sponsored by: The FreeBSD Foundation MFC after: 1 week
|
#
1a744fef |
|
04-Jan-2015 |
Konstantin Belousov <kib@FreeBSD.org> |
Avoid calling internal libc function through PLT or accessing data though GOT, by staticizing and hiding. Add setter for __error_selector to hide it as well. Suggested and reviewed by: jilles Sponsored by: The FreeBSD Foundation MFC after: 1 week
|
#
8495e8b1 |
|
03-Jan-2015 |
Konstantin Belousov <kib@FreeBSD.org> |
Fix known issues which blow up the process after dlopen("libthr.so") (or loading a dso linked to libthr.so into process which was not linked against threading library). - Remove libthr interposers of the libc functions, including __error(). Instead, functions calls are indirected through the interposing table, similar to how pthread stubs in libc are already done. Libc by default points either to syscall trampolines or to existing libc implementations. On libthr load, libthr rewrites the pointers to the cancellable implementations already in libthr. The interposition table is separate from pthreads stubs indirection table to not pull pthreads stubs into static binaries. - Postpone the malloc(3) internal mutexes initialization until libthr is loaded. This avoids recursion between calloc(3) and static pthread_mutex_t initialization. - Reinstall signal handlers with wrapper on libthr load. The _rtld_is_dlopened(3) is used to avoid useless calls to sigaction(2) when libthr is statically referenced from the main binary. In the process, fix openat(2), swapcontext(2) and setcontext(2) interposing. The libc symbols were exported at different versions than libthr interposers. Export both libc and libthr versions from libc now, with default set to the higher version from libthr. Remove unused and disconnected swapcontext(3) userspace implementation from libc/gen. No objections from: deischen Tested by: pho, antoine (exp-run) (previous versions) Sponsored by: The FreeBSD Foundation MFC after: 1 week
|
#
442542b8 |
|
23-Aug-2013 |
Jilles Tjoelker <jilles@FreeBSD.org> |
libc: Access some unexported variables more efficiently (related to stdio).
|
#
869fd80f |
|
22-Jun-2012 |
Konstantin Belousov <kib@FreeBSD.org> |
Use struct vdso_timehands data to implement fast gettimeofday(2) and clock_gettime(2) functions if supported. The speedup seen in microbenchmarks is in range 4x-7x depending on the hardware. Only amd64 and i386 architectures are supported. Libc uses rdtsc and kernel data to calculate current time, if enabled by kernel. Hopefully, this code is going to migrate into vdso in some future. Discussed with: bde Reviewed by: jhb Tested by: flo MFC after: 1 month
|
#
46ffdf3b |
|
24-Apr-2012 |
Konstantin Belousov <kib@FreeBSD.org> |
Take the spinlock around clearing of the fp->_flags in fclose(3), which indicates the avaliability of FILE, to prevent possible reordering of the writes as seen by other CPUs. Reported by: Fengwei yin <yfw.bsd gmail com> Reviewed by: jhb MFC after: 1 week
|
#
a7d61fc1 |
|
17-Feb-2012 |
Konstantin Belousov <kib@FreeBSD.org> |
Fetch the aux vector for the static libc, and use the entries to initialize the cache of the system information as it was done for the dynamic libc. This removes several sysctls from the static binary startup. Use the aux vector to fill the single struct dl_phdr_info describing the static binary itself, to implement dl_iterate_phdr(3) for the static binaries. [1] Based on the submission by: John Marino <draco marino st> [1] Tested by: flo (sparc64) MFC after: 2 weeks
|
#
3e65b9c6 |
|
23-Dec-2011 |
Colin Percival <cperciva@FreeBSD.org> |
Fix a problem whereby a corrupt DNS record can cause named to crash. [11:06] Add an API for alerting internal libc routines to the presence of "unsafe" paths post-chroot, and use it in ftpd. [11:07] Fix a buffer overflow in telnetd. [11:08] Make pam_ssh ignore unpassphrased keys unless the "nullok" option is specified. [11:09] Add sanity checking of service names in pam_start. [11:10] Approved by: so (cperciva) Approved by: re (bz) Security: FreeBSD-SA-11:06.bind Security: FreeBSD-SA-11:07.chroot Security: FreeBSD-SA-11:08.telnetd Security: FreeBSD-SA-11:09.pam_ssh Security: FreeBSD-SA-11:10.pam
|
#
a7d5f7eb |
|
19-Oct-2010 |
Jamie Gritton <jamie@FreeBSD.org> |
A new jail(8) with a configuration file, to replace the work currently done by /etc/rc.d/jail.
|
#
f4213b90 |
|
24-Sep-2010 |
David Xu <davidxu@FreeBSD.org> |
To support stack unwinding for cancellation points, add -fexceptions flag for them, two functions _pthread_cancel_enter and _pthread_cancel_leave are added to let thread enter and leave a cancellation point, it also makes it possible that other functions can be cancellation points in libraries without having to be rewritten in libthr.
|
#
ea246b63 |
|
23-Aug-2010 |
Konstantin Belousov <kib@FreeBSD.org> |
On shared object unload, in __cxa_finalize, call and clear all installed atexit and __cxa_atexit handlers that are either installed by unloaded dso, or points to the functions provided by the dso. Use _rtld_addr_phdr to locate segment information from the address of private variable belonging to the dso, supplied by crtstuff.c. Provide utility function __elf_phdr_match_addr to do the match of address against dso executable segment. Call back into libthr from __cxa_finalize using weak __pthread_cxa_finalize symbol to remove any atfork handler which function points into unloaded object. The rtld needs private __pthread_cxa_finalize symbol to not require resolution of the weak undefined symbol at initialization time. This cannot work, since rtld is relocated before sym_zero is set up. Idea by: kan Reviewed by: kan (previous version) MFC after: 3 weeks
|
#
2793b018 |
|
17-Aug-2010 |
Konstantin Belousov <kib@FreeBSD.org> |
Use aux vector to get values for SSP canary, pagesize, pagesizes array, number of host CPUs and osreldate. This eliminates the last sysctl(2) calls from the dynamically linked image startup. No objections from: kan Tested by: marius (sparc64) MFC after: 1 month
|
#
fe0506d7 |
|
09-Mar-2010 |
Marcel Moolenaar <marcel@FreeBSD.org> |
Create the altix project branch. The altix project will add support for the SGI Altix 350 to FreeBSD/ia64. The hardware used for porting is a two-module system, consisting of a base compute module and a CPU expansion module. SGI's NUMAFlex architecture can be an excellent platform to test CPU affinity and NUMA-aware features in FreeBSD.
|
#
9b0f1823 |
|
04-Jan-2010 |
David Xu <davidxu@FreeBSD.org> |
Use umtx to implement process sharable semaphore, to make this work, now type sema_t is a structure which can be put in a shared memory area, and multiple processes can operate it concurrently. User can either use mmap(MAP_SHARED) + sem_init(pshared=1) or use sem_open() to initialize a shared semaphore. Named semaphore uses file system and is located in /tmp directory, and its file name is prefixed with 'SEMD', so now it is chroot or jail friendly. In simplist cases, both for named and un-named semaphore, userland code does not have to enter kernel to reduce/increase semaphore's count. The semaphore is designed to be crash-safe, it means even if an application is crashed in the middle of operating semaphore, the semaphore state is still safely recovered by later use, there is no waiter counter maintained by userland code. The main semaphore code is in libc and libthr only has some necessary stubs, this makes it possible that a non-threaded application can use semaphore without linking to thread library. Old semaphore implementation is kept libc to maintain binary compatibility. The kernel ksem API is no longer used in the new implemenation. Discussed on: threads@
|
#
5ff95453 |
|
17-Dec-2009 |
John Baldwin <jhb@FreeBSD.org> |
MFC 199606, 199614: Add an internal _once() method. This works identical to pthread_once(3) with the additional property that it is safe for routines in libc to use in both single-threaded and multi-threaded processes. Multi-threaded processes use the pthread_once() implementation from the threading library while single-threaded processes use a simplified "stub" version internal to libc.
|
#
4e1fc19c |
|
20-Nov-2009 |
John Baldwin <jhb@FreeBSD.org> |
Revert the previous change to pthread_once() stub in libc. It is actually a feature that libstdc++ depends on to simulate the behavior of libc's internal '__isthreaded' variable. One benefit of this is that _libc_once() is now private to _once_stub.c. Requested by: kan
|
#
5bcfe82e |
|
20-Nov-2009 |
John Baldwin <jhb@FreeBSD.org> |
Add an internal _once() method. This works identical to pthread_once(3) with the additional property that it is safe for routines in libc to use in both single-threaded and multi-threaded processes. Multi-threaded processes use the pthread_once() implementation from the threading library while single-threaded processes use a simplified "stub" version internal to libc. The libc stub-version of pthread_once() now also uses the simplified "stub" version as well instead of being a nop. Reviewed by: deischen, Matthew Fleming @ Isilon Suggested by: alc MFC after: 1 week
|
#
d7f03759 |
|
19-Oct-2008 |
Ulf Lilleengen <lulf@FreeBSD.org> |
- Import the HEAD csup code which is the basis for the cvsmode work.
|
#
d6742bfb |
|
26-Aug-2008 |
Jason Evans <jasone@FreeBSD.org> |
Add thread-specific caching for small size classes, based on magazines. This caching allows for completely lock-free allocation/deallocation in the steady state, at the expense of likely increased memory use and fragmentation. Reduce the default number of arenas to 2*ncpus, since thread-specific caching typically reduces arena contention. Modify size class spacing to include ranges of 2^n-spaced, quantum-spaced, cacheline-spaced, and subpage-spaced size classes. The advantages are: fewer size classes, reduced false cacheline sharing, and reduced internal fragmentation for allocations that are slightly over 512, 1024, etc. Increase RUN_MAX_SMALL, in order to limit fragmentation for the subpage-spaced size classes. Add a size-->bin lookup table for small sizes to simplify translating sizes to size classes. Include a hard-coded constant table that is used unless custom size class spacing is specified at run time. Add the ability to disable tiny size classes at compile time via MALLOC_TINY.
|
#
c605eea9 |
|
22-Jun-2008 |
Ed Schouten <ed@FreeBSD.org> |
Turn execvpe() into an internal libc routine. Adding exevpe() has caused some ports to break. Even though execvpe() is a useful routine, it does not conform to any standards. This patch is a little bit different from the patch sent to the mailing list. I forgot to remove execvpe from the Symbol.map (which does not seem to miscompile libc, though). Reviewed by: davidxu Approved by: philip
|
#
aea15cbc |
|
04-Apr-2008 |
Doug Rabson <dfr@FreeBSD.org> |
Add some compatibility code so that software which is built to use the new struct flock with l_sysid member can work properly on an an old kernel which doesn't support l_sysid. Sponsored by: Isilon Systems
|
#
4dd719bd |
|
04-Jul-2007 |
Peter Wemm <peter@FreeBSD.org> |
Change the C wrappers for mmap/lseek/pread/pwrite/truncate/ftruncate to call the pad-less versions of the corresponding syscalls if the running kernel supports it. Check kern.osreldate once per program and cache the result to select the appropriate syscall. This maintains userland compatability with kernel.old's from quite a while back. Approved by: re (kensmith)
|
#
7dcf45c0 |
|
12-Jan-2007 |
Warner Losh <imp@FreeBSD.org> |
Remove 3rd clause, renumber, ok per email
|
#
f4cd2a5b |
|
05-Mar-2006 |
Daniel Eischen <deischen@FreeBSD.org> |
Add some more pthread stubs so that librt can use them. The thread jump table has been resorted, so you need to keep libc, libpthread, and libthr in sync. Submitted by: xu
|
#
52828c0e |
|
12-Jan-2006 |
Jason Evans <jasone@FreeBSD.org> |
In preparation for a new malloc implementation: * Add posix_memalign(). * Move calloc() from calloc.c to malloc.c. Add a calloc() implementation in rtld-elf in order to make the loader happy (even though calloc() isn't used in rtld-elf). * Add _malloc_prefork() and _malloc_postfork(), and use them instead of directly manipulating __malloc_lock. Approved by: phk, markm (mentor)
|
#
2ba64027 |
|
12-Sep-2005 |
Stefan Farfeleder <stefanf@FreeBSD.org> |
Move the declaration of __cleanup to libc_private.h as it is used in both stdio/ and stdlib/. Don't define __cleanup twice.
|
#
ccd13c49 |
|
15-Aug-2004 |
Doug Rabson <dfr@FreeBSD.org> |
Add support for TLS in statically linked programs.
|
#
82358b1b |
|
05-Nov-2003 |
Daniel Eischen <deischen@FreeBSD.org> |
Remove #include of spinlock.h from libc_private.h. Declare spinlocks as struct _spinlock. Keep the typedef in for now; another set of changes may come around to clean up consumers of spinlocks. Requested by: bde
|
#
35870236 |
|
04-Nov-2003 |
Daniel Eischen <deischen@FreeBSD.org> |
Externalize malloc's spinlock so that a thread library can take it around an application's fork() call. Our new thread libraries (libthr, libpthread) can now have threads running while another thread calls fork(). In this case, it is possible for malloc to be left in an inconsistent state in the child. Our thread libraries, libpthread in particular, need to use malloc internally after a fork (in the child). Reviewed by: davidxu
|
#
2bbd7cf8 |
|
27-Feb-2003 |
Jacques Vidrine <nectar@FreeBSD.org> |
Eliminate 19 warnings in libc (at level WARNS=2) of the `implicit declaration of function' variety.
|
#
fcfc20c8 |
|
13-Nov-2002 |
Daniel Eischen <deischen@FreeBSD.org> |
Argh, change declaration of two-dimensional array so that it actually builds.
|
#
28c104a5 |
|
13-Nov-2002 |
Daniel Eischen <deischen@FreeBSD.org> |
Make this compile with whatever error-checking is enabled in buildworld and/or beast.
|
#
fb22a377 |
|
13-Nov-2002 |
Daniel Eischen <deischen@FreeBSD.org> |
Use a jump table (a la Solaris) for pthread routines with default entries in the table being stubs. While I'm here, add macros to auto-generate the stubs. A conforming threads library can override the stub routines by filling in the jump table. Add some entries to namespace.h and sync un-namespace.h to it. Also add a comment to remind folks to update un-namespace.h when changing namespace.h.
|
#
4cd01193 |
|
29-Mar-2002 |
Mark Murray <markm@FreeBSD.org> |
Do not use __progname directly (except in [gs]etprogname(3)). Also, make an internal _getprogname() that is used only inside libc. For libc, getprogname(3) is a weak symbol in case a function of the same name is defined in userland.
|
#
d201fe46 |
|
24-Jan-2001 |
Daniel Eischen <deischen@FreeBSD.org> |
Remove _THREAD_SAFE and make libc thread-safe by default by adding (weak definitions to) stubs for some of the pthread functions. If the threads library is linked in, the real pthread functions will pulled in. Use the following convention for system calls wrapped by the threads library: __sys_foo - actual system call _foo - weak definition to __sys_foo foo - weak definition to __sys_foo Change all libc uses of system calls wrapped by the threads library from foo to _foo. In order to define the prototypes for _foo(), we introduce namespace.h and un-namespace.h (suggested by bde). All files that need to reference these system calls, should include namespace.h before any standard includes, then include un-namespace.h after the standard includes and before any local includes. <db.h> is an exception and shouldn't be included in between namespace.h and un-namespace.h namespace.h will define foo to _foo, and un-namespace.h will undefine foo. Try to eliminate some of the recursive calls to MT-safe functions in libc/stdio in preparation for adding a mutex to FILE. We have recursive mutexes, but would like to avoid using them if possible. Remove uneeded includes of <errno.h> from a few files. Add $FreeBSD$ to a few files in order to pass commitprep. Approved by: -arch
|
#
7f3dea24 |
|
27-Aug-1999 |
Peter Wemm <peter@FreeBSD.org> |
$Id$ -> $FreeBSD$
|
#
e095485c |
|
05-May-1998 |
John Birrell <jb@FreeBSD.org> |
Remove leading underscores from the FILE lock functions that POSIX specifies.
|
#
01c70c00 |
|
11-Apr-1998 |
John Birrell <jb@FreeBSD.org> |
Add a private header file for libc/libc_r/libpthread to contain definitions for things like locking etc.
|