summaryrefslogtreecommitdiff
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
...
* Deprecate sranddev(3) APIConrad Meyer2019-12-144-26/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It serves no useful purpose and wasn't as popular as its equally meritless cousin, srandomdev(3). Setting aside the problems with rand(3) in general, the problem with this interface is that the seed isn't shared with the caller (other than by attacking the output of the generator, which is trivial, but not a hallmark of pleasant API design). The (arguable) utility of rand(3) or random(3) is as a semi-fast simulation generator which produces consistent results from a given seed. These are mutually at odd. Furthermore, sometimes people got the mistaken impression that a high quality random seed meant a weak generator like rand(3) or random(3) could be used for things like cryptographic key generation. This is absolutely not so. The API was never part of a standard and was not widely used in tree. Existing in-tree uses have all been removed. Possible replacement in out of tree codebases: char buf[3]; time_t t; time(t); strftime(buf, sizeof(buf), "%S", gmtime(&t)); srand(atoi(buf)); Relnotes: yes Notes: svn path=/head/; revision=355747
* [PowerPC] Fully define gdtoa settings on powerpc64.Brandon Bergren2019-12-131-0/+3
| | | | | | | | | | | | | | | | The settings in arith.h were not fully defined on powerpc64 after the gdtoa switchover. Generate them using arithchk.c, similar to what AMD64 did for r114814. Technically, none of this is necessary in FreeBSD gdtoa, but since the other platforms have full definitions, we might as well have full definitions too. Approved by: jhibbits (in irc) Differential Revision: https://reviews.freebsd.org/D22775 Notes: svn path=/head/; revision=355729
* [PowerPC] Fix SPE floating point environment manipulationBrandon Bergren2019-12-122-2/+2
| | | | | | | | | | | | | | | Fix multiple problems in the powerpcspe floating point code. * Endianness handling of the SPEFSCR in fenv.h was completely broken. * Ensure SPEFSCR synchronization requirements are being met. The __r.__d -> __r transformations were written by jhibbits. Reviewed by: jhibbits Differential Revision: https://reviews.freebsd.org/D22526 Notes: svn path=/head/; revision=355656
* Add sigsetop extensions commonly found in musl libc and glibcKyle Evans2019-12-126-4/+285
| | | | | | | | | | | | | | These functions (sigandset, sigisemptyset, sigorset) are commonly available in at least musl libc and glibc; sigorset, at least, has proven quite useful in qemu-bsd-user work for tracking the current process signal mask in a more self-documenting/aesthetically pleasing manner. Reviewed by: bapt, jilles, pfg MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22187 Notes: svn path=/head/; revision=355641
* Update Makefile.depend filesSimon J. Gerraty2019-12-112-2/+0
| | | | | | | | | | | | | Update a bunch of Makefile.depend files as a result of adding Makefile.depend.options files Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22494 Notes: svn path=/head/; revision=355617
* Add Makefile.depend.optionsSimon J. Gerraty2019-12-111-0/+8
| | | | | | | | | | | | | | | | | | | | Leaf directories that have dependencies impacted by options need a Makefile.depend.options file to avoid churn in Makefile.depend DIRDEPS for cases such as OPENSSL, TCP_WRAPPERS etc can be set in local.dirdeps-options.mk which can add to those set in Makefile.depend.options See share/mk/dirdeps-options.mk Reviewed by: bdrewery MFC after: 1 week Sponsored by: Juniper Networks Differential Revision: https://reviews.freebsd.org/D22469 Notes: svn path=/head/; revision=355616
* Only return EPERM from kill(-pid) when no process was signalled.Konstantin Belousov2019-12-071-5/+4
| | | | | | | | | | | | | | | | | As mandated by POSIX. Also clarify the kill(2) manpage. While there, restructure the code in killpg1() to use helper which keeps overall state of the process list iteration in the killpg1_ctx structued, later used to infer the error returned. Reported by: amdmi3 Reviewed by: jilles Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D22621 Notes: svn path=/head/; revision=355500
* clock_gettime(2): add a HISTORY sectionAlan Somers2019-12-071-1/+9
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=355489
* lio_listio(2): add a HISTORY sectionAlan Somers2019-12-071-1/+6
| | | | | | | MFC after: 2 weeks Notes: svn path=/head/; revision=355488
* Use "far" calls and branches so that lld uses valid relocations.John Baldwin2019-12-042-6/+10
| | | | | | | | | | | | | | Conditional branch and jump instructions do not always call via PLT stubs and thus will not honor LD_PRELOAD, etc. lld warns about using non-preemptible relocations for preemptible or unknown symbols whereas bfd does not (at least for RISC-V). Reviewed by: br, James Clarke Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D22658 Notes: svn path=/head/; revision=355403
* Use a single 'ld' to read the jmpbuf magic values instead of 'la; ld'.John Baldwin2019-12-042-8/+4
| | | | | | | | | | | | This saves an instruction in each case as well as an extra memory indirection via the GOT for PIC code. Reviewed by: br, James Clarke Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D22656 Notes: svn path=/head/; revision=355402
* Regularize my copyright noticeWarner Losh2019-12-0410-13/+3
| | | | | | | | | | | | o Remove All Rights Reserved from my notices o imp@FreeBSD.org everywhere o regularize punctiation, eliminate date ranges o Make sure that it's clear that I don't claim All Rights reserved by listing All Rights Reserved on same line as other copyright holders (but not me). Other such holders are also listed last where it's clear. Notes: svn path=/head/; revision=355394
* [PowerPC] Fix typo in _ctx_start on ppc32Brandon Bergren2019-11-231-1/+1
| | | | | | | | | | | | Theoretically, this was breaking the size calculation for the symbol. Noticed when doing a readthrough. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D22525 Notes: svn path=/head/; revision=355036
* Fix typos in the cpuset_{get,set}domain() man page.Mark Johnston2019-11-221-3/+5
| | | | | | | | MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=355000
* Document required size of buffer for elf_aux_info(3).Konstantin Belousov2019-11-171-11/+23
| | | | | | | | | | | | PR: 241884 Reported by: jbeich Reviewed by: brooks Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential revision: https://reviews.freebsd.org/D22380 Notes: svn path=/head/; revision=354787
* [PowerPC] Fix *context on ELFv2Brandon Bergren2019-11-162-0/+11
| | | | | | | | | | | | | Due to ELFv1 specific code in _ctx_start.S and makecontext.c, userspace context switching was completely broken on ELFv2. With this change, we now pass the libthr test suite. Approved by: jhibbits (mentor) Differential Revision: https://reviews.freebsd.org/D22421 Notes: svn path=/head/; revision=354780
* armv6 soft float build fixedWarner Losh2019-11-143-5/+5
| | | | | | | | | | | Add ifdefs in the assembler for soft-float compile case. Submitted by: Hiroki Mori Reviewed by: ray@ Differential Review: https://reviews.freebsd.org/D22352 Notes: svn path=/head/; revision=354700
* Improve the description of AT_EXECPATH availability.Brooks Davis2019-11-131-2/+3
| | | | | | | | Reported by: kib Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=354699
* elf_aux_info: Add support for AT_EXECPATH.Brooks Davis2019-11-132-2/+22
| | | | | | | | | | Reviewed by: emaste, sef MFC after: 3 days Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D22353 Notes: svn path=/head/; revision=354694
* ssp: further refine the conditional used for constructor priorityKyle Evans2019-11-131-1/+1
| | | | | | | | | | | | __has_attribute(__constructor__) is a better test for clang than defined(__clang__). Switch to it instead. While we're already here and touching it, pfg@ nailed down when GCC actually introduced the priority argument -- 4.3. Use that instead of our hammer-guess of GCC >= 5 for the sake of correctness. Notes: svn path=/head/; revision=354689
* ssp: rework the logic to use priority=200 on clang buildsKyle Evans2019-11-131-4/+6
| | | | | | | | | | | | | | The preproc logic was added at the last minute to appease GCC 4.2, and kevans@ did clearly not go back and double-check that the logic worked out for clang builds to use the new variant. It turns out that clang defines __GNUC__ == 4. Flip it around and check __clang__ as well, leaving a note to remove it later. Reported by: cem Notes: svn path=/head/; revision=354672
* ssp: add a priority to the __stack_chk_guard constructorKyle Evans2019-11-131-1/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | First, this commit is a NOP on GCC <= 4.x; this decidedly doesn't work cleanly on GCC 4.2, and it will be gone soon anyways so I chose not to dump time into figuring out if there's a way to make it work. xtoolchain-gcc, clocking in as GCC6, can cope with it just fine and later versions are also generally ok with the syntax. I suspect very few users are running GCC4.2 built worlds and also experiencing potential fallout from the status quo. For dynamically linked applications, this change also means very little. rtld will run libc ctors before most others, so the situation is approximately a NOP for these as well. The real cause for this change is statically linked applications doing almost questionable things in their constructors. qemu-user-static, for instance, creates a thread in a global constructor for their async rcu callbacks. In general, this works in other places- - On OpenBSD, __stack_chk_guard is stored in an .openbsd.randomdata section that's initialized by the kernel in the static case, or ld.so in the dynamic case - On Linux, __stack_chk_guard is apparently stored in TLS and such a problem is circumvented there because the value is presumed stable in the new thread. On FreeBSD, the rcu thread creation ctor and __guard_setup are both unmarked priority. qemu-user-static spins up the rcu thread prior to __guard_setup which starts making function calls- some of these are sprinkled with the canary. In the middle of one of these functions, __guard_setup is invoked in the main thread and __stack_chk_guard changes- qemu-user-static is promptly terminated for an SSP violation that didn't actually happen. This is not an all-too-common problem. We circumvent it here by giving the __stack_chk_guard constructor a solid priority. 200 was chosen because that gives static applications ample range (down to 101) for working around it if they really need to. I suspect most applications will "just work" as expected- the default/non-prioritized flavor of __constructor__ functions run last, and the canary is generally not expected to change as of this point at the very least. This took approximately three weeks of spare time debugging to pin down. PR: 241905 Notes: svn path=/head/; revision=354669
* Revert r354605: Update jemalloc to version 5.2.1.Jason Evans2019-11-111-3/+2
| | | | | | | Compilation fails for non-llvm-based platforms. Notes: svn path=/head/; revision=354606
* Update jemalloc to version 5.2.1.Jason Evans2019-11-111-2/+3
| | | | Notes: svn path=/head/; revision=354605
* Update the copy_file_range man page to reflect the semantic changeRick Macklem2019-11-101-1/+14
| | | | | | | | | done by r354574. This is a content change. Notes: svn path=/head/; revision=354575
* Update the copy_file_range.2 man page to reflect the semantic changeRick Macklem2019-11-081-8/+9
| | | | | | | | | implemented by r354564. This is a content change. Notes: svn path=/head/; revision=354565
* Add __isnan()/__isnanf() aliases for compatibility with glibc and CUDADimitry Andric2019-11-021-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Even though clang comes with a number of internal CUDA wrapper headers, compiling sample CUDA programs will result in errors similar to: In file included from <built-in>:1: In file included from /usr/lib/clang/9.0.0/include/__clang_cuda_runtime_wrapper.h:204: /usr/home/arr/cuda/var/cuda-repo-10-0-local-10.0.130-410.48/usr/local/cuda-10.0//include/crt/math_functions.hpp:2910:7: error: no matching function for call to '__isnan' if (__isnan(a)) { ^~~~~~~ /usr/lib/clang/9.0.0/include/__clang_cuda_device_functions.h:460:16: note: candidate function not viable: call to __device__ function from __host__ function __DEVICE__ int __isnan(double __a) { return __nv_isnand(__a); } ^ CUDA expects __isnan() and __isnanf() declarations to be available, which are glibc specific extensions, equivalent to the regular isnan() and isnanf(). To provide these, define __isnan() and __isnanf() as aliases of the already existing static inline functions __inline_isnan() and __inline_isnanf() from math.h. Reported by: arrowd PR: 241550 MFC after: 1 week Notes: svn path=/head/; revision=354255
* Fix various -Wpointer-compare warningsBrooks Davis2019-10-084-8/+8
| | | | | | | | | | | | | | | | | | | | This warning (comparing a pointer against a zero character literal rather than NULL) has existed since GCC 7.1.0, and was recently added to Clang trunk. Almost all of these are harmless, except for fwcontrol's str2node, which needs to both guard against dereferencing a NULL pointer (though in practice it appears none of the callers will ever pass one in), as well as ensure it doesn't parse the empty string as node 0 due to strtol's awkward interface. Submitted by: James Clarke <jtrc27@jrtc27.com> Obtained from: CheriBSD Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D21914 Notes: svn path=/head/; revision=353326
* memfd_create(3): Don't actually force hugetlb size with MFD_HUGETLBKyle Evans2019-09-291-3/+0
| | | | | | | | The size flags are only required to select a size on systems that support multiple sizes. MFD_HUGETLB by itself is valid. Notes: svn path=/head/; revision=352870
* Revert the mode_t -> int changes and add a warning in the BUGS section instead.Warner Losh2019-09-282-4/+16
| | | | | | | | | | | | | While FreeBSD's implementation of these expect an int inside of libc, that's an implementation detail that we can hide from the user as it's the natural promotion of the current mode_t type and before it is used in the kernel, it's converted back to the narrower type that's the current definition of mode_t. As such, documenting int is at best confusing and at worst misleading. Instead add a note that these args are variadic and as such calling conventions may differ from non-variadic arguments. Notes: svn path=/head/; revision=352846
* Document varadic args as int, since you can't have short varadic args (they areWarner Losh2019-09-272-2/+2
| | | | | | | | | | | | | | | | promoted to ints). - `mode_t` is `uint16_t` (`sys/sys/_types.h`) - `openat` takes variadic args - variadic args cannot be 16-bit, and indeed the code uses int - the manpage currently kinda implies the argument is 16-bit by saying `mode_t` Prompted by Rust things: https://github.com/tailhook/openat/issues/21 Submitted by: Greg V at unrelenting Differential Revision: https://reviews.freebsd.org/D21816 Notes: svn path=/head/; revision=352795
* Further normalize copyright noticesKyle Evans2019-09-261-1/+0
| | | | | | | | | | | - s/C/c/ where I've been inconsistent about it - +SPDX tags - Remove "All rights reserved" where possible Requested by: rgrimes (all rights reserved) Notes: svn path=/head/; revision=352757
* Correct mistake in MLINKS introduced in r352747David Bright2019-09-261-1/+1
| | | | | | | | | | Messed up a merge conflict resolution and didn't catch that before commit. Sponsored by: Dell EMC Isilon Notes: svn path=/head/; revision=352756
* Add an shm_rename syscallDavid Bright2019-09-263-12/+84
| | | | | | | | | | | | | | | | | | | | | | | | | | Add an atomic shm rename operation, similar in spirit to a file rename. Atomically unlink an shm from a source path and link it to a destination path. If an existing shm is linked at the destination path, unlink it as part of the same atomic operation. The caller needs the same permissions as shm_unlink to the shm being renamed, and the same permissions for the shm at the destination which is being unlinked, if it exists. If those fail, EACCES is returned, as with the other shm_* syscalls. truss support is included; audit support will come later. This commit includes only the implementation; the sysent-generated bits will come in a follow-on commit. Submitted by: Matthew Bryan <matthew.bryan@isilon.com> Reviewed by: jilles (earlier revision) Reviewed by: brueffer (manpages, earlier revision) Relnotes: yes Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D21423 Notes: svn path=/head/; revision=352747
* Add SPDX tags to recently added filesKyle Evans2019-09-251-0/+2
| | | | | | | Reported by: Pawel Biernacki Notes: svn path=/head/; revision=352727
* posix_spawn(3): handle potential signal issues with vforkKyle Evans2019-09-252-28/+103
| | | | | | | | | | | | | | | | | | | | | | | | Described in [1], signal handlers running in a vfork child have opportunities to corrupt the parent's state. Address this by adding a new rfork(2) flag, RFSPAWN, that has vfork(2) semantics but also resets signal handlers in the child during creation. x86 uses rfork_thread(3) instead of a direct rfork(2) because rfork with RFMEM/RFSPAWN cannot work when the return address is stored on the stack -- further information about this problem is described under RFMEM in the rfork(2) man page. Addressing this has been identified as a prerequisite to using posix_spawn in subprocess on FreeBSD [2]. [1] https://ewontfix.com/7/ [2] https://bugs.python.org/issue35823 Reviewed by: jilles, kib Differential Revision: https://reviews.freebsd.org/D19058 Notes: svn path=/head/; revision=352712
* rfork(2): add RFSPAWN flagKyle Evans2019-09-251-2/+12
| | | | | | | | | | | | | | When RFSPAWN is passed, rfork exhibits vfork(2) semantics but also resets signal handlers in the child during creation to avoid a point of corruption of parent state from the child. This flag will be used by posix_spawn(3) to handle potential signal issues. Reviewed by: jilles, kib Differential Revision: https://reviews.freebsd.org/D19058 Notes: svn path=/head/; revision=352711
* sysent: regenerate after r352705Kyle Evans2019-09-251-4/+0
| | | | | | | | This also implements it, fixes kdump, and removes no longer needed bits from lib/libc/sys/shm_open.c for the interim. Notes: svn path=/head/; revision=352706
* Add linux-compatible memfd_createKyle Evans2019-09-255-5/+211
| | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=352703
* Update fcntl(2) after r352695Kyle Evans2019-09-251-1/+62
| | | | Notes: svn path=/head/; revision=352696
* remove obsolete i386 MD memchr implementationEd Maste2019-09-252-62/+0
| | | | | | | | | | | | | | | bde reports (in a reply to r351700 commit mail): This uses scasb, which was last optimal on the 8086, or perhaps the original i386. On freefall, it is several times slower than the naive translation of the naive C code. Reported by: bde Reviewed by: kib, markj Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21785 Notes: svn path=/head/; revision=352689
* lib/libc/regex: fix build with REDEBUG definedYuri Pankov2019-09-242-7/+1
| | | | | | | | Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D21760 Notes: svn path=/head/; revision=352651
* Add two options to allow mount to avoid covering up existing mount points.Sean Eric Fagan2019-09-231-1/+15
| | | | | | | | | | | | | | | | | | | The two options are * nocover/cover: Prevent/allow mounting over an existing root mountpoint. E.g., "mount -t ufs -o nocover /dev/sd1a /usr/local" will fail if /usr/local is already a mountpoint. * emptydir/noemptydir: Prevent/allow mounting on a non-empty directory. E.g., "mount -t ufs -o emptydir /dev/sd1a /usr" will fail. Neither of these options is intended to be a default, for historical and compatibility reasons. Reviewed by: allanjude, kib Differential Revision: https://reviews.freebsd.org/D21458 Notes: svn path=/head/; revision=352614
* sysctl: use names instead of magic numbers.Konstantin Belousov2019-09-181-2/+2
| | | | | | | | | | | | Replace magic numbers with symbols for internal sysctl operations. Convert in-kernel and libc consumers. Submitted by: Pawel Biernacki MFC after: 1 week Differential revision: https://reviews.freebsd.org/D21693 Notes: svn path=/head/; revision=352486
* Return EISDIR when directory is opened with O_CREAT without O_DIRECTORY.Konstantin Belousov2019-09-171-1/+6
| | | | | | | | | | | Reviewed by: bcr (man page), emaste (previous version) PR: 240452 Sponsored by: The FreeBSD Foundation MFC after: 1 week DIfferential revision: https://reviews.freebsd.org/D21634 Notes: svn path=/head/; revision=352455
* Increase the size of the send and receive buffers for YP client rpcKonstantin Belousov2019-09-161-1/+1
| | | | | | | | | | | | | | | | | | | calls to max allowed UDP datagram size. Since max allowed size both for keys and values where increased, the old sizes of around 1K cause ypmatch(3) failures, while plain maps fetches work. The buffers were reduced in r34146 from default UDP rpcclient values to 1024/2304 due to the key and value size being 1K. Reviewed by: slavash Sponsored by: Mellanox Technologies MFC after: 1 week Differential revision: https://reviews.freebsd.org/D21586 Notes: svn path=/head/; revision=352384
* Improve the description of big5(5)Li-Wen Hsu2019-09-141-2/+9
| | | | | | | | | | | | | | | | - Fix the statement that big5 is a de facto standard of Traditional Chinese text [1] - Add a BUGS section describes the problem of big5 and suggests use utf8 PR: 189095 Submitted by: Brennan Vincent <brennan@umanwizard.com> [1] Reviewed by: Ting-Wei Lan <lantw44@gmail.com> MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21622 Notes: svn path=/head/; revision=352315
* getsockopt.2: clarify that SO_TIMESTAMP is not 100% reliableAlan Somers2019-09-111-2/+3
| | | | | | | | | | | | | | When SO_TIMESTAMP is set, the kernel will attempt to attach a timestamp as ancillary data to each IP datagram that is received on the socket. However, it may fail, for example due to insufficient memory. In that case the packet will still be received but not timestamp will be attached. Reviewed by: kib MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D21607 Notes: svn path=/head/; revision=352231
* In FreeBSD 11 localedef(1) has replaced the mklocale(1) and colldef(1)Baptiste Daroussin2019-09-103-8/+7
| | | | | | | | | tools to generate the locales data. state it in the libc manpages. MFC after: 3 days Notes: svn path=/head/; revision=352127
* Fix cpuwhich_t column widthMitchell Horne2019-09-081-1/+1
| | | | | | | | | Not bumping .Dd since this is purely a format change. Approved by: markj (mentor) Notes: svn path=/head/; revision=352048