summaryrefslogtreecommitdiff
path: root/lib/libc
Commit message (Collapse)AuthorAgeFilesLines
...
* Bounds check again after advancing cp, otherwise we have a possibleCy Schubert2019-09-051-2/+2
| | | | | | | | | | | | | | | | | heap buffer overflow. This was discovered by a Google fuzzer test. This can lead to remote denial of service. User interaction and execution privileges are not a prerequisite for exploitation. Reported by: enh at Google, to FreeBSD by maya@NetBSD.org Obtained from: enh at Google See also: NetBSD ns_name.c r1.12 Reviewed by: delphij, ume MFC after: 3 days https://android-review.googlesource.com/c/platform/bionic/+/1093130 Differential Revision: https://reviews.freebsd.org/D21523 Notes: svn path=/head/; revision=351889
* pkgbase: Tag passwd related file to be in FreeBSD-runtime package.Emmanuel Vadot2019-09-051-0/+1
| | | | | | | | Reviewed by: bapt, gjb Differential Revision: https://reviews.freebsd.org/D21500 Notes: svn path=/head/; revision=351852
* Adjust history, info source from v1's manualsSevan Janiyan2019-09-041-2/+2
| | | | | | | | | https://www.bell-labs.com/usr/dmr/www/1stEdman.html MFC after: 5 days Notes: svn path=/head/; revision=351811
* Add procctl(PROC_STACKGAP_CTL)Konstantin Belousov2019-09-031-1/+62
| | | | | | | | | | | | | | It allows a process to request that stack gap was not applied to its stacks, retroactively. Also it is possible to control the gaps in the process after exec. PR: 239894 Reviewed by: alc Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D21352 Notes: svn path=/head/; revision=351773
* Add sysctlbyname system callMateusz Guzik2019-09-032-13/+45
| | | | | | | | | | | | | | | Previously userspace would issue one syscall to resolve the sysctl and then another one to actually use it. Do it all in one trip. Fallback is provided in case newer libc happens to be running on an older kernel. Submitted by: Pawel Biernacki Reported by: kib, brooks Differential Revision: https://reviews.freebsd.org/D17282 Notes: svn path=/head/; revision=351729
* libc: Use musl's optimized memchrEd Maste2019-09-021-41/+40
| | | | | | | | | | | | Parentheses added to HASZERO macro to avoid a GCC warning. Reviewed by: kib, mjg Obtained from: musl (snapshot at commit 4d0a82170a) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D17631 Notes: svn path=/head/; revision=351700
* mips: fix some mcount nitsKyle Evans2019-09-021-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | The symbol version for _mcount was removed 12 years ago in r169525 from gmon/Symbol.map, to be added to the per-arch Symbol.map. mips was overlooked in this, so _mcount has no symver. Add it back to where it should have been, rather than where it would go if it were added today, since we're correcting a historical mistake. Additionally, _mcount is getting thrown into .mdebug.abi32 in the llvm80/90 world as it's not getting explicitly thrown into .text, so do this now. This fixes the libc build that was previously failing due to relocations in .mdebug.abi32. This is specifically due to the way clang's integrated AS works and that they emit the .mdebug.abiNN section early in the process. An LLVM bug has been submitted[0] and an agreement has been made that the mips backend should switch to .text following .mdebug.abiNN for compatibility. [0] https://bugs.llvm.org/show_bug.cgi?id=43119 Reviewed by: imp, arichardson MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21435 Notes: svn path=/head/; revision=351681
* libc: remove getsEd Maste2019-09-013-44/+10
| | | | | | | | | | | | | | | | | | | | gets is unsafe and shouldn't be used (for many years now). Leave it in the existing symbol version so anything that previously linked aginst it still runs, but do not allow new software to link against it. (The compatability/legacy implementation must not be static so that the symbol and in particular the compat sym gets@FBSD_1.0 make it into libc.) PR: 222796 (exp-run) Reported by: Paul Vixie Reviewed by: allanjude, cy, eadler, gnn, jhb, kib, ngie (some earlier) Relnotes: Yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D12298 Notes: svn path=/head/; revision=351659
* Unskip test cases from netbsd-tests by defining __HAVE_FENVLi-Wen Hsu2019-08-311-0/+3
| | | | | | | | | | | | | | | This unskips: - lib.libc.stdlib.strtod_test.strtod_round - lib.msun.fe_round_test.t_nofe_round In lib/msun/tests/Makefile only define on fe_round_test.c because lib.msun.ilogb_test.ilogb will get wrong results and needs more examination. MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=351648
* lib.libc.gen.getmntinfo_test.getmntinfo_test is unstable since 8/20, skip itLi-Wen Hsu2019-08-231-0/+3
| | | | | | | | | | in CI env temporarily for more offline diagnosis PR: 240049 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=351416
* mips: hide regnum definitions behind _KERNEL/_WANT_MIPS_REGNUMKyle Evans2019-08-224-3/+1
| | | | | | | | | | | | | | | | | | | machine/regnum.h ends up being included by sys/procfs.h and sys/ptrace.h via machine/reg.h. Many of the regnum definitions are too short and too generic to be exposing to any userland application including one of these two headers. Moreover, these actively cause build failures in googletest (template <typename T1 ...> expanding to template <typename 9 ...>). Hide the definitions behind _KERNEL or _WANT_MIPS_REGNUM, and patch all of the userland consumers to define as needed. Discussed with: imp, jhb Reviewed by: imp, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21330 Notes: svn path=/head/; revision=351409
* libc: mips: remove unused longjmp.cKyle Evans2019-08-221-105/+0
| | | | | | | | | Reviewed by: imp, jhb MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D21330 Notes: svn path=/head/; revision=351407
* Add @generated tag to libc syscall asm wrappersEd Maste2019-08-161-2/+4
| | | | | | | | | | | | | | Although libc syscall wrappers do not get checked in this can aid in finding the source of generated files when spelunking in the objdir. Multiple tools use @generated to identify generated files (for example, in a review Phabricator will by default hide diffs in generated files). For consistency use the @generated tag in makesyscalls.sh as we've done for other generated files, even though these wrappers aren't checked in to the tree. Notes: svn path=/head/; revision=351122
* Revert r351078, r351085: stand/quad.h evictionKyle Evans2019-08-151-21/+0
| | | | | | | It did not go well; further examination is required... Notes: svn path=/head/; revision=351088
* libc quad.h: one last _STANDALONE correctionKyle Evans2019-08-151-0/+5
| | | | Notes: svn path=/head/; revision=351085
* stand: kick out quad.hKyle Evans2019-08-151-0/+16
| | | | | | | | | | | | | | Use quad.h from libc instead for the time being. This reduces the number of nearly-identical-quad.h we have in tree to two with only minor changes. Prototypes for some *sh*di3 have been added to match the copy in libkern. The differences between the two are likely few enough that they can perhaps be merged with little additional effort to bring us down to 1. MFC after: 3 days Notes: svn path=/head/; revision=351078
* Increase YPMAXRECORD to 16M to be compatible with Linux.Konstantin Belousov2019-08-124-13/+30
| | | | | | | | | | | | | | | | | | | | | | | Since YP protocol definition uses the constant to declare variable-size opaque byte strings, the change should be binary compatible with existing installations which do not expose keys or values larger than 1024 bytes. All uses of local variables with YPMAXRECORD sizes were removed to avoid insane stack use. On the other hand, variables with static lifetime should be fine and only result in increased VA use. Glibc made same change, increasing the allowed length for keys and values in YP to 16M, in 2013. Reviewed by: markj Discussed with: ian Sponsored by: Mellanox Technologies MFC after: 3 weeks Differential revision: https://reviews.freebsd.org/D20900 Notes: svn path=/head/; revision=350957
* wait(2): clarify reparenting of children of the exiting process.Konstantin Belousov2019-08-111-3/+8
| | | | | | | | | | | Point to the existence of reapers and mention that init is the default reaper. Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=350861
* wait(2): split long line by using .Fo/.Fa instead of .Ft.Konstantin Belousov2019-08-111-1/+7
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=350860
* Fix a possible segfault in wcsxfrm(3) and wcsxfrm_l(3).Dimitry Andric2019-08-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If the length of the source wide character string, passed in via the "size_t n" parameter, is set to zero, the function should only return the required length for the destination wide character string. In this case, it should *not* attempt to write to the destination, so the "dst" parameter is permitted to be NULL. However, when the internally called _collate_wxfrm() function returns an error, such as when using the "C" locale, as a fallback wcscpy(3) or wcsncpy(3) are used. But if the input length is zero, wcsncpy(3) will be called with a length of -1! If the "dst" parameter is NULL, this will immediately result in a segfault, or if "dst" is a valid pointer, it will most likely result in unexpectedly overwritten memory. Fix this by explicitly checking for an input length greater than zero, before calling wcsncpy(3). Note that a similar situation does not occur in strxfrm(3), the plain character version of this function, as it uses strlcpy(3) for the error case. The strlcpy(3) function does not write to the destination if the input length is zero. MFC after: 1 week Notes: svn path=/head/; revision=350697
* Add an MLINK for daemonfd(3).Mark Johnston2019-08-011-0/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=350514
* Fix formatting.Mark Johnston2019-08-011-1/+1
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=350513
* Add mkostempsat(3).Mark Johnston2019-07-294-19/+54
| | | | | | | | | | | | | | | This is a variant of mkostemps() which takes a directory descriptor and returns a descriptor for a tempfile relative to that directory. Unlike the other mktemp functions, mkostempsat() can be used in capability mode. Reviewed by: cem Discussed with: brooks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21031 Notes: svn path=/head/; revision=350420
* Fix grammar nit in copy_file_range docsBenjamin Kaduk2019-07-251-1/+1
| | | | | | | Bytes are countable, so we have fewer of them, not less of them. Notes: svn path=/head/; revision=350325
* Add libc support for the copy_file_range(2) syscall added by r350315.Rick Macklem2019-07-253-0/+193
| | | | | | | | | | | copy_file_range.2 is a new man page (content change). Reviewed by: kib, asomers Relnotes: yes Differential Revision: https://reviews.freebsd.org/D20584 Notes: svn path=/head/; revision=350317
* special-case getvfsbyname(3) for fusefs(5)Alan Somers2019-07-251-1/+18
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fusefs file systems may have a fsname subtype (set by mount_fusefs's "-o subtype" option) that gets appended to the fsname as returned by statfs(2). The subtype is set on a per-mount basis so it isn't part of the struct vfsconf. Special-case getvfsbyname to match either the full "fusefs.foobar" or short "fusefs" fsname. This is a merge of r348007, r348054, and r350093 from projects/fuse2 Reviewed by: kib MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21043 Notes: svn path=/head/; revision=350314
| * style changes to getvfsbynameAlan Somers2019-07-171-3/+1
| | | | | | | | | | | | | | | | Reported by: markj Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=350093
| * MFHead @349476Alan Somers2019-06-2712-24/+110
| |\ | | | | | | | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=349479
| * \ MFHead @349234Alan Somers2019-06-201-5/+2
| |\ \ | | | | | | | | | | | | | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=349236
| * \ \ MFHead @348740Alan Somers2019-06-0617-59/+119
| |\ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=348744
| * | | | getvfsbyname: prefer sizeof to strlen even for constantsAlan Somers2019-05-211-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang is smart enough to evaluate strlen() of a constant at compile-time. However, that won't work in the future if we compile libc with -ffreestanding. Reported by: kib Dissenting: ngie, cem Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=348054
| * | | | special-case getvfsbyname(3) for fusefs(5)Alan Somers2019-05-201-1/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fusefs file systems may have a fsname subtype (set by mount_fusefs's "-o subtype" option) that gets appended to the fsname as returned by statfs(2). The subtype is set on a per-mount basis so it isn't part of the struct vfsconf. Special-case getvfsbyname to match either the full "fusefs.foobar" or short "fusefs" fsname. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=348007
* | | | | Avoid copying too much from the input string.Brooks Davis2019-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This avoids reading past the end of the static strings. On a system with bounds checking these tests fault. Reviewed by: asomers Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D21004 Notes: svn path=/head/; revision=350160
* | | | | Include a mode when creating files with openat().Brooks Davis2019-07-181-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Reviewed by: asomers Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D20989 Notes: svn path=/head/; revision=350117
* | | | | Document that setmode(3) is not thread safe.Brooks Davis2019-07-181-1/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some circumstances, setmode(3) may call umask(2) twice to retrieve the current mode and then restore it. Between calls, the process will have a umask of 0. Reviewed by: markj Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D20982 Notes: svn path=/head/; revision=350116
* | | | | Remove redundent decleration of __elf_phdr_match_addr().Brooks Davis2019-07-171-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Obtained from: CheriBSD MFC after: 1 week Sponsored by: DARPA, AFRL Notes: svn path=/head/; revision=350102
* | | | | bsearch.3: Improve the example.Konstantin Belousov2019-07-171-19/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Submitted by: fernape MFC after: 1 week Differential revision: https://reviews.freebsd.org/D19902 Notes: svn path=/head/; revision=350091
* | | | | Fix filename to avoid skipping lib/libc/net/servent test.Olivier Cochard2019-07-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | PR: 239177 Approved by: ngie MFC after: 1 month Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D20943 Notes: svn path=/head/; revision=350019
* | | | | Add ptrace op PT_GET_SC_RET.John Baldwin2019-07-151-1/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This ptrace operation returns a structure containing the error and return values from the current system call. It is only valid when a thread is stopped during a system call exit (PL_FLAG_SCX is set). The sr_error member holds the error value from the system call. Note that this error value is the native FreeBSD error value that has _not_ been translated to an ABI-specific error value similar to the values logged to ktrace. If sr_error is zero, then the return values of the system call will be set in sr_retval[0] and sr_retval[1]. Reviewed by: kib MFC after: 1 month Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D20901 Notes: svn path=/head/; revision=350017
* | | | | Add arm_sync_icache() and arm_drain_writebuf() sysarch syscall wrappers.Ian Lepore2019-07-136-0/+250
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NetBSD and OpenBSD have libc wrapper functions for the ARM_SYNC_ICACHE and ARM_DRAIN_WRITEBUF sysarch operations. This change adds compatible functions to our library. This should make it easier for various upstream sources to support *BSD operating systems with a single variation of cache maintence code in tools like interpreters and JIT compilers. I consider the argument types passed to arm_sync_icache() to be especially unfortunate, but this is intended to match the other BSDs. Differential Revision: https://reviews.freebsd.org/D20906 Notes: svn path=/head/; revision=349972
* | | | | Reorganize the SRCS lists as one file per line, and then alphabetize them.Ian Lepore2019-07-101-6/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | No functional changes. Notes: svn path=/head/; revision=349891
* | | | | Document atomicity for read(2) and write(2).Konstantin Belousov2019-07-061-1/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Take part of the text from POSIX 2018 edition and describe the atomicity requirements for read and write syscalls. See p1003.1-2018, Vol.2, 2.9.7 Threads interaction with Regular File Operations. Reviewed by: asomers Sponsored by: The FreeBSD Foundation MFC after: 3 days Differential revision: https://reviews.freebsd.org/D20867 Notes: svn path=/head/; revision=349794
* | | | | libc: correct iconv buffer overflowEd Maste2019-07-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | admbugs: 920 Submitted by: Andrea Venturoli, gabor Reported by: Andrea Venturoli <security@netfence.it>, NetFence Security: CVE-2019-5600 Security: FreeBSD-SA-19:09.iconv Notes: svn path=/head/; revision=349619
* | | | | Control implicit PROT_MAX() using procctl(2) and the FreeBSD noteKonstantin Belousov2019-07-021-1/+44
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | feature bit. In particular, allocate the bit to opt-out the image from implicit PROTMAX enablement. Provide procctl(2) verbs to set and query implicit PROTMAX handling. The knobs mimic the same per-image flag and per-process controls for ASLR. Reviewed by: emaste, markj (previous version) Discussed with: brooks Sponsored by: The FreeBSD Foundation Differential revision: https://reviews.freebsd.org/D20795 Notes: svn path=/head/; revision=349609
* | | | | Reduce size of rtld by 22% by pulling in less code from libcAlex Richardson2019-06-301-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently RTLD is linked against libc_nossp_pic which means that any libc symbol used in rtld can pull in a lot of depedencies. This was causing symbol such as __libc_interposing and all the pthread stubs to be included in RTLD even though they are not required. It turns out most of these dependencies can easily be avoided by providing overrides inside of rtld. This change is motivated by CHERI, where we have an experimental ABI that requires additional relocation processing to allow the use of function pointers inside of rtld. Instead of adding this self-relocation code to RTLD I attempted to remove most function pointers from RTLD and discovered that most of them came from the libc dependencies instead of being actually used inside rtld. A nice side-effect of this change is that rtld is now 22% smaller on amd64. text data bss dec hex filename 0x21eb6 0xce0 0xe60 145910 239f6 /home/alr48/ld-elf-x86.before.so.1 0x1a6ed 0x728 0xdd8 113645 1bbed /home/alr48/ld-elf-x86.after.so.1 The number of R_X86_64_RELATIVE relocations that need to be processed on startup has also gone down from 368 to 187 (almost 50% less). Reviewed By: kib Differential Revision: https://reviews.freebsd.org/D20663 Notes: svn path=/head/; revision=349554
* | | | | Typo.Konstantin Belousov2019-06-281-1/+1
| |_|_|/ |/| | | | | | | | | | | | | | | | | | | | | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=349511
* | | | Fix -Wsign-compare warnings in realpath.cAlex Richardson2019-06-261-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This is needed in order to build realpath.c as part of rtld. Notes: svn path=/head/; revision=349416
* | | | powerpc: Transition to Secure-PLT, like most other OSsJustin Hibbits2019-06-253-11/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: PowerPC has two PLT models: BSS-PLT and Secure-PLT. BSS-PLT uses runtime code generation to generate the PLT stubs. Secure-PLT was introduced with GCC 4.1 and Binutils 2.17 (base has GCC 4.2.1 and Binutils 2.17), and is a more secure PLT format, using a read-only linkage table, with the dynamic linker populating a non-executable index table. This is the libc, rtld, and kernel support only. The toolchain and build parts will be updated separately. Reviewed By: nwhitehorn, bdragon, pfg Differential Revision: https://reviews.freebsd.org/D20598 MFC after: 1 month Notes: svn path=/head/; revision=349350
* | | | Add libc stub for pthread_getthreadid_np(3).Konstantin Belousov2019-06-233-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Requested by: jbeich PR: 238650 Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=349299
* | | | Fix two WARNS=6 warnings in opendir.c and telldir.cAlex Richardson2019-06-232-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is in preparation for compiling these files as part of rtld (which is built with WARNS=6). See https://reviews.freebsd.org/D20663 for more details. Notes: svn path=/head/; revision=349298