Commit graph

288242 commits

Author SHA1 Message Date
Xin LI 906748d208 newsyslog(8): Add option to globally override compression method.
Historically, newsyslog compressed rotated log files to save disk space.
This was useful in the early days. However, with modern file systems like
ZFS offering native compression, and with the availability of larger hard
drives, the benefits of additional compression have become less significant.
This is particularly true considering the inconvenience of decompressing
log files when searching for specific patterns.

Additionally, the original implementation of compression methods was not
future-proof.  As a result, we have redefined the J, X, Y, Z flags to
signify "treat the file as compressible" rather than "compress the file
with that specific method."

A new command-line option, -c, has been introduced to allow overriding
these settings in a more future-proof way. The available choices are:

 * none			 - do not compress, regardless of flag.
 * legacy		 - historical behavior: J=bzip2, X=xz, Y=zstd, Z=gzip.
 * bzip2, xz, zstd, gzip - apply the specified compression method.

Currently, the default is set to 'legacy' to preserve historical behavior.
However, our intention is to change this default to 'none' in FreeBSD 15.0.

Additionally, this update changes the default settings for zstd to use
multithreading and long-range options, better aligning with its intended
use.

Inspired by D42961 .

Reviewed by:	debdrup (earlier version, mdoc(7))
MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D43165
2023-12-22 22:46:33 -08:00
Alexander Motin 8c86b98124 iichid(4): Improve idle sampling hysteresis
In sampling mode some devices return same data indefinitely even if
there is nothing to report.  Previous idle hysteresis implementation
activated only when device returned no data, so some devices ended up
polled at fast rate all the time.  This new implementation compares
each new report with the previous, and, if they are identical, after
reaching threshold also drop sampling rate to slow.

On my Dell XPS 13 9310 with iichid(4) touchscreen and touchpad this
reduces idle power consumption by ~0.5W by reducing number of context
switches in the driver from ~4000 to ~700 per second when not touched.

MFC after:	1 month
2023-12-22 22:50:52 -05:00
Philip Paeps eebb9c2cae contrib/tzdata: import tzdata 2023d
Changes: https://github.com/eggert/tz/blob/2023d/NEWS

MFC after:	1 day
2023-12-23 09:51:01 +08:00
Philip Paeps 893fe32cd2 Import tzdata 2023d 2023-12-23 09:34:58 +08:00
Rick Macklem dac33a65b9 RELNOTES: Add an entry for commit 7c5146da12 2023-12-22 12:25:19 -08:00
Rick Macklem 922e78f65f mountd: Update exports.5 for commit 7c5146da12
Commit 7c5146da12 modified mountd so that it uses
strunvis(3) to decode directory names in exports lines.
This allows special characters, such as blanks, to be
encoded in the directory names.

This patch updates the exports.5 man page for this change.

This is a content change.

Reviewed by:	karels, pauamma_gundo.com (manpages)
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42163
2023-12-22 12:17:36 -08:00
Rick Macklem b484bcd504 nfscl: Fix handling of a copyout() error reply
If vfs.nfs.nfs_directio_enable is set non-zero (the default is
zero) and a file on an NFS mount is read after being opened
with O_DIRECT | O_ RDONLY, a call to nfsm_mbufuio() calls
copyout() without checking for an error return.
If copyout() returns EFAULT, this would not work correctly.

Only the call path
 VOP_READ()->ncl_readrpc()->nfsrpc_read()->nfsrpc_readrpc()
will do this and the error return for EFAULT will
be returned back to VOP_READ().

This patch adds the error check to nfsm_mbufuio().

Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D43160
2023-12-22 12:11:22 -08:00
Konstantin Belousov 671a00491d vm_iommu_map()/unmap(): stop transiently wiring already wired pages
Namely, switch from vm_fault_quick_hold() to pmap_extract() KPI to
translate gpa to hpa. Assert that the looked up hpa belongs to the wired
page, as it should be for the VM which is configured for pass-throu
(this is theoretically a restriction that could be removed on newer
DMARs).

