aboutsummaryrefslogtreecommitdiff
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* unbound: Vendor import 1.19.1Cy Schubert2024-03-282-5/+7
| | | | | | | | | | | | | | | | | | | | | | | | Release notes at https://www.nlnetlabs.nl/news/2024/Feb/13/unbound-1.19.1-released/ Security: CVE-2023-50387, CVE-2023-50868 Security: FreeBSD-SA-24:03.unbound Approved by: so (cherry picked from commit 8f76bb7dad48538c6832c2fb466a433d2a3f8cd5) (cherry picked from commit 1b5982339ced0f39ef588a07a3e960954e87c65e) (cherry picked from commit 948e11aaf420cd7d493cc2e118cacc06d18653fe) (cherry picked from commit 9afc0c849e6e0436351fbdaf6157d1c822793d80) (cherry picked from commit 6e71235e558ef579605e7f35b02f983b9a246a4a) (cherry picked from commit 8a9416b18f8a894c4bb0c3a284746d5e0bc81152) (cherry picked from commit 103ba509e72e3949d22485666949e9705d4af8cd) (cherry picked from commit 4631a5104763c01123dad62546b1325cb16bf44c) (cherry picked from commit 5aab39b24ce7437265b94461ffdd9b12c0723658) (cherry picked from commit a118088ff3741023c24caeff1a4fff7b660817fd) (cherry picked from commit 67267734315c6a48db31697f0a0669fa1f985969) (cherry picked from commit 1318715277325a508ad5b76c8cd9c17c8146693b) (cherry picked from commit b76ef9a7cb8a7c62d10ae8101f41014f34819174) (cherry picked from commit e2b44c401cc2a59da8c4c0515c6bcb533d09cc73)
* setusercontext(): Apply personal settings only on matching effective UIDOlivier Certner2024-02-141-1/+1
| | | | | | | | | | | | | | | | | | | | | Commit 35305a8dc114 (r211393) added a check on whether 'uid' was equal to getuid() before calling setlogincontext(). Doing so still allows a setuid program to apply resource limits and priorities specified in a user-controlled configuration file ('~/.login_conf') where a non-setuid program could not. Plug the hole by checking instead that the process' effective UID is the target one (which is likely what was meant in the initial commit). PR: 271750 Reviewed by: kib, des MFC after: 2 weeks Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D40351 Approved by: so Security: FreeBSD-EN-24:02.libutil (cherry picked from commit 892654fe9b5a9115815c30a423b8db47185aebbd) (cherry picked from commit ede6fd06726c02e9d2a5c47ac8cf80d8aaec5a70)
* release: update releng/14.0 to -RELEASErelease/14.0.0Glen Barber2023-11-091-1/+1
| | | | | | | | | | - Add UPDATING entry anticipating the announcement date. - Set a static __FreeBSD_version in crtbrand.S. - Update BRANCH to reflect RELEASE. Approved by: re (implicit) Sponsored by: GoFundMe https://www.gofundme.com/f/gjbbsd Sponsored by: PayPal https://paypal.me/gjbbsd
* cap_net: correct capability name from addr2name to name2addrMariusz Zaborski2023-11-082-1/+13
| | | | | | | | | | | | | | | | Previously, while checking name2addr capabilities, we mistakenly used the addr2name set. This error could cause a process to inadvertently reset its limitations. Reported by: Shawn Webb <shawn.webb@hardenedbsd.org> (cherry picked from commit afd74c400075d94e01dd3430844bb290834660ef) (cherry picked from commit 765757c6301fa41c0b59108347c600fbc9020c39) Approved by: so Approved by: re (implicit) Security: FreeBSD-SA-23:16.cap_net Sponsored by: The FreeBSD Foundation
* fflush: correct buffer handling in __sflushDag-Erling Smørgrav2023-11-083-39/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes CVE-2014-8611 correctly. The commit that purported to fix CVE-2014-8611 (805288c2f062) only hid it behind another bug. Two later commits, 86a16ada1ea6 and 44cf1e5eb470, attempted to address this new bug but mostly just confused the issue. This commit rolls back the three previous changes and fixes CVE-2014-8611 correctly. The key to understanding the bug (and the fix) is that `_w` has different meanings for different stream modes. If the stream is unbuffered, it is always zero. If the stream is fully buffered, it is the amount of space remaining in the buffer (equal to the buffer size when the buffer is empty and zero when the buffer is full). If the stream is line-buffered, it is a negative number reflecting the amount of data in the buffer (zero when the buffer is empty and negative buffer size when the buffer is full). At the heart of `fflush()`, we call the stream's write function in a loop, where `t` represents the return value from the last call and `n` the amount of data that remains to be written. When the write function fails, we need to move the unwritten data to the top of the buffer (unless nothing was written) and adjust `_p` (which points to the next free location in the buffer) and `_w` accordingly. These variables have already been set to the values they should have after a successful flush, so instead of adjusting them down to reflect what was written, we're adjusting them up to reflect what remains. The bug was that while `_p` was always adjusted, we only adjusted `_w` if the stream was fully buffered. The fix is to also adjust `_w` for line-buffered streams. Everything else is just noise. Fixes: 805288c2f062 Fixes: 86a16ada1ea6 Fixes: 44cf1e5eb470 Sponsored by: Klara, Inc. (cherry picked from commit 1f90b4edffe815aebb35e74b79e10593b31f6b75) (cherry picked from commit 1e99535be2ea9c0ef8bc57fc885e9c01fa95d2dd) (cherry picked from commit d09a3bf72c0b5f1779c52269671872368c99f02a) (cherry picked from commit 92709431b14df6c0687446247ac57cfc189ee827) (cherry picked from commit 418f026bd5a5084c1c4e2e91ad38051f6caa928c) (cherry picked from commit abe12d2f4ce31c3da0961b1b0a58df11f5a41e19) (cherry picked from commit 4e0e01bf6511c28212d7dff94fe131a502e13026) (cherry picked from commit d2c65a1c948648f11342274029a3f18b90aa58d2) Approved by: so Approved by: re (implicit) Security: FreeBSD-SA-23:15.stdio Sponsored by: The FreeBSD Foundation
* ptrace(2): Disabling: Describe influence of security.bsd.see_jail_procOlivier Certner2023-10-181-15/+21
| | | | | | | | | | Approved by: re (gjb) Reviewed by: mhorne, emaste, pauamma_gundo.com Sponsored by: Kumacom SAS Differential Revision: https://reviews.freebsd.org/D41109 (cherry picked from commit d952820105d6a2ad87ddf3bdc6c5fc5215d13b87) (cherry picked from commit 7c069dbe8e561436b4b2a0d6cf2c2483bd4e0fa3)
* ktrace.2: correct kern.ktrace.genio_size sysctl nameEd Maste2023-10-131-1/+1
| | | | | | | | | | | | | | The man page had `kern.ktrace.geniosize` but the sysctl node contains an underscore. PR: 274274 Reported by: Ivan Rozhuk Sponsored by: The FreeBSD Foundation (cherry picked from commit a572dfa1bfe00cec93b27d8848ca49562cab5e3c) (cherry picked from commit 2fe06dda0a8abced5851188ed2cb76d1759efa19) Approved by: re (gjb)
* libfetch: don't rely on ca_root_nss for certificate validationMichael Osipov2023-10-051-8/+0
| | | | | | | | | | | | | | | | | | | | | | | Before certctl(8), there was no system trust store, and libfetch relied on the CA certificate bundle from the ca_root_nss port to verify peers. We now have a system trust store and a reliable mechanism for manipulating it (to explicitly add, remove, or revoke certificates), but if ca_root_nss is installed, libfetch will still prefer that to the system trust store. With this change, unless explicitly overridden, libfetch will rely on OpenSSL to pick up the default system trust store. PR: 256902 MFC after: 3 days Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D42059 Approved by: re (gjb) (cherry picked from commit 09f5c1e118bb4eca77b83a0d08f559b20f60aa59) (cherry picked from commit fb058a9a40a5adc82721ed822fb4fba213446a7b)
* regcomp: use unsigned char when testing for escapesChristos Zoulas2023-10-011-4/+4
| | | | | | | | | | | | | | | | - cast GETNEXT to unsigned where it is being promoted to int to prevent sign-extension (really it would have been better for PEEK*() and GETNEXT() to return unsigned char; this would have removed a ton of (uch) casts, but it is too intrusive for now). - fix an isalpha that should have been iswalpha PR: 264275, 274032 Reviewed by: kevans, eugen (previous version) Approved by: re (gjb) Obtained from: NetBSD (cherry picked from commit 3fb80f1476c7776f04ba7ef6d08397cef6abcfb0) (cherry picked from commit 56b09feb23d98fcd0c4aed8d4f907a5a2f6b5ea9)
* pmc: better distinguish pmu-events allocation pathMitchell Horne2023-09-253-17/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Background: The pm_ev field of struct pmc_op_pmcallocate and struct pmc traditionally contains the index of the chosen event, corresponding to the __PMC_EVENTS array in pmc_events.h. This is a static list of events, maintained by FreeBSD. In the usual case, libpmc translates the user supplied event name (string) into the pm_ev index, which is passed as an argument to the allocation syscall. On the kernel side, the allocation method for the relevant hwpmc class translates the given index into the event code that will be written to an event selection register. In 2018, a new source of performance event definitions was introduced: the pmu-events json files, which are maintained by the Linux kernel. The result was better coverage for newer Intel processors with a reduced maintenance burden for libpmc/hwpmc. Intel and AMD CPUs were unconditionally switched to allocate events from pmu-events instead of the traditional scheme (959826ca1bb0a, 81eb4dcf9e0d). Under the pmu-events scheme, the pm_ev field contains an index corresponding to the selected event from the pmu-events table, something which the kernel has no knowledge of. The configuration for the performance counting registers is instead passed via class-dependent fields (struct pmc_md_op_pmcallocate). In 2021 I changed the allocation logic so that it would attempt to pull from the pmu-events table first, and fall-back to the traditional method (dfb4fb41166bc3). Later, pmu-events support for arm64 and power8 CPUs was added (28dd6730a5d6 and b48a2770d48b). The problem that remains is that the pm_ev field is overloaded, without a definitive way to determine whether the event allocation came from the pmu-events table or FreeBSD's statically-defined PMC events. This resulted in a recent fix, 21f7397a61f7. Change: To disambiguate these two supported but separate use-cases, add a new flag, PMC_F_EV_PMU, to be set as part of the allocation, indicating that the event index came from pmu-events. This is useful in two ways: 1. On the kernel side, we can validate the syscall arguments better. Some classes support only the traditional event scheme (e.g. hwpmc_armv7), while others support only the pmu-events method (e.g. hwpmc_core for Intel). We can now check for this. The hwpmc_arm64 class supports both methods, so the new flag supersedes the existing MD flag, PM_MD_EVENT_RAW. 2. The flag will be tracked in struct pmc for the duration of its lifetime, meaning it is communicated back to userspace. This allows libpmc to perform the reverse index-to-event-name translation without speculating about the meaning of the index value. Adding the flag is a backwards-incompatible ABI change. We recently bumped the major version of the hwpmc module, so this breakage is acceptable. Reviewed by: jkoshy Approved by: re (gjb) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40753 (cherry picked from commit c190fb35f35cc163b61e582a49115680b0d49dcc) (cherry picked from commit 5adb91c72985b840b2c7fbf3c3308619acd2b61a)
* libpmc: make pmc_pmu_pmcallocate() machine-independentMitchell Horne2023-09-252-13/+26
| | | | | | | | | | | | | | Have it call the platform-dependent version. For better layering, move the reset logic inside the new function. This is mainly to facilitate an upcoming change. Reviewed by: jkoshy Approved by: re (gjb) Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40752 (cherry picked from commit 45dcc17e2fb8f0f9838ba167b311f271a08fcea9) (cherry picked from commit 196bb0e152cf2d3a0ba61bda8a2d09c8107a809a)
* libfido2: update to 1.13.0Ed Maste2023-09-231-1/+5
| | | | | | | | | | | | | | | | | Some highlights from NEWS entries: ** Improved OpenSSL 3.0 compatibility. ** Support for hidraw(4) on FreeBSD; gh#597. ** Improved support for FIDO 2.1 authenticators. PR: 273596 Relnotes: Yes Sponsored by: The FreeBSD Foundation (cherry picked from commit 2ccfa855b2fc331819953e3de1b1c15ce5b95a7e) (cherry picked from commit 5bfbde817cdedbd7309c38a361cd1211bdcdd70e) Approved by: re (gjb)
* lib/libc/amd64: back out amd64 SIMD workRobert Clausecker2023-09-198-870/+22
| | | | | | | | | | | | | | | | | Due to some bugs being found, back out the amd64 SIMD libc work from releng/14.0 ahead of the release and give these changes in a critical part of FreeBSD some more time to mature. This patch set backs out D40693, D41333, D41349, D41442, and D41697. Change sets D40729, D40730 (ffs), D41011 (bcmp integer overflow bug), and D41050 (rtld bits) are not backed out. The intent is for this backout to be a direct commit to releng/14.0 with the changes staying on CURRENT and stable/14. Sponsored by: The FreeBSD Foundation Requested by: imp kevans Approved by: kib, re (cperciva) Differential Revision: https://reviews.freebsd.org/D41855
* libc: Don't assume signed char.Dag-Erling Smørgrav2023-09-142-4/+4
| | | | | | | | | | MFC after: 3 days Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D41814 Approved by: re (delphij) (cherry picked from commit 88a9b6e1ed82b562f52bae26b3de257495cd1983) (cherry picked from commit c1335a776b0ff33a715bdaa2be59412006cb4053)
* Merge commit 4bb2416d42eb from llvm-project (by Jessica Clarke):Jessica Clarke2023-09-111-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | [builtins][AArch64] Implement _sync out-of-line atomics Whilst Clang does not use these, recent GCC does, and so on systems such as FreeBSD that wish to use compiler-rt as the system runtime library but also wish to support building programs with GCC these interfaces are needed. This is a light adaptation of the code committed to GCC by Sebastian Pop <spop@amazon.com>, relicensed with permission for use in compiler-rt. Fixes https://github.com/llvm/llvm-project/issues/63483 Reviewed By: sebpop, MaskRay Differential Revision: https://reviews.llvm.org/D158536 Reviewed by: dim Approved by: re (gjb) MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41716 (cherry picked from commit 8524dc53fd4c6b79d75b82cb82f3ac72fc25e85f) (cherry picked from commit 2f269a3532b279a215d527ef67949ff020476e8c)
* scandir.3: Fix several typosTrond Endrestøl2023-09-091-5/+4
| | | | | | | | | | Approved by: re (cperciva) PR: 273480 Reviewed by: markj MFC after: 1 week (cherry picked from commit b7000cadfbf312b6a8acff6b7a3bbbbe55509565) (cherry picked from commit d0a5da5c1cf9c8d2c19b267e4db0fa2e28838f9d)
* libcasper: reference system.fileargs serviceEd Maste2023-09-091-1/+4
| | | | | | | | | | | | Reviewed by: oshogbo Fixes: cdd6ea94b0a4 ("libcasper: introduce cap_fileargs...") Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D41761 (cherry picked from commit 56e3123fc864b6d08ee5b3752538d2f9be52027b) (cherry picked from commit 99f8ee196deb0ca2b2a19602a317ac61e9ca25a0) Approved by: re (gjb)
* */string.3,arch.7,environ.7: add cross-references to simd(7)Robert Clausecker2023-09-081-2/+3
| | | | | | | | | | | | | | With the new simd-dispatch framework documented in simd(7), add cross-references to the new man pages to appropriate places. Sponsored by: The FreeBSD Foundation Approved by: emaste, re (gjb) MFC to: stable/14, releng/14.0 MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D41697 (cherry picked from commit d41afb814612ce005d93d2f8d127dcf6ea751cc4) (cherry picked from commit 7ec2ae8c7cd4400d5c0db690a1fe43cf85b6c5d3)
* libc: Implement N2680.Dag-Erling Smørgrav2023-09-0711-5/+468
| | | | | | | | | | | | | | | | | | | | | | This adds specific width length modifiers in the form of wN and wfN (where N is 8, 16, 32, or 64) which allow printing intN_t and int_fastN_t without resorting to casts or PRI macros. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41725 (cherry picked from commit bce0bef3c6abab92c7ac8cc23b7cc632a382721e) libc: Add test cases for N2680. This adds test cases for %wN and %wfN to the printf(3) and scanf(3) tests. While here, fix a few nits in the N2630 test cases. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D41743 (cherry picked from commit 12b1c1e3fb446021a881d9815465137843fca50b) Approved by: re (gjb)
* libc: Fix fmemopen(3) prototype in fopen(3) man page.Dag-Erling Smørgrav2023-09-071-6/+9
| | | | | | | | | | | | | | | | | | | | While here, also update a mention of ANSI C. Sponsored by: Klara, Inc. Reviewed by: kevans, markj Differential Revision: https://reviews.freebsd.org/D41686 (cherry picked from commit 5a57401e7106132b61b16e34365cebf52b773007) libc: Further nit in fopen(3) man page. Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D41687 (cherry picked from commit c9f5889d05b5854be033849a4ff9985699071548) Approved by: re (gjb)
* nss_tacplus: Provide dummy setpwent(), getpwent_r(), endpwent().Dag-Erling Smørgrav2023-09-071-0/+31
| | | | | | | | | | | | | These aren't really needed, since TACACS+ does not support enumeration, but providing placeholders keeps nsdispatch() from complaining that they're missing. MFC after: 1 week Sponsored by: Klara, Inc. Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D41658 (cherry picked from commit 56b74a2d856c4d65a4b5c72d1352067b6b469d3b) Approved by: re (gjb)
* libc: Implement N2630.Dag-Erling Smørgrav2023-09-0728-259/+1309
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds formatted input/output of binary integer numbers to the printf(), scanf(), and strtol() families, including their wide-character counterparts. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41511 (cherry picked from commit d9dc1603d6e48cca84cad3ebe859129131b8387c) libc: Add unit tests for N2630 and possible collateral damage. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41512 (cherry picked from commit b9385720f34b536ef2568a642e8b1fad0450056f) libc: Document support for binary integers. Reviewed by: debdrup, emaste Differential Revision: https://reviews.freebsd.org/D41522 (cherry picked from commit 76edfabbecdec686a570b8e009d5ea4112f943e0) libc: Fix fixed-width case in the new integer parser. Fixes: d9dc1603d6e4 Differential Revision: https://reviews.freebsd.org/D41622 (cherry picked from commit aca3bd1602577591e5cd237c4bb0bb71b3be0c75) libc: Add a wide version of snprintf_test. Reviewed by: imp, emaste Differential Revision: https://reviews.freebsd.org/D41726 (cherry picked from commit 4ec9ee9912765ac4ca57353999caa92a23283d8e) libc: Suppress format checks on printf() / scanf() tests. Reviewed by: jrtc27, markj, emaste Differential Revision: https://reviews.freebsd.org/D41727 (cherry picked from commit 294bd2827e61a78041f6613f4b82235fcc454157) Approved by: re (gjb)
* geli: Fix geli setkey -J for detached providersArjan de Vet2023-09-041-0/+6
| | | | | | | | | | | | Clear cached_passphrase before generating a new key, otherwise the operation nonsensically tries to reuse the old passphrase. Approved by: re (kib) PR: 254966 Pull Request: https://github.com/freebsd/freebsd-src/pull/780 MFC after: 1 week (cherry picked from commit 88d13bf33754bd4b0c5df92eef83d6fadb9b4944)
* libc: fix history for strverscmp(3) and versionsort(3)Mina Galić2023-09-032-4/+4
| | | | | | | PR: 273401 Approved by: re (gjb) (cherry picked from commit 09ec5e67a7a6605e5a58a2e3e82dab243a90609a)
* zfs: merge openzfs/zfs@32949f256 (zfs-2.2-release) into stable/14Martin Matuska2023-09-031-0/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Notable upstream pull request merges: #15024 Add missed DMU_PROJECTUSED_OBJECT prefetch #15029 Do not request data L1 buffers on scan prefetch #15036 FreeBSD: catch up to __FreeBSD_version 1400093 #15039 Fix raw receive with different indirect block size #15047 FreeBSD: Fix build on stable/13 after 1302506 #15049 Fix the ZFS checksum error histograms with larger record sizes #15052 Reduce bloat in ereport.fs.zfs.checksum events #15056 Avoid extra snprintf() in dsl_deadlist_merge() #15061 Ignore pool ashift property during vdev attachment #15063 Don't panic if setting vdev properties is unsupported for this vdev type #15067 spa_min_alloc should be GCD, not min #15071 Add explicit prefetches to bpobj_iterate() #15072 Adjust prefetch parameters #15079 set autotrim default to 'off' everywhere #15080 ZIL: Fix config lock deadlock #15088 metaslab: tuneable to better control force ganging #15096 Avoid waiting in dmu_sync_late_arrival() #15097 BRT should return EOPNOTSUPP #15103 Remove zl_issuer_lock from zil_suspend() #15107 Remove fastwrite mechanism #15113 libzfs: sendrecv: send_progress_thread: handle SIGINFO/SIGUSR1 #15122 ZIL: Second attempt to reduce scope of zl_issuer_lock #15129 zpool_vdev_remove() should handle EALREADY error return #15132 ZIL: Replay blocks without next block pointer #15148 zfs_clone_range should return descriptive error codes #15153 ZIL: Avoid dbuf_read() before dmu_sync() #15161 Make zoned/jailed zfsprops(7) make more sense #15172 copy_file_range: fix fallback when source create on same txg #15180 Update outdated assertion from zio_write_compress #15216 Relax error reporting in zpool import and zpool split #15227 ZIL: Tune some assertions #15228 ZIL: Revert zl_lock scope reduction #15233 ZIL: Change ZIOs issue order Obtained from: OpenZFS OpenZFS commit: 32949f2560bf35ec86dfa5d984514908e0eb3ecc Approved by: re (gjb)
| * Relax error reporting in zpool import and zpool splitUmer Saleem2023-09-021-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For zpool import and zpool split, zpool_enable_datasets is called to mount and share all datasets in a pool. If there is an error while mounting or sharing any dataset in the pool, the status of import or split is reported as failure. However, the changes do show up in zpool list. This commit updates the error reporting in zpool import and zpool split path. More descriptive messages are shown to user in case there is an error during mount or share. Errors in mount or share do not effect the overall status of zpool import and zpool split. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <mav@FreeBSD.org> Signed-off-by: Umer Saleem <usaleem@ixsystems.com> Closes #15216
| * libzfs: sendrecv: send_progress_thread: handle SIGINFO/SIGUSR1наб2023-08-252-18/+79
| | | | | | | | | | | | | | | | | | | | POSIX timers target the process, not the thread (as does SIGINFO), so we need to block it in the main thread which will die if interrupted. Ref: https://101010.pl/@ed1conf@bsd.network/110731819189629373 Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz> Closes #15113
| * zpool_vdev_remove() should handle EALREADY error returnSerapheim Dimitropoulos2023-08-021-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the vdev properties features was merged an extra check was added in `spa_vdev_remove_top_check()` which checked whether the vdev that we want to remove is already being removed and if so return an EALREADY error. ``` static int spa_vdev_remove_top_check(vdev_t *vd) { ... <snip> ... /* * This device is already being removed */ if (vd->vdev_removing) return (SET_ERROR(EALREADY)); ``` Before that change we'd still fail with an error but it was a more generic one - here is the check that failed later in the same function: ``` /* * There can not be a removal in progress. */ if (spa->spa_removing_phys.sr_state == DSS_SCANNING) return (SET_ERROR(EBUSY)); ``` Changing the error code returned from that function changed the behavior of the removal's library interface exposed to the userland - `spa_vdev_remove()` now returns `EZFS_UNKNOWN` instead of `EZFS_EBUSY` that was returning before. This patch adds logic to make `spa_vdev_remove()` mindful of the new EALREADY code and propagating `EZFS_EBUSY` reverting to the previously established semantics of that function. Reviewed-by: Mark Maybee <mark.maybee@delphix.com> Reviewed-by: Matthew Ahrens <mahrens@delphix.com> Signed-off-by: Serapheim Dimitropoulos <serapheim@delphix.com> Closes #15013 Closes #15129
| * Fix remount when setting multiple properties.Alexander Motin2023-06-301-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | The previous code was checking zfs_is_namespace_prop() only for the last property on the list. If one was not "namespace", then remount wasn't called. To fix that move zfs_is_namespace_prop() inside the loop and remount if at least one of properties was "namespace". Reviewed-by: Umer Saleem <usaleem@ixsystems.com> Reviewed-by: Ameer Hamza <ahamza@ixsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #15000
| * Finally drop long disabled vdev cache.Alexander Motin2023-06-091-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It was a vdev level read cache, designed to aggregate many small reads by speculatively issuing bigger reads instead and caching the result. But since it has almost no idea about what is going on with exception of ZIO_FLAG_DONT_CACHE flag set by higher layers, it was found to make more harm than good, for which reason it was disabled for the past 12 years. These days we have much better instruments to enlarge the I/Os, such as speculative and prescient prefetches, I/O scheduler, I/O aggregation etc. Besides just the dead code removal this removes one extra mutex lock/unlock per write inside vdev_cache_write(), not otherwise disabled and trying to do some work. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #14953
| * Use __attribute__((malloc)) on memory allocation functionsRichard Yao2023-05-261-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This informs the C compiler that pointers returned from these functions do not alias other functions, which allows it to do better code optimization and should make the compiled code smaller. References: https://stackoverflow.com/a/53654773 https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-malloc-function-attribute https://clang.llvm.org/docs/AttributeReference.html#malloc Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #14827
| * Teach zpool scrub to scrub only blocks in error logGeorge Amanakis2023-05-185-23/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added a flag '-e' in zpool scrub to scrub only blocks in error log. A user can pause, resume and cancel the error scrub by passing additional command line arguments -p -s just like a regular scrub. This involves adding a new flag, creating new libzfs interfaces, a new ioctl, and the actual iteration and read-issuing logic. Error scrubbing is executed in multiple txg to make sure pool performance is not affected. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Co-authored-by: TulsiJain tulsi.jain@delphix.com Signed-off-by: George Amanakis <gamanakis@gmail.com> Closes #8995 Closes #12355
| * Add the ability to uninitializeBrian Behlendorf2023-05-183-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | zpool initialize functions well for touching every free byte...once. But if we want to do it again, we're currently out of luck. So let's add zpool initialize -u to clear it. Co-authored-by: Rich Ercolani <rincebrain@gmail.com> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Rich Ercolani <rincebrain@gmail.com> Closes #12451 Closes #14873
| * Refine special_small_blocks property validationDon Brady2023-05-121-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | When the special_small_blocks property is being set during a pool create it enforces a limit of 128KiB even if the pool's record size is larger. If the recordsize property is being set during a pool create, then use that value instead of the default SPA_OLD_MAXBLOCKSIZE value. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Don Brady <dev.fs.zfs@gmail.com> Closes #13815 Closes #14811
* | lib/libc/amd64/string/strchrnul.S: fix edge case in scalar codeRobert Clausecker2023-08-281-7/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When the buffer is immediately preceeded by the character we are looking for and begins with one higher than that character, and the buffer is misaligned, a match was errorneously detected in the first character. Fix this by changing the way we prevent matches before the buffer from being detected: instead of removing the corresponding bit from the 0x80..80 mask, set the LSB of bytes before the buffer after xoring with the character we look for. The bug only affects amd64 with ARCHLEVEL=scalar (cf. simd(7)). The change comes at a 2% performance impact for short strings if ARCHLEVEL is set to scalar. The default configuration is not affected. os: FreeBSD arch: amd64 cpu: 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz │ strchrnul.scalar.0.out │ strchrnul.scalar.2.out │ │ sec/op │ sec/op vs base │ Short 57.89µ ± 2% 59.08µ ± 1% +2.07% (p=0.030 n=20) Mid 19.24µ ± 0% 19.73µ ± 0% +2.53% (p=0.000 n=20) Long 11.03µ ± 0% 11.03µ ± 0% ~ (p=0.547 n=20) geomean 23.07µ 23.43µ +1.53% │ strchrnul.scalar.0.out │ strchrnul.scalar.2.out │ │ B/s │ B/s vs base │ Short 2.011Gi ± 2% 1.970Gi ± 1% -2.02% (p=0.030 n=20) Mid 6.049Gi ± 0% 5.900Gi ± 0% -2.47% (p=0.000 n=20) Long 10.56Gi ± 0% 10.56Gi ± 0% ~ (p=0.547 n=20) geomean 5.045Gi 4.969Gi -1.50% MFC to: stable/14 MFC after: 3 days Approved by: mjg (blanket, via IRC), re (gjb) Sponsored by: The FreeBSD Foundation (cherry picked from commit 3d8ef251aa9dceabd57f7821a0e6749d35317db3)
* | libc: Add timespec_getres(3) as per C23.Dag-Erling Smørgrav2023-08-245-2/+96
| | | | | | | | | | | | | | This also adds support for TIME_MONOTONIC to timespec_get(3). Reviewed by: allanjude Differential Revision: https://reviews.freebsd.org/D41524
* | libc: Fix parsing of hexadecimal numbers in strtol() family.Dag-Erling Smørgrav2023-08-248-9/+33
| | | | | | | | | | | | | | | | This had previously been partly fixed in 2571c7f7200f. MFC after: 1 week Reviewed by: imp, allanjude, emaste Differential Revision: https://reviews.freebsd.org/D41510
* | timerfd: Add manual page.Jake Freeland2023-08-242-0/+344
| | | | | | | | | | | | | | This manual page accompanies the timerfd system calls. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D40218
* | timerfd: Move implementation from linux compat to sys/kernJake Freeland2023-08-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | Move the timerfd impelemntation from linux compat code to sys/kern. Use it to implement the new system calls for timerfd. Add a hook to kern_tc to allow timerfd to know when the system time has stepped. Add kqueue support to timerfd. Adjust a few names to be less Linux centric. RelNotes: YES Reviewed by: markj (on irc), imp, kib (with reservations), jhb (slack) Differential Revision: https://reviews.freebsd.org/D38459
* | libc: iconv: zero out cv_shared on allocationKyle Evans2023-08-234-10/+1
| | | | | | | | | | | | | | | | | | | | Right now we have to zero-initialize most fields in the varius callers, but this is a little error prone. Simplify it by zeroing it out upon allocation instead, drop the other redundant initialization. Reviewed by: markj Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D41546
* | libc: fix c*rtomb/mbrtoc*Kyle Evans2023-08-232-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In 693f88c9da8d ("iconv_std: complete the //IGNORE support"), we more completely implemented //IGNORE, which changed the semantics of ci_discard_ilseq. DISCARD_ILSEQ semantics are supposed to match //IGNORE, so we really can't do much about that particular incompatibility. This broke c*rtomb and mbrtoc* handling of invalid sequences, but it turns out they don't want DISCARD_ILSEQ semantics at all; they really want the subset that we call _CITRUS_ICONV_F_HIDE_INVALID. This restores the exact flow in iconv_std to precisely how it happened prior to 693f88c9da8d. PR: 265871 Fixes: 693f88c9da8d ("iconv_std: complete the //IGNORE support") Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D41513
* | Add membarrier(2)Konstantin Belousov2023-08-231-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | This is an attempt at clean-room implementation of the Linux' membarrier(2) syscall. For documentation, you would need to read both membarrier(2) Linux man page, the comments in Linux kernel/sched/membarrier.c implementation and possibly look at actual uses. Sponsored by: The FreeBSD Foundation MFC after: 1 week Differential revision: https://reviews.freebsd.org/D32360
* | libzstd: Explicitly define ZSTD_DISABLE_ASMJessica Clarke2023-08-221-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | On FreeBSD, ZSTD_ASM_SUPPORTED is defined as 0, but on macOS and Linux it is defined as 1, yet we don't build any of the assembly sources. Rather than add them just for bootstrapping on non-FreeBSD, explicitly define ZSTD_DISABLE_ASM so they're not needed and everything is consistent. This fixes building a bootstrap LLVM toolchain on non-FreeBSD amd64 (the only architecture with assembly available). Reviewed by: emaste, imp Differential Revision: https://reviews.freebsd.org/D41543
* | Document strnstr()'s history.David E. O'Brien2023-08-221-0/+6
| |
* | lib/libc/amd64/string/memcmp.S: add baseline implementationRobert Clausecker2023-08-211-6/+175
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This changeset adds a baseline implementation of memcmp and bcmp for amd64. The same code is used for both functions with conditional code were the behaviour differs (we need more precise output for the memcmp case). FreeBSD documents that memcmp returns the difference between the mismatching characters. Slightly faster code would be possible could we relax this requirement to the ISO/IEC 9899:1999 requirement of merely returning a negative/positive integer or zero. Performance is better than bionic and glibc, except for long strings were the two are 13% faster. This could be because they use SSE4 ptest which we cannot use in a baseline kernel. Sponsored by: The FreeBSD Foundation Approved by: mjg Differential Revision: https://reviews.freebsd.org/D41442
* | lib/libc/amd64/string/stpcpy.S: add baseline implementationRobert Clausecker2023-08-212-11/+135
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a baseline implementation of stpcpy(3) for amd64. It performs quite well in comparison to the previous scalar implementation as well as agains bionic and glibc (though glibc is faster for very long strings). Fiddle with the Makefile to also have strcpy(3) call into the optimised stpcpy(3) code, fixing an oversight from D9841. Sponsored by: The FreeBSD Foundation Reviewed by: imp ngie emaste Approved by: mjg kib Fixes: D9841 Differential Revision: https://reviews.freebsd.org/D41349
* | libc/gen/_pthread_stubs.c: Remove stray whitespacesKonstantin Belousov2023-08-201-2/+2
| | | | | | | | | | Sponsored by: The FreeBSD Foundation MFC after: 1 week
* | libc: export pthread_getname_np stubMinsoo Choo2023-08-206-3/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | pthread_getname_np needs to be provided by libc in order to import jemalloc 5.3.0. A stub implementation for libc pthread_getname_np() is added for _pthread_stubs.c, which always reports empty name for the main thread. Internal _pthread_getname_np() is not exported, but provided for libc own use. Reviewed by: kib MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D41461
* | unbound: Move config.h to lib directory.Dag-Erling Smørgrav2023-08-192-2/+1546
| | | | | | | | | | | | | | It was originally in contrib, and moved to usr.sbin in 6692aa840c1f; I always thought lib would make more sense but never got around to moving it. Reviewed by: cy Differential Revision: https://reviews.freebsd.org/D41504
* | Fix GoogleTest 1.14.0 importEnji Cooper2023-08-193-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | - Prune headers and tests no longer installed after the upgrade. - Remove GoogleTest-related files when MK_GOOGLETEST == no. - Disable `-Werror` with gcc to unbreak the gcc12 CI run with `lib/googletest`. Any issues found by g++ will be filed upstream and hopefully resolved in a future version. - Remove clang -Werror issues which are resolved in version 1.14.0 to avoid masking valid issues. MFC after: 1 week MFC with: 28f6c2f292806bf31230a959bc4b19d7081669a7