Commit graph

288467 commits

Author SHA1 Message Date
Zhan-Wei f0d6447c0b pax: Add missing 'for' in comment.
Event: Advanced UNIX Programming Course (Fall23) at NTHU.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/941
2023-12-26 10:24:24 -07:00
Zhan-Wei ebb1fe4006 mv: Improve comment
Fix typo/grammar error: Use the singlar verb ending on exists.

Event: Advanced UNIX Programming Course (Fall23) at NTHU.
Reviewed by: imp, zlei
Pull Request: https://github.com/freebsd/freebsd-src/pull/940
2023-12-26 10:24:22 -07:00
lherschi c327288e8e bluetooth: fix comment in bluetooth.device.conf
The default for discoverable is 'NO' not 'YES'. This now matches the man
page.

Event: Advanced UNIX Programming Course (Fall'23) at NTHU.
Reviewed by: imp, zlei
Pull Request: https://github.com/freebsd/freebsd-src/pull/939
2023-12-26 10:24:19 -07:00
Pin-Yi Kuo 4185d1f76a diff(1): fix a typo
On the manpage of diff(1), "when" is mistyped to "wen".

Event: Advanced UNIX Programming Course (Fall'23) at NTHU.
Signed-off-by: Pin-Yi Kuo <kuokuoyiyi@gapp.nthu.edu.tw>
Reviewed by: imp, zlei
Pull Request: https://github.com/freebsd/freebsd-src/pull/943
2023-12-26 10:07:55 -07:00
Pin-Yi Kuo e3d3e1ff7e df(1): fix a typo
On the manpage of df(1), "according" is mistyped into "acccording"

Event: Advanced UNIX Programming Course (Fall'23) at NTHU.
Signed-off-by: Pin-Yi Kuo <kuokuoyiyi@gapp.nthu.edu.tw>
Reviewed by: imp, zlei, Mina Galić
Pull Request: https://github.com/freebsd/freebsd-src/pull/944
2023-12-26 10:05:29 -07:00
rilysh 8f0498208d bhyve/audio.c: avoid re-calculating the length of dev_name
In the function audio_init(), strlen() is being called two times,
first to get the length of dev_name and second to use in memcpy().
Creating a local variable and keeping the length avoids this
re-calculation.

Signed-off-by: rilysh <nightquick@proton.me>
Reviewed by: imp, zlei
Pull Request: https://github.com/freebsd/freebsd-src/pull/945
2023-12-26 09:36:31 -07:00
Che-Yu Chang 2aa186b3b0 gvinum(8): Fix a typo
On line 354, "go up from" is mistyped as "go up form".

Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/951
2023-12-26 09:12:27 -07:00
Che-Yu Chang f8f3b16b6c camcontrol(8): Fix typos
On line 748, "bigger than" is mistyped as "bigger then", and on line
765, "more than" is mistyped as "more then".

Event: Advanced UNIX Programming Course (Fall’23) at NTHU.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/949
2023-12-26 09:12:23 -07:00
Alexander Motin 5bc10feacc acpi_cpu: Reduce BUS_MASTER_RLD manipulations
Instead of setting and clearing BUS_MASTER_RLD register on every C3
state enter/exit, set it only once if the system supports C3 state
and we are going to "disable" bus master arbitration while in it.

This is what Linux does for the past 14 years, and for even more time
this register is not implemented in a relevant hardware.  Same time
since this is only a single bit in a bigger register, ACPI has to
do take a global lock and do read-modify-write for it, that is too
expensive, saved only by C3 not entered frequently, but enough to be
seen in idle system CPU profiles.

MFC after:	1 month
2023-12-25 21:43:20 -05:00
Mark Johnston 6adf554abd vmm: Fix handling of errors from subyte()
subyte() returns -1 upon an error, not an errno value.

MFC after:	1 week
Fixes:	e17eca3276 ("vmm: Avoid embedding cpuset_t ioctl ABIs")
2023-12-25 21:04:01 -05:00
Mark Johnston c38df501ce compat_freebsd4: Fix handling of errors from subyte()
Upon failure, subyte() returns -1, not an errno value.

MFC after:	1 week
2023-12-25 21:04:01 -05:00
Mark Johnston 74e713804f iscsi: Check for copyout errors in iscsi_ioctl_daemon_receive()
Reviewed by:	jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43148
2023-12-25 21:04:01 -05:00
Mark Johnston 099d25c354 nmount: Ignore errors when copying out an error string
In general we copy error strings as part of reporting an error from
lower layers, so if the copyout() fails there's nothing to do since we'd
prefer to preserve the original error.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	olce, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43147
2023-12-25 21:04:01 -05:00
Mark Johnston bbf221e3e8 geom: Report copyout() errors in g_ctl_ioctl_ctl()
Despite the name, req->serror is used in some cases to copy non-error
messages to userspace.  So, report errors when copying out so long as
they don't clobber an earlier error.

Reviewed by:	mav, imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43146
2023-12-25 21:04:01 -05:00
Mark Johnston 6cdff09c0d gntdev: Handle errors from suword32() in gntdev_alloc_gref()
Try to copy out output values before handling errors, and check that we
did so successfully.  In particular, it doesn't seem sensible to ignore
errors here, otherwise userspace won't have any way to refer to the
allocations.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	royger
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43145
2023-12-25 21:04:01 -05:00
Mark Johnston 68cc77a3b7 mpr: Handle errors from copyout() in ioctl handlers
In preparation for adding a __result_use_check annotation to copyin()
and related functions, start checking for errors from copyout() in
the mpr(4) user command handler.  This should make it easier to catch
bugs.

Reviewed by:	imp, asomers
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D43177
2023-12-25 21:04:01 -05:00
Mark Johnston bcf4a7c7ac mps: Handle errors from copyout() in ioctl handlers
In preparation for adding a __result_use_check annotation to copyin()
and related functions, start checking for errors from copyout() in
the mps(4) user command handler.  This should make it easier to catch
bugs.

Reviewed by:	imp, asomers
MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D43176
2023-12-25 21:04:01 -05:00
Mark Johnston 3379d9b5de umtx: Check for errors from suword32()
This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	kib
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D43144
2023-12-25 21:04:01 -05:00
Mark Johnston f450277f7a thread: Ignore errors when copying out during thr_exit()
It does not seem reasonable to return to userspace after calling
umtx_thread_exit().

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	olce, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43143
2023-12-25 21:04:00 -05:00
Mark Johnston abbc260f74 jail: Ignore errors from copyout() while copying the error string
Reviewed by:	zlei, jamie
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43142
2023-12-25 21:04:00 -05:00
Mark Johnston d0adc2f283 sendfile: Explicitly ignore errors from copyout()
There is a documented bug in sendfile.2 which notes that sendfile(2)
does not raise an error if it fails to copy out the number of bytes
written.  Explicitly ignore the error from copyout() calls in
preparation for annotating copyout() with __result_use_check.

Reviewed by:	glebius, kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43129
2023-12-25 21:04:00 -05:00
Mark Johnston 771501e96f ses: Add error checking for copyout() calls
This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	mav, imp, asomers
Tested by:	asomers
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43130
2023-12-25 21:04:00 -05:00
Mark Johnston bdf03b4bcc powerpc: Avoid ignoring copyin()'s return value
A recent change made it possible for cpu_set_upcall() to return an
error.  Do that here instead of ignoring an error from copyin().

Reviewed by:	jhibbits
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43105
2023-12-25 21:04:00 -05:00
Mark Johnston 3fde275167 linux: Check for copyout errors in linux_fixup()
This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	olce, dchagin
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43104
2023-12-25 21:04:00 -05:00
Mark Johnston 7b68fb5ab2 thread: Add a return value to cpu_set_upcall()
Some implementations copy data to userspace, an operation which can in
principle fail.  In preparation for adding a __result_use_check
annotation to copyin() and related functions, let implementations of
cpu_set_upcall() return an error, and check for errors when copying data
to user memory.

Reviewed by:	kib, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43100
2023-12-25 21:04:00 -05:00
Mark Johnston 4f35450ce5 compat_freebsd4: Check for errors from subyte() in freebsd4_uname()
This is in preparation for adding a __result_use_check annotation to
copyin() and related functions.

Reviewed by:	imp, kib, jhb
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43099
2023-12-25 21:04:00 -05:00
Mark Johnston a01ff11cb7 ocs: Check for copyin errors in the ioctl handler
If copyin() fails, the driver will blindly proceed with whatever had
been in the uninitialized DMA buffer.  This is not what we want.  Check
for copyin failures.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	ram
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43097
2023-12-25 21:04:00 -05:00
Mark Johnston 6bfb7306ef mpi3mr: Check for copyin errors in mpi3mr_map_data_buffer_dma()
A failed copyin will cause the driver to use the contents of
uninitialized buffers instead, which is unlikely to be the behaviour
that we want.  Check for errors.

This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	imp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43098
2023-12-25 21:04:00 -05:00
Mark Johnston b2caed2f8d uhid: Check for errors from copyin() in ioctl handlers
This is in preparation for annotating copyin() and related functions
with __result_use_check.

Reviewed by:	wulf
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43103
2023-12-25 21:04:00 -05:00
Mark Johnston e452fa70d5 hid: Handle errors from copyin() in ioctl handlers
If copyin() fails, the driver will proceed blindly with a zeroed buffer,
which is not what we want.  In preparation for annotating copyin() with
__result_use_check, start checking for errors.

Reviewed by:	wulf
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43102
2023-12-25 21:04:00 -05:00
Mark Johnston 81eb7baa69 freebsd32: Report errors when copying out oldlenp in __sysctl
This matches the native implementation's behaviour.

Reviewed by:	kib
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43101
2023-12-25 21:04:00 -05:00
Mark Johnston 711880597c ath: Handle errors from copyout() in ath_rate_fetch_node_stats()
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43096
2023-12-25 21:04:00 -05:00
Andrew Gierth 2a1d50fc12 vfs_domount_update(): correct fsidcmp() usage
MFC after:	3 days
2023-12-26 03:35:46 +02:00
Konstantin Belousov c0047e7c35 iommu_gas_remove(): consolidate places where decision is made to keep the entry
Move all flag checks into iommu_gas_remove_unmap().

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:23 +02:00
Konstantin Belousov f591287756 iommu_gas: make placeholder entry at the start of the GAS zero size
same as the placeholder at the end.  This is required to allow GAS to
start at zero, for integration with vmm.

Also, in iommu_gas_remove(), accept placeholders after remove op.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Konstantin Belousov 273b4de346 iommu: add iommu_gas_remove_locked()
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Konstantin Belousov a59c252903 IOMMU: add GAS map entry flag IOMMU_MAP_ENTRY_FAKE
to allow to shut down assert in iommu_gas_cmp_entries() when used
against fake entry to search for specific place in the tree.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Konstantin Belousov cb1d664b00 iommu_gas: zero fake on-stack map entry used in iommu_gas_remove_clip_left()
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Konstantin Belousov 733da1eb94 iommu_gas: print entries flags and domains if an overlap detected
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Konstantin Belousov 24e38af60a DMAR: add knob to disable RMRR entries installation into domains
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Konstantin Belousov 30ce85ca11 iommu_gas: add ddb 'show iommu_domain' command
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Konstantin Belousov a869643e18 iommu_gas_match_one(): check for underflow
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Konstantin Belousov 7153d5e4bc dmar(9): style, fix indent
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Konstantin Belousov 6afa2333d2 iommu: remove leftover sys/cdefs.h includes
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2023-12-26 03:28:22 +02:00
Dimitry Andric 1ff41cad71 Minimize libc++ errno-related header diffs with upstream
In commit 88640c0e8b the new EINTEGRITY errno value was added, and
this caused us to carry a patch for upstream libc++ since that time.
Because it can cause merge conflicts when importing libc++ code from
upstream, I have submitted an upstream pull request to get most of that
patch integrated.

It turns out that we do not need the errno.h part of it at all, since
all supported FreeBSD versions define EOWNERDEAD and ENOTRECOVERABLE,
and therefore the block that juggles with ELAST values is never used in
FreeBSD. At the moment it only applies to older versions of Linux, or
possibly other platforms.

Therefore the only part that needs to stay is the definition of a enum
errc value for EINTEGRITY, and this is made optional upon EINTEGRITY
being defined, to make it suitable for upstreaming.

No functional change is intended.

MFC after:	1 week
2023-12-25 18:19:12 +01:00
Robert Clausecker fb9c25a91f share/man/man7/simd.7: document SIMD-enhanced memrchr implementation
Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
2023-12-25 15:00:08 +01:00
Robert Clausecker fb197a4f77 lib/libc/amd64/string: add memrchr() scalar, baseline implementation
The scalar implementation is fairly simplistic and only performs
slightly better than the generic C implementation. It could be
improved by using the same algorithm as for memchr, but it would
have been a lot more complicated.

The baseline implementation is similar to timingsafe_memcmp.  It's
slightly slower than memchr() due to the more complicated main
loop, but I don't think that can be significantly improved.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42925
2023-12-25 15:00:05 +01:00
Robert Clausecker 691ff1832e lib/libc/tests/string: add memrchr unit tests
The "values" test case is specifically crafted to detect the off-by-one
error previous discovered in the scalar strchrnul implementation.

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision:	https://reviews.freebsd.org/D42925
2023-12-25 14:59:58 +01:00
Robert Clausecker e0d4f419ac lib/libc/string: document restrict qualification of memccpy() arguments
POSIX.1-2004 and the upcoming C23 agree that memccpy()'s arguments
are restrict qualified and must not overlap.  In 2002, restrict
qualifiers were added to <string.h>'s declaration of the function.
Make things official and document that the arguments must not
overlap.

See also:	61b60edfd3
Approved by:	kib
MFC after:	1 month
MFC to:		stable/14
2023-12-25 14:59:50 +01:00
Robert Clausecker ea7b13771c lib/libc/amd64/string: implement strncat() by calling strlen(), memccpy()
This picks up the accelerated implementation of memccpy().

Tested by:	developers@, exp-run
Approved by:	mjg
MFC after:	1 month
MFC to:		stable/14
PR:		275785
Differential Revision: https://reviews.freebsd.org/D42902
2023-12-25 14:59:48 +01:00