Commit graph

288218 commits

Author SHA1 Message Date
Dimitry Andric dc0b4094ab Silence VLA extension warnings in fusefs tests
Building tests/sys/fs/fusefs with clang 18 results the following
warning:

  tests/sys/fs/fusefs/cache.cc:145:14: error: variable length arrays in C++ are a Clang extension [-Werror,-Wvla-cxx-extension]
    145 |         uint8_t buf[bufsize];
        |                     ^~~~~~~

Because we do not particularly care that this is a clang extension,
suppress the warning.

MFC after:	3 days
2023-12-21 23:45:52 +01:00
Dimitry Andric 69c8025a49 Silence snprintf truncation warnings in printf_test examples
Building share/examples/tests with clang 18 results in a few warnings
like:

  share/examples/tests/tests/plain/printf_test.c:67:6: error: 'snprintf' will always be truncated; specified size is 10, but format string expands to at least 17 [-Werror,-Wformat-truncation]
     67 |         if (snprintf(buffer, sizeof(buffer), "0123456789abcdef") != 16)
        |             ^

Since these tests are meant as an example of testing snprintf overflow,
suppress the warnings.

MFC after:	3 days
2023-12-21 23:45:52 +01:00
Dimitry Andric c794d18822 Fix snprintf truncation in telnet
Building telnet with clang 18 results in the following warning:

  contrib/telnet/telnet/telnet.c:231:5: error: 'snprintf' will always be truncated; specified size is 10, but format string expands to at least 11 [-Werror,-Wformat-truncation]
    231 |     snprintf(temp2, sizeof(temp2), "%c%c%c%c....%c%c", IAC, SB, TELOPT_COMPORT,
	|     ^

The temp2 buffer is 10 chars, while the format string also consists of
10 chars. Therefore, snprintf(3) will truncate the last character, 'SE'
(end sub negotation) in this case.

Bump the buffer to 11 chars to avoid truncation.

MFC after:	3 days
2023-12-21 23:45:52 +01:00
Brooks Davis 5d21ac643b Revert "power*/SYS.h: implement _SYSCALL_BODY() macro"
bapt reports build errors on powerpc/powerpc so this is the most likely
culprit.

This reverts commit e88e127279.
2023-12-21 21:37:09 +00:00
Gleb Smirnoff c1c55da49f pfil: don't leak pfil_head_t on interface detach
PR:		256714
Submitted by:	jcaplan@blackberry.com
2023-12-21 10:53:49 -08:00
Mark Johnston 3ff574c5e1 ufs: Update *eofflag upon a read of an unlinked directory
If the directory is unlinked, no further entries will be returned, but
we return no error.  At least one caller (vn_dir_next_dirent()) asserts
that a VOP_READDIR call which returns no error and no entries will set
*eofflag != 0, so the current behaviour of UFS can trigger an assertion
failure.

Simply set *eofflag in this scenario.

Reviewed by:	olce, kib
Reported by:	syzkaller
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43089
2023-12-21 13:26:46 -05:00
Kristof Provost 881bf8814a pf: export missing state information
We did not export all of the information pfctl expected to print via the
new netlink code. This manifested as pfctl printing 'rtableid: 0', even
when there is no rtable set.

While we're addressing that also export other missing fields such as
dummynet, min_ttl, max_mss, ..

Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-12-21 19:21:17 +01:00
Gleb Smirnoff 330089470f nanobsd: Fix the fix to a typo
Submitted by:		jlduran@gmail.com
Reviewed by:		imp, glebius, emaste
PR:			275691
Differential Revision:	https://reviews.freebsd.org/D43035
Fixes:			d8c70d6dfb
2023-12-21 10:13:44 -08:00
Brooks Davis e88e127279 power*/SYS.h: implement _SYSCALL_BODY() macro
Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and
calls cerror as required.  Use to implement PSEUDO() and RSYSCALL().

Reviewed by:	jhibbits
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43056
2023-12-21 17:57:14 +00:00
Mark Johnston bd1654ce92 freebsd32: Fix error handling for suword32() calls
suword32() returns -1 upon an error, not an errno value.

MFC after:	1 week
2023-12-21 11:54:05 -05:00
Michael Gmelin 3d36053ca6 libifconfig: Fix bridge status member list
When this functionality was moved to libifconfig in 3dfbda3401,
the end of list calculation was modified for unknown reasons, practically
limiting the number of bridge member returned to (about) 102.

This patch changes the calculation back to what it was originally and
adds a unit test to verify it works as expected.

Reported by:	Patrick M. Hausen (via ML)
Reviewed by:	kp
Approved by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43135
2023-12-21 16:50:27 +01:00
Vincenzo Maffione ad874544d9 libnetmap: remove interface name validation
When trying to use a VLAN device (e.g. "em0.123") with a dot
the library fails to parse the interface correctly. The former
pattern is much too restrictive given that almost all characters
can be coerced into a device name via ifconfig.

Remove the particularly restrictive validation.  Some characters
still cannot be used as an interface name as they are used as
delimiters in the syntax, but this allows to be able to use most
of them without an issue.

Submitted by:	franco@opnsense.org
Differential Revision:	https://reviews.freebsd.org/D42485
Reviewed by:	vmaffione
2023-12-21 14:43:57 +00:00
Warner Losh 64db9a0f82 Add kenv .Xr in kldload(8) and loader.conf(5)
Sponsored by:		Netflix
2023-12-20 21:17:38 -07:00
Warner Losh 9e6d11ce9a vtnet: Adjust rx buffer so IP header 32-bit aligned
Call madj(m, ETHER_ALIGN) to offset rx buffers when allocating them.
This improves performance everywhere, and allows armv7 to work at all.

PR:			271288 (PR had a different fix than I wound up with)
MFC After:		3 days
Sponsored by:		Netflix
Differential Revision:	https://reviews.freebsd.org/D43136
2023-12-20 21:16:45 -07:00
Warner Losh 486ee36440 rl: Fix typo
'or' should be 'of' here

Sponsored by:		Netflix
2023-12-20 21:16:29 -07:00
Doug Moore 6dd15b7a23 vm_phys; fix uncalled free_contig
Function vm_phys_free_contig does not always free memory properly when
the npages parameter is less than max block size.  Change it so that it does.

Note that this function is not currently invoked, and this error was
not triggered in earlier versions of the code.

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D42891
2023-12-20 21:37:47 -06:00
Robert Clausecker c91cd7d03a lib/libc/amd64/string/strcspn.S: always return earliest match in 17--32 char case
When matching against a set of 17--32 characters, strcspn() uses two
invocations of PCMPISTRI to match against the first 16 characters
of the set and then the remaining characters.  If a match was found in
the first half of the set, the code originally immediately returned
that match.  However, it is possible for a match in the second half of
the set to occur earlier in the vector, leading to that match being
overlooked.

Fix the code by checking if there is a match in the second half of the
set and taking the earlier of the two matches.

The correctness of the function has been verified with extended unit
tests and test runs against the glibc test suite.

Approved by:	mjg (implicit, via IRC)
MFC after:	1 week
MFC to:		stable/14
2023-12-21 03:17:17 +01:00
Robert Clausecker a0ecf2224e lib/libc/tests/string/strcspn_test.c: add test for correct match order
This new unit test verifies that if there are multiple
matches, the first match is returned, ignoring later
matches.

Approved by:	mjg (blanket, via IRC)
MFC after:	1 week
MFC to:		stable/14
2023-12-21 03:16:57 +01:00
Konstantin Belousov 7c8f163184 vmm.h: remove dup declaration
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43139
2023-12-21 01:51:47 +02:00
Dag-Erling Smørgrav fcaae06579 pwd_mkdb: Cosmetic nit.
Sponsored by:	Klara, Inc.
2023-12-20 22:42:42 +01:00
Dimitry Andric 87eea35e3f Add missing /usr/include/c++/v1/__mdspan/mdspan.h header
I missed this header while updating the Makefile for libc++ 17.

PR:		273753
MFC after:	1 month
2023-12-20 20:16:57 +01:00
Dag-Erling Smørgrav afdce08370 renice: Clean up the tests a bit.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	ngie, asomers
Differential Revision:	https://reviews.freebsd.org/D43087
2023-12-20 17:59:37 +01:00
Dimitry Andric 0c3af23961 Add missing sources to libclang_rt Makefiles, clean up unneeded ones
During the llvm-17 merge, a few new source files were not added to the
libclang_rt Makefiles, in particular sanitizer_thread_arg_retval.cpp
which is now required for AddressSanitizer and MemorySanitizer. Also,
MemorySanitizer now requires msan_dl.cpp.

While here, clean out a number of source files that compile into nothing
(because they only contain non-FreeBSD parts). Also, remove a duplicated
instance of tsan_new_delete.cpp from libclang_rt.tsan, since it is only
supposed to live in libclang_rt.tsan_cxx.

PR:		275854
Reported by:	jbeich
MFC after:	1 month
2023-12-20 17:08:26 +01:00
Gordon Bergling fa826f64e1 rtnetlink.4: Fix a typo in the manual pag
- s/constists/consists/

MFC after:	3 days
2023-12-20 10:06:08 +01:00
Yuri Pankov 7d413ee805 Revert "locale: regenerate SJIS charmap from CLDR"
...as it broke colldef build.

This reverts commit a4a9d2a64a.
2023-12-20 14:14:27 +07:00
Yuri Pankov a4a9d2a64a locale: regenerate SJIS charmap from CLDR
There are some noticable differences affecting the '\' and '~'
characters between our current charmap and latest CLDR version.

PR:		264299, 275444
Reviewed by:	bapt
Tested by:	uratan@miomio.jp
Differential Revision:	https://reviews.freebsd.org/D42848
2023-12-20 13:24:22 +07:00
Martin Matuska 188408da9f zfs: merge openzfs/zfs@dbda45160
Notable upstream pull request merges:
 #15665 9b1677fb5 dmu: Allow buffer fills to fail

Obtained from:	OpenZFS
OpenZFS commit:	dbda45160f
2023-12-19 23:19:48 +01:00
Dmitry Luhtionov 45835894bd pchtherm(4): Add PCI ID for Wellsburg Thermal Subsystem
MFC after:	2 weeks
2023-12-19 23:32:01 +03:00
Dmitry Luhtionov cb494408d8 ichsmb(4): Add PCI ID for Intel Ice Lake SMBus controller
MFC after:	2 weeks
2023-12-19 23:32:01 +03:00
Gleb Smirnoff 513f2e2e71 tcp: always set tcp_tun_port to a correct value
The tcp_tun_port field that is used to pass port value between UDP
and TCP in case of tunneling is a generic field that used to pass
data between network layers.  It can be contaminated on entry, e.g.
by a VLAN tag set by a NIC driver.  Explicily set it, so that it
is zeroed out in a normal not-tunneled TCP.  If it contains garbage,
tcp_twcheck() later can enter wrong block of code and treat the packet
as incorrectly tunneled one.  On main and stable/14 that will end up
with sending incorrect responses, but on stable/13 with ipfw(8) and
pcb-matching rules it may end up in a panic.

This is a minimal conservative patch to be merged to stable branches.
Later we may redesign this.

PR:			275169
Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D43065
2023-12-19 11:24:17 -08:00
Gleb Smirnoff 48b55a7c7b tcp_hpts: make the module unloadable
Although the HPTS subsytem wasn't initially designed as a loadable
module, now it is so.  Make it possible to also unload it, but for
safety reasons hide that under 'kldunload -f'.

Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D43092
2023-12-19 10:21:56 -08:00
Gleb Smirnoff 175d4d6988 tcp_hpts: use tcp_pace.cts_last_ran for last ran table
Remove the global cts_last_ran and use already existing unused field of
struct tcp_hptsi, which seems originally planned to hold this table.  This
makes it consistent with other malloc-ed tables, like main array of HPTS
entities and CPU groups.

Reviewed by:		tuexen
Differential Revision:	https://reviews.freebsd.org/D43091
2023-12-19 10:21:56 -08:00
Kristof Provost c2e0b604a3 netinet tests: test that we send IGMP join/leave packets as expected
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-12-19 17:47:41 +01:00
Kristof Provost ec6682ed6c atf.test: fix installation of python test scripts
Python test scripts get processed (to add the `#! /usr/libexec/
atf_pytest_wrapper` shebang line), into a .xtmp file, and installed from
there. However, as there was no dependency of this .xtmp file on the
original file we kept reinstalling the .xtmp file, even if the original
had been edited already.

This could cause great confusion when debugging python test scripts.

Reviewed by:	markj
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D43118
2023-12-19 17:23:54 +01:00
Mike Karels 636592343c tmpfs: increase memory reserve to a percent of available memory + swap
The tmpfs memory reserve defaulted to 4 MB, and other than that,
all of available memory + swap could be allocated to tmpfs files.
This was dangerous, as the page daemon attempts to keep some memory
free, using up swap, and then resulting in processes being killed.
Increase the reserve to a fraction of available memory + swap at
file system startup time.  The limit is expressed as a percentage
of available memory + swap that can be used, and defaults to 95%.
The percentage can be changed via the vfs.tmpfs.memory_percent sysctl,
recomputing the reserve with the new percentage but the initial
available memory + swap.  Note that the reserve can also be set
directly with an existing sysctl, ignoring the percentage.  The
previous behavior can be specified by setting vfs.tmpfs.memory_percent
to 100.

Add sysctl for vfs.tmpfs.memory_percent and the pre-existing
vfs.tmpfs.memory_reserved to tmpfs(5).

PR:		275436
MFC after:	1 month
Reviewed by:	rgrimes
Differential Revision:	https://reviews.freebsd.org/D43011
2023-12-19 09:33:33 -06:00
Mike Karels ed19c0989f tmpfs: enforce size limit on writes when file system size is default
tmpfs enforced the file system size limit on writes for file systems
with a specified size, but not when the size was the default.  Add
enforcement when the size is default: do not allocate additional
pages if the available memory + swap falls to the reserve level.
Note, enforcement is also done when attempting to create a file,
both with and without an explicit file system size.

PR:		275436
MFC after:	1 month
Reviewed by:	cy
Differential Revision:	https://reviews.freebsd.org/D43010
2023-12-19 09:32:58 -06:00
Peter Holm 2134b35e0f stress2: Fix "-Wunused-but-set-variable" warnings. Style fixes, while here 2023-12-19 10:36:41 +01:00
Olivier Certner a540e5ee07 committers-src: Add olce@ with mentors emaste@ and markj@
Approved by:        emaste (mentor)
2023-12-19 09:43:45 +01:00
Mark Johnston d760d74dbe ieee80211: Check for copyout() errors in the SIOCG80211STATS handler
In preparation for annotating copyin() and related functions with
__result_use_check.

Reviewed by:	bz, emaste
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43095
2023-12-18 22:44:54 -05:00
Bjoern A. Zeeb eac3646fcd LinuxKPI: 802.11: more TXQ implementation and locking
Implement ieee80211_handle_wake_tx_queue() and ieee80211_tx_dequeue_ni()
while looking at the code.  They are needed by various wireless drivers.

Introduce an ltxq lock and protect the skbq by that.
This prevents panics due to a race between a driver upcall and
the net80211 tx downcall.  While the former should be rcu protected we
cannot rely on that.
It remains questionable if we need to protect further fields there
(with a different lock?).

Also introduce a txq_mtx on the lhw which needs to be further deployed
but we need to come up with a good strategy to not end up with 7 different
locks.

Sponsored by:	The FreeBSD Foundation
PR:		274178, 275710
Tested by:	cc
MFC after:	3 days
2023-12-19 00:50:49 +00:00
Robert Wing acd5638e26 tty: delete knotes when TTY is revoked
Do not clear knotes from the TTY until it gets dealloc'ed, unless the
TTY is being revoked, in that case delete the knotes when closed is
called on the TTY.

When knotes are cleared from a knlist, those knotes become detached from
the knlist. And when an event is triggered on a detached knote there
isn't an associated knlist and therefore no lock will be taken when the
event is triggered.

This becomes a problem when a detached knote is triggered on a TTY since
the mutex for a TTY is also used as the lock for its knlists. This
scenario ends up calling the TTY event handlers without the TTY lock
being held and tripping on asserts in the event handlers.

PR:             272151
Reviewed by:	kib, markj
Differential Revision:	https://reviews.freebsd.org/D41605
2023-12-18 15:40:46 -09:00
Mark Johnston d9b7301bb7 nvme: Initialize HMB entries before loading them into the controller
struct nvme_hmb_desc contains a pad field which was not getting
initialized before being synced.  This doesn't have much consequence but
triggers a report from KMSAN, which verifies that host-filled DMA memory
is initialized before it is made visible to the device.  So, let's just
initialize it properly.

Reported by:	KMSAN
Reviewed by:	mav, imp
MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
Differential Revision:	https://reviews.freebsd.org/D43090
2023-12-18 17:45:24 -05:00
Brooks Davis 8a1b84f861 arm/SYS.h: align with other arches
Rename SYSTRAP() macro to _SYSCALL() and add _SYSCALL_BODY() which invokes
the syscall via _SYCALL() and then calls cerror as required.  Use to
implement PSEUDO() and RSYSCALL() removing _SYSCALL_NOERROR().

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43061
2023-12-18 22:28:42 +00:00
Brooks Davis d444ef5393 arm/SYS.h: remove unused CURBRK macro
The last use was removed in 2018 as part of a reimplementation of brk()
and sbrk() in commit 9d9fd255d6.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43060
2023-12-18 22:28:42 +00:00
Brooks Davis 8f465f509b {amd64,i386}/SYS.h: add _SYSCALL and _SYSCALL_BODY
Add a _SYSCALL(name) which calls the SYS_name syscall.  Use it to add a
_SYSCALL_BODY() macro which invokes the syscall and calls cerror as
required.  Use the latter to implement PSEUDO() and RSYSCALL().

Reviewed by:	imp, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43059
2023-12-18 22:28:42 +00:00
Brooks Davis 300bbb3a43 riscv/SYS.h: implement _SYSCALL_BODY() macro
Add _SYSCALL_BODY() macro which invokes the syscall via _SYCALL() and
calls cerror as required.  Use to implement PSEUDO() and RSYSCALL().

Reviewed by:	imp, markj
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43057
2023-12-18 22:28:42 +00:00
Mark Johnston 604de40a02 kqueue.9: Update the description of knlist_clear()
knlist_clear() does not free knotes and so does not call fdrop(), so
remove the bit of the function description which claims otherwise.  (The
knote will be dropped by the next queue scan, and it is at that point
that the fd reference will be dropped.)

MFC after:	1 week
2023-12-18 13:16:48 -05:00
Mark Johnston ccf8e1bb38 arm64: Remove an unused global variable
No functional change intended.

MFC after:	1 week
Sponsored by:	Klara, Inc.
Sponsored by:	Juniper Networks, Inc.
2023-12-18 13:13:43 -05:00
Warner Losh e02bee0b3e efibootmgr: Report the path to the device
Report the entire path to the device, rather than the the bit after /dev/
for the --esp command. Nothing in the tree depends on the output
format: Only bsdinstall's bootconfig script calls efibootmgr, and it
doesn't use the --esp/-E flag.

Sponsored by:		Netflix
2023-12-18 10:09:13 -07:00
Warner Losh 6aa1b4332f efibootmgr: Document -e command line switch
-e env will include `env` in the boot loader. Document that the boot
loader appends the `env` to the BootXXXX variable, and will parse it as
a series of a=b values to set in the boot loader's environment.  These
assignments are separated by spaces. The env arg needs to be quoted if
more than one env var is to be set (we parse only the next argument on
the command line).

Sponsored by:		Netflix
2023-12-18 10:01:38 -07:00