Noted by:	alc
Reviewed by:	alc, jhb, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43140
2023-12-22 19:34:27 +02:00
Konstantin Belousov 3abc72f871 vmm_iommu_modify(): split vm_iommu_map()/unmap() into separate functions
Reviewed by:	alc, jhb, markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D43140
2023-12-22 19:34:27 +02:00
Kristof Provost e774c1ef27 pf: mark netlink commands as requiring NETINET_PF privileges
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-12-22 17:43:30 +01:00
John Baldwin d281fece43 kldxref: Appease a Coverity warning
While parsing .dynamic, nsym is set when parsing the symbol table from
.dynsym.  That parsing also sets ef->ef_symtab to a non-NULL value.
The value of nsym isn't validated until after a check for
ef->ef_symtab being NULL, so nsym always has a valid value when it is
read.  However, that chain of events is a bit much for static analysis
to follow, so initialize nsym to 0 before parsing sections to quiet
the warning.

Reported by:	Coverity Scan
CID:		1532339
Sponsored by:	DARPA
2023-12-22 07:49:40 -08:00
John Baldwin 0d557cdf6f kldxref: Simplify handling of ELF object files
Unlike the backend for ELF DSOs, the object file backend allocated an
aligned chunk of memory and read all of the in-memory sections from
the file into this memory even though most of the file contents were
never used.  Instead, just track a set of virtual addresses (based at
0) that each loaded section would be loaded at and only read the
necessary bits from the backing file when needed.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43126
2023-12-22 07:49:18 -08:00
John Baldwin ed96fd7fc6 kldxref: Simplify elf_read_raw_data
Use pread as a valid offset is always passed now.  Originally the DSO
code read the .hash section in two separate requests and relied on the
implicit offset for the second read, but now the hash table is fetched
in a single call.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43125
2023-12-22 07:49:03 -08:00
John Baldwin 6d46e2e0a7 kldxref: Tidy error handling for invalid addresses
- Don't print an offset value that's always zero.

- ef_get_offset can't return -1.

Reviewed by:	imp
Sponsored by:	DARPA
Differential Revision:	https://reviews.freebsd.org/D43124
2023-12-22 07:48:47 -08:00
Konstantin Belousov 72f1e31f5f bhyve.8: fix -k description
Apparently 19eaa01bea inserted -K description in the middle of -k.

Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D43164
2023-12-22 17:29:33 +02:00
Konstantin Belousov 59a35b7c6b bhyve.8: add missed dot
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Differential revision:	https://reviews.freebsd.org/D43164
2023-12-22 17:29:25 +02:00
Tijl Coosemans 272b4b764b devd: Don't install autofs.conf with WITHOUT_AUTOFS 2023-12-22 15:27:50 +01:00
Richard Scheffenegger 8717c306bd tcp: allow userspace use of tcp header flags accessor functions
Provide accessor functions to all 12 possible TCP header
flags for userspace too.

Reviewed By:           zlei
MFC after:             2 weeks
Sponsored by:          Netapp, Inc.
Differential Revision: https://reviews.freebsd.org/D43152
2023-12-22 02:20:29 +01:00
Pawel Jakub Dawidek eb4d13126d seq(1): Put separator only between the elements.
- Using non-default ('\n') separator will produce an output with the
  separator at the end of the output, eg.

	% echo "[$(seq -s ' ' 0 2)]"
	[0 1 2 ]

- The output should always be followed by a new line character. Currently:

	% seq -s ' ' 0 2
	0 1 2 %

This change makes seq(1) to behave the same way Linux seq(1):

	% echo "[$(seq -s ' ' 0 2)]"
	[0 1 2]

	% seq -s ' ' 0 2
	0 1 2
	%

