aboutsummaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* libc: Fix most issues reported by mandocGordon Bergling2020-12-1920-65/+61
| | | | | | | | | | | | | | - varios "new sentence, new line" warnings - varios "sections out of conventional order" warnings - varios "unusual Xr order" warnings - varios "missing section argument" warnings - varios "no blank before trailing delimiter" warnings - varios "normalizing date format" warnings MFC after: 1 month Notes: svn path=/head/; revision=368817
* strerror.3: Fix whitespace issue introduced in r368714Jessica Clarke2020-12-181-1/+1
| | | | | | | MFC with: 368714 Notes: svn path=/head/; revision=368770
* strerror.3: Add an example for perror()Mateusz Piotrowski2020-12-171-1/+26
| | | | | | | | | | | This is a nice and quick reference. Reviewed by: jilles, yuripv MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D27623 Notes: svn path=/head/; revision=368714
* nl_langinfo(3): document recognized item namesYuri Pankov2020-12-171-8/+94
| | | | | | | | | | | While here, remove .Tn macro usage (prompted by mandoc lint). PR: 251468 Reviewed by: bapt Differential Revision: https://reviews.freebsd.org/D27606 Notes: svn path=/head/; revision=368711
* Implement strerror_l().Konstantin Belousov2020-12-166-22/+95
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=368692
* Be bug compatible with other operating systems by allowing non-sequentialHans Petter Selasky2020-12-141-8/+12
| | | | | | | | | | | | | | | | | interface numbering for USB descriptors in userspace. Else certain USB control requests using the interface number, won't be recognized by the USB firmware. Refer to section 9.2.3 in the USB 2.0 specification: Interfaces are numbered from zero to one less than the number of concurrent interfaces supported by the configuration. PR: 251784 MFC after: 1 week Sponsored by: Mellanox Technologies // NVIDIA Networking Notes: svn path=/head/; revision=368632
* strdup.3: Function appeared in 4.3BSD-Reno, not 4.4BSDJessica Clarke2020-12-141-1/+1
| | | | | | | | | | | | | Linux claims 4.3BSD, we claim 4.4BSD and OpenBSD claims 4.3BSD-Reno. It turns out that OpenBSD got it right: the function was added in late 1988 a few months after 4.3BSD-Tahoe, well in advance of 4.3BSD-Reno. Reviewed by: bcr Approved by: bcr Differential Revision: https://reviews.freebsd.org/D27392 Notes: svn path=/head/; revision=368625
* MFV r368607:Martin Matuska2020-12-131-0/+1
| | | | | | | | | | | | | | | | | Sync libarchive with vendor. Vendor changes: Issue #1461: Unbreak build without lzma Issue #1462: warc reader: Fix build with gcc11 Issue #1463: Fix code compatibility in test_archive_read_support.c Issue #1464: Use built-in strnlen on platforms where not available Issue #1465: warc reader: fix undefined behaviour in deconst() function MFC after: 3 days X-MFC-With: 368234 Notes: svn path=/head/; revision=368608
* Change getlocalbase() to not allocate any heap memoryStefan Eßer2020-12-122-27/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After the commit of the current version, Scott Long pointed out, that an attacker might be able to cause a use-after-free access if this function returned the value of the sysctl variable "user.localbase" by freeing the allocated memory without the cached address being cleared in the library function. To resolve this issue, I have proposed the originally suggested version with a statically allocated buffer in a review (D27370). There was no feedback on this review and after waiting for more than 2 weeks, the potential security issue is fixed by this commit. (There was no security risk in practice, since none of the programs converted to use this function attempted to free the buffer. The address could only have pointed into the heap if user.localbase was set to a non-default value, into r/o data or the environment, else.) This version uses a static buffer of size LOCALBASE_CTL_LEN, which defaults to MAXPATHLEN. This does not increase the memory footprint of the library at this time, since its data segment grows from less than 7 KB to less than 8 KB, i.e. it will get two 4 KB pages on typical architectures, anyway. Compiling with LOCALBASE_CTL_LEN defined as 0 will remove the code that accesses the sysctl variable, values between 1 and MAXPATHLEN-1 will limit the maximum size of the prefix. When built with such a value and if too large a value has been configured in user.localbase, the value defined as ILLEGAL_PREFIX will be returned to cause any file operations on that result to fail. (Default value is "/dev/null/", the review contained "/\177", but I assume that "/dev/null" exists and can not be accessed as a directory. Any other string that can be assumed not be a valid path prefix could be used.) I do suggest to use LOCALBASE_CTL_LEN to size the in-kernel buffer for the user.localbase variable, too. Doing this would guarantee that the result always fit into the buffer in this library function (unless run on a kernel built with a different buffer size.) The function always returns a valid string, and only in case it is built with a small static buffer and run on a system with too large a value in user.localbase, the ILLEGAL_PREFIX will be returned, effectively causing the created path to be non-existent. Differential Revision: https://reviews.freebsd.org/D27370 Notes: svn path=/head/; revision=368577
* timespec_get(3): sort SEE ALSO correctlyEnji Cooper2020-12-111-1/+1
| | | | | | | | | | | clock_gettime(2) should be mentioned before gettimeofday(2). Reported by: make manlint MFC after: 1 week Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368547
* cpuset{,_getaffinity,_getdomain}.2: fix SEE ALSOEnji Cooper2020-12-113-7/+7
| | | | | | | | | | | | Sort by manpage section, then sort entries alphabetically. This makes the manpages `make manlint` clean. MFC after: 1 week Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368546
* aio_suspend.2: properly canonicalize .DdEnji Cooper2020-12-111-1/+1
| | | | | | | | | | | | Months should be fully spelled as their local-specific equivalents: in this case `Oct` should have been spelled like `October`. Reported by: make manlint MFC after: 1 week Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368537
* cap_enter(2): fix CAVEATS sectionEnji Cooper2020-12-111-13/+13
| | | | | | | | | | | | | | | | The CAVEATS section was misspelled as "CAVEAT" before this change. Fix the spelling to identify issues related to the section. Furthermore, given that the section order was incorrect, move the CAVEATS section down to the bottom of the manpage, per the conventional section order. MFC after: 1 week Reported by: make manlint Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368536
* posix_spawn(3): fix section that references `vfork`Enji Cooper2020-12-111-1/+3
| | | | | | | | | | | | | `vfork(2)` should be referenced in paragraphs as `.Fn vfork`, not `vfork()`. This change switches the reference to use `.Fn`, which in turn makes the manpage `make manlint` clean. MFC after: 1 week Reported by: make manlint Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368534
* getentropy(3): sort SEE ALSO sectionsEnji Cooper2020-12-111-1/+1
| | | | | | | | | | | | Sorting order should be done by manpage section (2 vs 3), then alphabetically. This change fixes the order to sort by the manpage section, first. Reported by: make manlint MFC after: 1 week Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368533
* arc4random(3): fix .Xr issuesEnji Cooper2020-12-111-2/+2
| | | | | | | | | | | | | - pthreads(3) should actually be pthread(3). - getentropy(2) should actually be getentropy(3). This makes the manpage `make manlint` clean. MFC after: 1 week Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368532
* Add the LTO-9 density code to libmt and the mt(1) man page.Kenneth D. Merry2020-12-101-0/+1
| | | | | | | | | | | | | | | | | | | | These values are taken directly from the density report from an IBM LTO-9 tape drive. (Using mt getdensity) A LTO-9 drive stores 18TB raw (45TB with compression) on an LTO-9 tape. lib/libmt/mtlib.c: Add the LTO-9 density code, and bpmm/bpi values. usr.bin/mt/mt.1: Add the LTO-9 density code, bpmm/bpi values and number of tracks. Bump the man page date. MFC after: 3 days Sponsored by: Spectra Logic Notes: svn path=/head/; revision=368525
* libsysdecode: decode _UMTX_OP flagsKyle Evans2020-12-093-1/+17
| | | | | | | | | | | | Assume that UMTX_OP with a double underbar following is a flag, while any underbar+alphanumeric combination immeiately following is an op. This was a part of D27325. Reviewed by: kib Notes: svn path=/head/; revision=368480
* _umtx_op(2): document recent addition of 32bit compat flagsKyle Evans2020-12-091-1/+74
| | | | | | | | | This was part of D27325. Reviewed by: kib Notes: svn path=/head/; revision=368479
* extattr_get_file(20: bump .DdEnji Cooper2020-12-081-1/+1
| | | | | | | | | | | | | This is being done for the formatting and context changes. While the net content hasn't been changed, the content/context changes were sufficient to warrant the date bump. MFC after: 1 week MFC with: r368431, r368433, r368434, r368435 Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368436
* extattr_get_file(2): clarify RETURN VALUESEnji Cooper2020-12-081-4/+15
| | | | | | | | | | | | | | | | | | | While some of the syscalls' behavior were documented and implied in the RETURN VALUES section by earlier, e.g., the DESCRIPTION sections, as having behavior of the other calls (`*_fd` vs `*_file` vs `*_link`), there was a lot of implied return value behavior in the section prior to this change. Explicitly document the syscall behavior per the current implementation in sys/kern/vfs_extattr.c so others can better develop based on its explicit documented behavior instead of having to digest the context of the manpage to understand the appropriate behavior. MFC after: 1 week MFC with: r368431, r368433, r368434 Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368435
* extattr_get_file(2): fix more formattingEnji Cooper2020-12-081-3/+3
| | | | | | | | | | | - Remove an unnecessary trailing comma separating a two-item clause. - Sort more function calls alphabetically (in the same vein as r368433). MFC after: 1 week Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368434
* extattr_get_file(2): sort syscalls alphabeticallyEnji Cooper2020-12-081-22/+22
| | | | | | | | | | | | | | | Although some sections of the manpage sort the syscalls alphabetically, many core areas of the manpage do not. Sort the syscalls so it is easier to pick out functional changes and to improve manpage readability. This formatting change is also being done to make future functional changes easier to spot. MFC after: 1 week Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368433
* lio_listio(2): fix manlint errorEnji Cooper2020-12-081-1/+1
| | | | | | | | | | | The date with .Dd prior to this change isn't canonically spelled out: it should have been "December", not "Dec". MFC after: 1 week Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368432
* extattr_get_fd(2): fix manlint errorsEnji Cooper2020-12-081-4/+4
| | | | | | | | | | | | | - The CAVEATS section was misspelled as "CAVEAT". - The CAVEATS section should come before the "BUGS" section and after other existing sections by convention. MFC after: 1 week Reported by: make manlint Sponsored by: DellEMC Isilon Notes: svn path=/head/; revision=368431
* libc: regex: retire internal EMPTBR ("Empty branch present")Kyle Evans2020-12-052-7/+0
| | | | | | | | | It was realized just a little too late that this was a hack that belonged in individual regex(3)-using applications. It was surrounded in NOTYET and not implemented in the engine, so remove it. Notes: svn path=/head/; revision=368359
* libregex: implement \b and \B (word boundary, not word boundary)Kyle Evans2020-12-054-7/+60
| | | | | | | | | | This is the last of the needed GNU expressions before we can unleash bsdgrep by default. \b is effectively an agnostic equivalent of \< and \>, while \B will match every space that isn't making a transition from nonchar -> char or char -> nonchar. Notes: svn path=/head/; revision=368358
* libregex: implement \` and \' (begin-of-subj, end-of-subj)Kyle Evans2020-12-054-13/+74
| | | | | | | | | | These are GNU extensions, generally equivalent to ^ and $ except that the new syntax will not match beginning of line after the first in a multi-line expression or the end of line before absolute last in a multi-line expression. Notes: svn path=/head/; revision=368357
* libc: regex: factor out ISBOW/ISEOW macrosKyle Evans2020-12-051-8/+13
| | | | | | | | | These will be reused for \b (word boundary, which matches both sides). No functional change. Notes: svn path=/head/; revision=368356
* Add CFI start/end proc directives to arm64, i386, and ppcConrad Meyer2020-12-0512-5/+21
| | | | | | | | | | | | | | Follow-up to r353959 and r368070: do the same for other architectures. arm32 already seems to use its own .fnstart/.fnend directives, which appear to be ARM-specific variants of the same thing. Likewise, MIPS uses .frame directives. Reviewed by: arichardson Differential Revision: https://reviews.freebsd.org/D27387 Notes: svn path=/head/; revision=368354
* Always use 64-bit physical addresses for dump_avail[] in minidumpsMark Johnston2020-12-039-34/+12
| | | | | | | | | | | | | | | | | | | | | | As of r365978, minidumps include a copy of dump_avail[]. This is an array of vm_paddr_t ranges. libkvm walks the array assuming that sizeof(vm_paddr_t) is equal to the platform "word size", but that's not correct on some platforms. For instance, i386 uses a 64-bit vm_paddr_t. Fix the problem by always dumping 64-bit addresses. On platforms where vm_paddr_t is 32 bits wide, namely arm and mips (sometimes), translate dump_avail[] to an array of uint64_t ranges. With this change, libkvm no longer needs to maintain a notion of the target word size, so get rid of it. This is a no-op on platforms where sizeof(vm_paddr_t) == 8. Reviewed by: alc, kib Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D27082 Notes: svn path=/head/; revision=368307
* Remove trailing whitespace.Cy Schubert2020-12-031-4/+4
| | | | | | | MFC after: 1 week Notes: svn path=/head/; revision=368294
* MFV r368207:Martin Matuska2020-12-013-0/+3
| | | | | | | | | | | | | | | | | | | | | | Update libarchive to 3.5.0 Relevant vendor changes: Issue #1258: add archive_read_support_filter_by_code() PR #1347: mtree digest reader support Issue #1381: skip hardlinks pointing to itself on extraction PR #1387: fix writing of cpio archives with hardlinks without file type PR #1388: fix rdev field in cpio format for device nodes PR #1389: completed support for UTF-8 encoding conversion PR #1405: more formats in archive_read_support_format_by_code() PR #1408: fix uninitialized size in rar5_read_data PR #1409: system extended attribute support PR #1435: support for decompression of symbolic links in zipx archives Issue #1456: memory leak after unsuccessful archive_write_open_filename MFC after: 1 week Notes: svn path=/head/; revision=368234
* Ensure that threading library is initialized in pthread_mutex_init().Konstantin Belousov2020-11-301-0/+2
| | | | | | | | | | | | We need at least thr_malloc ready. The situation is possible e.g. in case of libthr being listed in DT_NEEDED before some of its consumers. Reported and tested by: lev Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=368190
* libc: Add pthread_attr_get_np(3) stub, reporting ESRCH.Konstantin Belousov2020-11-284-0/+12
| | | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=368125
* libprocstat.3: Correct two occurrences of kvm_getprocs to procstat_getprocsMateusz Piotrowski2020-11-261-3/+3
| | | | | | | | | | Submitted by: otis_sk.freebsd.org Reviewed by: markj MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D26151 Notes: svn path=/head/; revision=368084
* Remove stray column.Konstantin Belousov2020-11-261-1/+1
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=368083
* Style.Konstantin Belousov2020-11-261-18/+18
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 3 days Notes: svn path=/head/; revision=368082
* libsysdecode: account for invalid protection flagsPawel Biernacki2020-11-261-1/+1
| | | | | | | | Reported by: jhb MFC with: r368022 Notes: svn path=/head/; revision=368053
* Use designated initializers for libc pthread stubs' jump table.Konstantin Belousov2020-11-251-67/+67
| | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week Notes: svn path=/head/; revision=368023
* libsysdecode: correctly decode mmap flagsPawel Biernacki2020-11-251-1/+1
| | | | | | | | | | | | | | r352913 added decoding of mmap PROT_MAX()'d flags but didn’t account for the case where different values were specified for PROT_MAX and regular flags. Fix it. Submitted by: sigsys_gmail.com Reported by: sigsys_gmail.com MFC after: 7 days Differential Revision: https://reviews.freebsd.org/D27312 Notes: svn path=/head/; revision=368022
* Remove the cloned file descriptors for /dev/crypto.John Baldwin2020-11-252-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Crypto file descriptors were added in the original OCF import as a way to provide per-open data (specifically the list of symmetric sessions). However, this gives a bit of a confusing API where one has to open /dev/crypto and then invoke an ioctl to obtain a second file descriptor. This also does not match the API used with /dev/crypto on other BSDs or with Linux's /dev/crypto driver. Character devices have gained support for per-open data via cdevpriv since OCF was imported, so use cdevpriv to simplify the userland API by permitting ioctls directly on /dev/crypto descriptors. To provide backwards compatibility, CRIOGET now opens another /dev/crypto descriptor via kern_openat() rather than dup'ing the existing file descriptor. This preserves prior semantics in case CRIOGET is invoked multiple times on a single file descriptor. Reviewed by: markj Relnotes: yes Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D27302 Notes: svn path=/head/; revision=368005
* Honor the disabled setting for MSI-X interrupts for passthrough devices.John Baldwin2020-11-242-1/+16
| | | | | | | | | | | | | | | | | | | | | | | Add a new ioctl to disable all MSI-X interrupts for a PCI passthrough device and invoke it if a write to the MSI-X capability registers disables MSI-X. This avoids leaving MSI-X interrupts enabled on the host if a guest device driver has disabled them (e.g. as part of detaching a guest device driver). This was found by Chelsio QA when testing that a Linux guest could switch from MSI-X to MSI interrupts when using the cxgb4vf driver. While here, explicitly fail requests to enable MSI on a passthrough device if MSI-X is enabled and vice versa. Reported by: Sony Arpita Das @ Chelsio Reviewed by: grehan, markj MFC after: 2 weeks Sponsored by: Chelsio Communications Differential Revision: https://reviews.freebsd.org/D27212 Notes: svn path=/head/; revision=368003
* Remove support for SSLv3 from fetch(3).Jung-uk Kim2020-11-242-9/+3
| | | | | | | | | Support for SSLv3 was already removed from OpenSSL (r361392). Differential Revision: https://reviews.freebsd.org/D24947 Notes: svn path=/head/; revision=368000
* libc: fix undefined behavior from signed overflow in strstr and memmemEd Maste2020-11-192-8/+8
| | | | | | | | | | | | | | | | | | | | | unsigned char promotes to int, which can overflow when shifted left by 24 bits or more. this has been reported multiple times but then forgotten. it's expected to be benign UB, but can trap when built with explicit overflow catching (ubsan or similar). fix it now. note that promotion to uint32_t is safe and portable even outside of the assumptions usually made in musl, since either uint32_t has rank at least unsigned int, so that no further default promotions happen, or int is wide enough that the shift can't overflow. this is a desirable property to have in case someone wants to reuse the code elsewhere. musl commit: 593caa456309714402ca4cb77c3770f4c24da9da Obtained from: musl Notes: svn path=/head/; revision=367823
* libc: optimize memmem two-way bad character shiftEd Maste2020-11-191-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | first, the condition (mem && k < p) is redundant, because mem being nonzero implies the needle is periodic with period exactly p, in which case any byte that appears in the needle must appear in the last p bytes of the needle, bounding the shift (k) by p. second, the whole point of replacing the shift k by mem (=l-p) is to prevent shifting by less than mem when discarding the memory on shift, in which case linear time could not be guaranteed. but as written, the check also replaced shifts greater than mem by mem, reducing the benefit of the shift. there is no possible benefit to this reduction of the shift; since mem is being cleared, the full shift is valid and more optimal. so only replace the shift by mem when it would be less than mem. musl commits: 8f5a820d147da36bcdbddd201b35d293699dacd8 122d67f846cb0be2c9e1c3880db9eb9545bbe38c Obtained from: musl MFC after: 2 weeks Notes: svn path=/head/; revision=367822
* clang-format libc string functions imported from muslEd Maste2020-11-183-125/+194
| | | | | | | | | | | We have adopted these and don't consider them 'contrib' code, so bring them closer to style(9). This is a followon to r315467 and r351700. MFC after: 1 week Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=367821
* Add function getlocalbase() to libutil.Stefan Eßer2020-11-184-2/+178
| | | | | | | | | | | | | | | | | | This function returns the path to the local software base directory, by default "/usr/local" (or the value of _PATH_LOCALBASE in include/paths.h when building the world). The value returned can be overridden by 2 methods: - the LOCALBASE environment variable (ignored by SUID programs) - else a non-default user.localbase sysctl value Reviewed by: hps (earlier version) Relnotes: yes Differential Revision: https://reviews.freebsd.org/D27236 Notes: svn path=/head/; revision=367813
* msun tests: use standard floating-point exception flags on lrint and fenv testsAlfredo Dal'Ava Junior2020-11-182-9/+12
| | | | | | | | | | | | | | | Some platforms have additional architecture-specific floating-point flags. Msun test cases lrint and test_fegsetenv (fenv) expects only standard flags, so make sure to mask them appropriately. This makes test pass on PowerPC64. Reviewed by: jhibbits, ngie Sponsored by: Eldorado Research Institute (eldorado.org.br) Differential Revision: https://reviews.freebsd.org/D27202 Notes: svn path=/head/; revision=367811
* Split out cwd/root/jail, cmask state from filedesc tableConrad Meyer2020-11-172-7/+14
| | | | | | | | | | | | | | | | No functional change intended. Tracking these structures separately for each proc enables future work to correctly emulate clone(2) in linux(4). __FreeBSD_version is bumped (to 1300130) for consumption by, e.g., lsof. Reviewed by: kib Discussed with: markj, mjg Differential Revision: https://reviews.freebsd.org/D27037 Notes: svn path=/head/; revision=367777