summaryrefslogtreecommitdiff
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
* MFC r339531,r339579,r340252,r340463,r340464,340472,r340587Mateusz Guzik2018-11-204-73/+91
| | | | | | | | | | | | | | | amd64: tidy up memset to have rax set earlier for small sizes amd64: finish the tail in memset with an overlapping store amd64: align memset buffers to 16 bytes before using rep stos amd64: convert libc bzero to a C func to avoid future bloat amd64: sync up libc memset with the kernel version amd64: handle small memset buffers with overlapping stores Fix -DNO_CLEAN amd64 build after r340463 Approved by: re (gjb) Notes: svn path=/releng/12.0/; revision=340688
* Follow up on r331936. gets_s(3) will also fail in the same way thatCy Schubert2018-10-281-0/+2
| | | | | | | | | | gets(3) does. This was missed in r331936. Reported by: emaste@ Approved by: re (kib@) Notes: svn path=/stable/12/; revision=339828
* MFC r339489:Yuri Pankov2018-10-273-103/+48
| | | | | | | | | | | | | | | | | Add -b/-l options to localedef(1) to specify output endianness and use it appropriately when building share/ctypedef and share/colldef. This makes the resulting locale data in EL->EB (amd64->powerpc64) cross build and in the native EB build match. Revert the changes done to libc in r308170 as they are no longer needed. PR: 231965 Reviewed by: bapt, emaste, sbruno, 0mp Approved by: re (gjb), kib (mentor) Differential Revision: https://reviews.freebsd.org/D17603 Notes: svn path=/stable/12/; revision=339825
* strptime: fix parsing of tm_year when both %C and %y appear in theYuri Pankov2018-10-171-9/+17
| | | | | | | | | | | | | | | | | | format string in arbitrary order. This makes the related test cases in lib/libc/tests/time (not yet connected to the build) pass. While here, don't error on negative tm_year value based on the APPLICATION USAGE in http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/time.h.html (glibc does the same): tm_year is a signed value; therefore, years before 1900 may be represented. Approved by: re (gjb), kib (mentor) Differential Revision: https://reviews.freebsd.org/D17550 Notes: svn path=/head/; revision=339408
* Get rid unneccessary useless calls to lseek(2) from getgrent(3).Edward Tomasz Napierala2018-10-161-17/+31
| | | | | | | | | | | | | | | | | | | | | Looks like this: fstatat(AT_FDCWD,"/etc/nsswitch.conf",{ mode=-rw-r--r-- ,inode=2167001,size=390,blksize=32768 },0x0) = 0 (0x0) open("/etc/group",O_RDONLY|O_CLOEXEC,0666) = 3 (0x3) fstat(3,{ mode=-rw-r--r-- ,inode=2166927,size=919,blksize=32768 }) = 0 (0x0) -lseek(3,0x0,SEEK_CUR) = 0 (0x0) -lseek(3,0x0,SEEK_SET) = 0 (0x0) read(3,"# $FreeBSD: release/10.0.0/etc/g"...,32768) = 919 (0x397) close(3) = 0 (0x0) Reviewed by: kib Approved by: re (gjb) MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D17571 Notes: svn path=/head/; revision=339387
* Avoid OOB reads in memmem(3).Gleb Smirnoff2018-10-151-9/+9
| | | | | | | | | | | | | | | | commit 51bdcdc424bd7169c8cccdc2de7cad17f5ea0f70 Author: Alexander Monakov <amonakov@ispras.ru> Date: Fri Jun 30 00:35:33 2017 +0300 fix OOB reads in Xbyte_memmem Reported by Leah Neukirchen. Reviewed by: emaste Approved by: re (kib) Notes: svn path=/head/; revision=339370
* Prevent flex(1) from generating calls to isatty(3) - and, in turn,Edward Tomasz Napierala2018-10-151-0/+1
| | | | | | | | | | | | | TIOCGETA ioctls - when parsing nsswitch.conf(5). Reviewed by: imp, markj Approved by: re (gjb) MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D17564 Notes: svn path=/head/; revision=339368
* Don't call dlopen(3) for built-in NSS types - "cache", "compat",Edward Tomasz Napierala2018-10-152-7/+14
| | | | | | | | | | | | | | "dns", "files", "db", and "nis". It saves some path lookups during binary startup. Reviewed by: markj Approved by: re (gjb, kib) MFC after: 2 weeks Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D17557 Notes: svn path=/head/; revision=339363
* Add .Xrs to kqueue(2) from pdfork(2) and procdesc(4), to make EVFILT_PROCDESCEdward Tomasz Napierala2018-10-141-1/+2
| | | | | | | | | | | easier to find. Approved by: re (rgrimes) MFC after: 2 weeks Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=339356
* amd64: convert libc bcopy to a C func to avoid future bloatMateusz Guzik2018-10-133-104/+15
| | | | | | | | | | | | | | | | | The function is of limited use and is an almost a direct clone of memmove/memcpy (with arguments swapped). Introduction of ERMS variants of string routines would mean avoidable growth of libc. bcopy will get redefined to a __builtin_memmove later on with this symbol only left for compatibility. Reviewed by: kib Approved by: re (gjb) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17539 Notes: svn path=/head/; revision=339348
* amd64: import updated kernel memmove to libcMateusz Guzik2018-10-132-6/+271
| | | | | | | | | | | | | | bcopy is left alone as it is expected to be converted to a C func. Due to header mess ALIGN_TEXT is temporarily defined explicitly in memmove.S Reviewed by: kib Approved by: re (gjb) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17538 Notes: svn path=/head/; revision=339347
* strptime: disallow zero hour for %I (defined by POSIX as [01,12]) and %lYuri Pankov2018-10-131-1/+1
| | | | | | | | | | (extension, defined in strftime(3) as 1-12). Approved by: re (gjb), kib (mentor) Differential Revision: https://reviews.freebsd.org/D17543 Notes: svn path=/head/; revision=339346
* Document that sendfile(2) can return ENOTCAPABLEAllan Jude2018-10-131-1/+7
| | | | | | | | | PR: 232207 Submitted by: Enji Cooper <yaneurabeya@gmail.com> Approved by: re (rgrimes) Notes: svn path=/head/; revision=339343
* Disallow zero day of month from strptime("%d").Konstantin Belousov2018-10-081-1/+1
| | | | | | | | | | | | | | It is required by POSIX, specified in our man page, and followed by Linux. PR: 232072 Reported by: miguel_tete17@hotmail.com Sponsored by: The FreeBSD Foundation Approved by: re (gjb) MFC after: 1 week Notes: svn path=/head/; revision=339241
* amd64: import updated kernel memset to libcMateusz Guzik2018-10-051-12/+66
| | | | | | | | | | | | | | | See r339205 for details. An unused ERMS support is retained in the macro. It will be activated after ifunc support lands. Reviewed by: kib Approved by: re (gjb) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17405 Notes: svn path=/head/; revision=339206
* amd64: reimplement libc memset and bzero with kernel memsetMateusz Guzik2018-10-012-91/+66
| | | | | | | | | | | | | | | | | | This is a depessimization, see r334537 for an explanation. Routines remain significantly slower than they have to be. bzero was removed from the kernel but remains in libc. Macroify to accommodate differences to memset (no return value, always setting to 0). The bzero.S file is left in place due to libc build magic which pulls in a C variant if a matching .S file is missing. Reviewed by: kib Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D17355 Notes: svn path=/head/; revision=339077
* amd64: remove unnecessary cld from libc memcpy/bcopyMateusz Guzik2018-09-291-1/+0
| | | | | | | | | | The ABI specifies the direction forward on function call, making the cld instruction redundant. Approved by: re (kib) Notes: svn path=/head/; revision=339011
* amd64: reimplement libc memcmp and bcmp with kernel memcmpMateusz Guzik2018-09-272-51/+222
| | | | | | | | | | | | | | | | | | | | | | | Both are significantly slower than hand-coded loops. See r338963 for kernel commit. bcmp differs from memcmp by always returning 1 when a difference is found, as opposed to going for a value bigger or lower than 0 depending on what it is. This means it can do less work. For now the code is duplicated and modified. This will get deduplicated after another round of optimization when memcmp will get a longer-term form. Both tested with the glibc suite. While the suite does not have a test for bcmp, I created a wrapper routine which verified that values match (0 vs 0, 1 vs non-zero). Reviewed by: kib Approved by: re (gjb) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17336 Notes: svn path=/head/; revision=338973
* Move libc linker ifunc test to build target onlyEd Maste2018-09-241-5/+6
| | | | | | | | | | | Targets like 'cleandir' must not depend on toolchain capabilities. Reported by: delphij, Shawn Webb Approved by: re (kib) Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=338903
* libc: require ifunc-capable linker for amd64/i386Ed Maste2018-09-211-0/+5
| | | | | | | | | | | We expect to introduce optimized libc routines in the near future, which requires use of a linker that supports ifuncs. Approved by: re (gjb, kib) Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=338861
* Move mac.conf to lib/libc/posix1e/Brad Davis2018-09-182-0/+19
| | | | | | | | | | This leverages CONFS to handle the install of the config file. Approved by: re (blanket, pkgbase), will (mentor) Differential Revision: https://reviews.freebsd.org/D17162 Notes: svn path=/head/; revision=338745
* Fix CONFS to append the value in this case.Brad Davis2018-09-181-1/+1
| | | | | | | Approved by: re (blanket, pkgbase), will (mentor) Notes: svn path=/head/; revision=338744
* Move rpc and netconfig to lib/libc/rpc/Brad Davis2018-09-173-0/+88
| | | | | | | | | | | | | | This uses relative paths to make it more specific to avoid any potential future problems with .PATH and leverages CONFS. libc was picked as the destination location for these because of the syscalls that use these files as the lowest level place they are referenced. Approved by: re (gjb), will (mentor) Differential Revision: https://reviews.freebsd.org/D17163 Notes: svn path=/head/; revision=338732
* Move hosts, hosts.equiv, networks, nsswitch.conf, protocols to lib/libc/net/Brad Davis2018-09-176-0/+232
| | | | | | | | | | | | | | This uses relative paths to make it more specific to avoid any potential future problems with .PATH and leverages CONFS. libc was picked as the destination location for these because of the syscalls that use these files as the lowest level place they are referenced. Approved by: re (gjb), will (mentor) Differential Revision: https://reviews.freebsd.org/D17164 Notes: svn path=/head/; revision=338729
* amd64: depessimize userspace memcpy/memmove/bcopyMateusz Guzik2018-09-172-4/+16
| | | | | | | | | | | | | The change resembles what was done in r334537 for kernel routines. While here take care of i386 variants. Note that primitives remain suboptimal. Reviewed by: kib (previous version) Approved by: re (gjb) Differential Revision: https://reviews.freebsd.org/D17167 Notes: svn path=/head/; revision=338713
* Add SOL_SOCKET level socket option with name SO_DOMAIN to getMichael Tuexen2018-08-211-1/+2
| | | | | | | | | | | | | | the domain of a socket. This is helpful when testing and Solaris and Linux have the same socket option using the same name. Reviewed by: bcr@, rrs@ Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D16791 Notes: svn path=/head/; revision=338136
* In r331279 the code used ENOSYS to check the existence of getrandom(2).Xin LI2018-08-201-8/+29
| | | | | | | | | | | | | | | | | | This will only work if the caller already handles SIGSYS, which is not always the case. Address this by checking osreldate instead. Note that because there was not __FreeBSD_version bump when the system call was added, use 1200061 (r332100) which is the first bump after the introduction of the system call. PR: 230762 Reported by: Jenkins via Mark Millard Reviewed by: cem Differential Revision: https://reviews.freebsd.org/D16807 Notes: svn path=/head/; revision=338084
* Document socket control message routines for ancillary data access (CMSG_DATA).Mateusz Piotrowski2018-08-193-4/+7
| | | | | | | | | | | PR: 227777 Reviewed by: bcr, eadler Approved by: mat (mentor), manpages (bcr) Obtained from: OpenBSD Differential Revision: https://reviews.freebsd.org/D15215 Notes: svn path=/head/; revision=338060
* Update userland arc4random() with OpenBSD's Chacha20 based arc4random().Xin LI2018-08-198-241/+363
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=338059
* Provide set_constraint_handler_s(3) man page.Konstantin Belousov2018-08-193-2/+155
| | | | | | | | | | | | Mention abort_handler_s(3) and ignore_handler_s(3), provide cross-reference from memset(3). Submitted by: Yuri Pankov <yuripv@yuripv.net> MFC after: 3 days Differential revision: https://reviews.freebsd.org/D16797 Notes: svn path=/head/; revision=338051
* Clarify that memset_s(3) requires __STDC_WANT_LIB_EXT1__ for visibility.Konstantin Belousov2018-08-191-5/+5
| | | | | | | | | | | Fix typos and other nits. Submitted by: Yuri Pankov <yuripv@yuripv.net> MFC after: 3 days Differential revision: https://reviews.freebsd.org/D16797 Notes: svn path=/head/; revision=338049
* Use tab for indent.Konstantin Belousov2018-08-191-1/+1
| | | | | | | | Submitted by: Yuri Pankov <yuripv@yuripv.net> MFC after: 3 days Notes: svn path=/head/; revision=338048
* Workaround ECAPMODE for kernels between revision [331280, 337999)Xin LI2018-08-181-1/+1
| | | | | | | where getrandom(2) is not available in capability mode. Notes: svn path=/head/; revision=338011
* Split arc4random_uniform into it's own file and sync with OpenBSD.Xin LI2018-08-183-35/+59
| | | | | | | | | PR: 182610 Obtained from: OpenBSD MFC after: 2 weeks Notes: svn path=/head/; revision=337997
* Add pthread_get_name_np(3).Konstantin Belousov2018-08-172-0/+2
| | | | | | | | | | | | | | | | The function retrieves the thread name previously set by pthread_set_name_np(3). The name is cached in the process memory. Requested by: Willem Jan Withagen <wjw@digiware.nl> Man page update: Yuri Pankov <yuripv@yuripv.net> Reviewed by: ian (previous version) Discussed with: arichardson, bjk (man page) Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Differential revision: https://reviews.freebsd.org/D16702 Notes: svn path=/head/; revision=337983
* Fix style nits.Mariusz Zaborski2018-08-171-3/+3
| | | | Notes: svn path=/head/; revision=337966
* Revert r337922, except for some documention-only bits. This needs to waitJamie Gritton2018-08-161-15/+100
| | | | | | | | | until user is changed to stop using jail(2). Differential Revision: D14791 Notes: svn path=/head/; revision=337925
* Put jail(2) under COMPAT_FREEBSD11. It has been the "old" way of creatingJamie Gritton2018-08-162-104/+20
| | | | | | | | | | | | | | | | | jails since FreeBSD 7. Along with the system call, put the various security.jail.allow_foo and security.jail.foo_allowed sysctls partly under COMPAT_FREEBSD11 (or BURN_BRIDGES). These sysctls had two disparate uses: on the system side, they were global permissions for jails created via jail(2) which lacked fine-grained permission controls; inside a jail, they're read-only descriptions of what the current jail is allowed to do. The first use is obsolete along with jail(2), but keep them for the second-read-only use. Differential Revision: D14791 Notes: svn path=/head/; revision=337922
* Allow the use of TCP instead of UDP for queries by setting options usevcBjoern A. Zeeb2018-08-161-0/+2
| | | | | | | | | | | in resolv.conf which sets RES_USEVC. Reviewed by: ume MFC after: 17 days Differential Revision: https://reviews.freebsd.org/D16607 Notes: svn path=/head/; revision=337904
* getopt_long(3): Document behavior of leading characters in optstringKyle Evans2018-08-121-2/+43
| | | | | | | | | | | | | | | | | | Leading '+', '-', and ':' in optstring have special meaning. We briefly mention that the first two have special meaning in that we say POSIXLY_CORRECT turns them off, but we don't actually document their meaning. Add a paragraph to RETURN VALUES explaining how they control the treatment of non-option arguments. A leading ':' has no mention; add a note that it suppresses warnings about missing arguments. Reviewed by: jilles MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D14142 Notes: svn path=/head/; revision=337666
* Update man page to include FreeBSD-specific details.Warner Losh2018-08-101-9/+19
| | | | | | | | | | | | While this implements a standards-conforming C11 function, there's implementation details the programmer needs to know. Include those here. Make changes inspired by comments on the initial review as well, though mostly this involves stealing the epoch verbage from gettimeofday(2). Add myself to authors since I've now changed a substantial amount of this man page. Notes: svn path=/head/; revision=337578
* Remove assert.h and commented out _DIAGASSERT.Warner Losh2018-08-101-3/+0
| | | | | | | | | | | | Remove assert.h and _DIAGASSERT to create a paper-trail of changes from NetBSD. Specifically didn't fix other style issues since I don't want this to diverge from the NetBSD original too much and that's too niggling a change to be worth future merge hassles. Differential Review: https://reviews.freebsd.org/D16649 Notes: svn path=/head/; revision=337577
* Bring in timespce_get form NetBSD.Warner Losh2018-08-104-0/+136
| | | | | | | | | | | | | | Bring in the functionality for timespec_get from NetBSD. I've lightly edited the .c file to remove _DIAGASSERT because FreeBSD doesn't have that functionality and the typical #define'ing it to assert isn't right here. The man page is verbatim from NetBSD, but will be revised as part of a larger cleanup of the time man pages (they are inconsistent and vague in all the wrong places). Differential Review: https://reviews.freebsd.org/D16649 Notes: svn path=/head/; revision=337576
* libc: fix cases of undefined behavior.Pedro F. Giffuni2018-08-072-4/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These were found by the Undefined Behavious GsoC project at NetBSD: Avoid undefined behavior in ftok(3) Do not change the signedness bit with a left shift operation. Cast to unsigned integer to prevent this. ftok.c:56:10, left shift of 123456789 by 24 places cannot be represented in type 'int' ftok.c:56:10, left shift of 4160 by 24 places cannot be represented in type 'int' Avoid undefined behavior in an inet_addr.c Do not change the signedness bit with a left shift operation. Cast to unsigned integer to prevent this. inet_addr.c:218:20, left shift of 131 by 24 places cannot be represented in type 'int' Detected with micro-UBSan in the user mode. Obtained from: NetBSD MFC after: 2 weeks Notes: svn path=/head/; revision=337422
* settimeofday(2): Remove stale note about timezoneConrad Meyer2018-08-041-6/+1
| | | | | | | | | Contrary to the removed comment, the kernel does appear to use the timezone argument of settimeofday. The comment dates to the BSD4.4 import; I assume it is just stale. Notes: svn path=/head/; revision=337334
* MAXLOGNAME changed to 33 in r243023.Ruslan Bukin2018-08-032-2/+2
| | | | | | | | | Update man pages. Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=337264
* exec.3: Add BUGS section and document non-FreeBSD portabilityConrad Meyer2018-07-281-0/+52
| | | | | | | Requested by: kib (in part) Notes: svn path=/head/; revision=336852
* Move etc/shells to lib/libc/gen with getusershell(3).Brad Davis2018-07-282-0/+11
| | | | | | | | Approved by: will (mentor) Differential Revision: https://reviews.freebsd.org/D16467 Notes: svn path=/head/; revision=336840
* Clean up execl*(3) manual page prototype formattingConrad Meyer2018-07-281-9/+4
| | | | | | | | | | | | | | | | | | | | Rendering of execle was missing a comma between the NULL argument and envp. For unclear reasons, POSIX' definition of these routines comments out the mandatory trailing NULL argument. That seems unnecessary and probably (reasonably) confuses mdoc. For unclear reasons, POSIX' definition of these routines spells NULL as "(char *)0." This is needlessly unclear. One guess might be that POSIX targets more exotic computer architectures than FreeBSD does. Fortunately, there is no such problem on any reasonable platform for FreeBSD to support. Spell NULL as NULL. The comma was probably removed in r117204 while the comment and creative spelling of NULL were added in r116537 (both 15 years ago). Notes: svn path=/head/; revision=336835
* Revert r336773: it removed too much.Warner Losh2018-07-272-0/+1792
| | | | | | | | | | r336773 removed all things xscale. However, some things xscale are really armv5. Revert that entirely. A more modest removal will follow. Noticed by: andrew@ Notes: svn path=/head/; revision=336783