Approved by:	oshogbo
Differential Revision:	https://reviews.freebsd.org/D43094
2023-12-21 21:54:05 -08:00
Bill Sommerfeld 8f7ed58a15 regex: mixed sets are misidentified as singletons
Fix "singleton" function used by regcomp() to turn character set matches
into exact character matches if a character set has exactly one
element.

The underlying cset representation is complex; most critically it
records"small" characters (codepoint less than either 128
or 256 depending on locale) in a bit vector, and "wide" characters in
a secondary array.

Unfortunately the "singleton" function uses to identify singleton sets
treated a cset as a singleton if either the "small" or the "wide" sets
had exactly one element (it would then ignore the other set).

The easiest way to demonstrate this bug:

	$ export LANG=C.UTF-8
	$ echo 'a' | grep '[abà]'

It should match (and print "a") but instead it doesn't match because the
single accented character in the set is misinterpreted as a singleton.

Reviewed by:	kevans, yuripv
Obtained from:	illumos
Differential Revision:	https://reviews.freebsd.org/D43149
2023-12-22 12:19:59 +07:00
Bjoern A. Zeeb 488e8a7fac LinuxKPI: reduce impact of large MAXCPU
Start scaling arrays dynamically instead of using MAXCPU, resulting in
extra allocations on startup but reducing the overall memory footprint.
For the static single CPU mask we provide two versions to further save
memory depending on a low or high CPU count system.  The threshold to
switch is currently at 128 CPUs on 64bit platforms.
More detailed comments on the implementations can be found in the code.

If I am not wrong on a MAXCPU=65536 system the memory footprint should
roughly go down from 512M to 1.5M for the static single CPU mask.

Submitted by:	olce (most of this final version)
Sponsored by:	The FreeBSD Foundation
PR:		274316
Differential Revision: https://reviews.freebsd.org/D42345
2023-12-22 00:22:04 +00:00
Bjoern A. Zeeb e85eb4c8d7 net80211: adjust more VHT structures/fields
Replace ieee80211_ie_vhtcap with ieee80211_vht_cap and
ieee80211_ie_vht_operation with ieee80211_vht_operation.
The "ie" version has the two bytes type/length at the beginning which
we did not actually use as such (the one place doing did just as unused
extra work).

Using the non-"ie" versions allows us to re-use them on shared code.
Using an enum helps us to not accidentally get unsuppored or unhandled
values tough we cannot use it in the struct as we need to ensure the
field width.

ieee80211_vht_operation is guarded by _KERNEL/WANT_NET80211.  While the
header is supposed to be exported to user land historically, software
such as wpa bring their own structure definitions.  For in-tree usage
it is only ifconfig which really cares (at least for now).

Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	adrian (earlier), cc
Differential Revision: https://reviews.freebsd.org/D42901
2023-12-22 00:20:19 +00:00
Bjoern A. Zeeb 72bb33a36b net80211: improve logging about state transitions lost
It is possible that we call ieee80211_new_state_locked() again before
a previous task finished to completion (not run yet or unlocked in
between) since 5efea30f03 (and follow-up).
In either case we would overwrite the new state and argument in the vap.

While most drivers somehow deal with that (or not), LinuxKPI 802.11 compat
code has KASSERTs to keep net80211, LinuxKPI and driver/firmware state in
sync and they may trigger due to a missing transition or more likely a
changed ni/lsta.

Enhance the wlandebug +state logging for these cases so they
are easier to debug.

While here remove the unconditional logging to the message buffer;
it has been here for a good decade but not helped to actually identify
and sort the problem.

Sponsored by:   The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	cc
Differential Revision: https://reviews.freebsd.org/D42560
2023-12-22 00:19:05 +00:00
Dag-Erling Smørgrav 45438f9c8b find: Add a warning about -delete.
MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	pauamma_gundo.com
Differential Revision:	https://reviews.freebsd.org/D43162
2023-12-22 00:41:16 +01:00
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