The SUS doesn't mention this error code as a possible one [1]. The FreeBSD
manual page specifies a possible ECONNRESET for close(2):
[ECONNRESET] The underlying object was a stream socket that was
shut down by the peer before all pending data was
delivered.
In the past it had been EINVAL (see 21367f630d), and this EINVAL was
added as a safety measure in 623dce13c6. After conversion to
ECONNRESET it had been documented in the manual page in 78e3a7fdd5, but
I bet wasn't ever tested to actually be ever returned, cause the
tcp-testsuite[2] didn't exist back then. So documentation is incorrect
since 2006, if my bet wins. Anyway, in the modern FreeBSD the condition
described above doesn't end up with ECONNRESET error code from close(2).
The error condition is reported via SO_ERROR socket option, though. This
can be checked using the tcp-testsuite, temporarily disabling the
getsockopt(SO_ERROR) lines using sed command [3]. Most of these
getsockopt(2)s are followed by '+0.00 close(3) = 0', which will confirm
that close(2) doesn't return ECONNRESET even on a socket that has the
error stored, neither it is returned in the case described in the manual
page. The latter case is covered by multiple tests residing in tcp-
testsuite/state-event-engine/rcv-rst-*.
However, the deleted block of code could be entered in a race condition
between close(2) and processing of incoming packet, when connection had
already been half-closed with shutdown(SHUT_WR) and sits in TCPS_LAST_ACK.
This was reported in the bug 146845. With the block deleted, we will
continue into tcp_disconnect() which has proper handling of INP_DROPPED.
The race explanation follows. The connection is in TCPS_LAST_ACK. The
network input thread acquires the tcpcb lock first, sets INP_DROPPED,
acquires the socket lock in soisdisconnected() and clears SS_ISCONNECTED.
Meanwhile, the syscall thread goes through sodisconnect() which checks for
SS_ISCONNECTED locklessly(!). The check passes and the thread blocks on
the tcpcb lock in tcp_usr_disconnect(). Once input thread releases the
lock, the syscall thread observes INP_DROPPED and returns ECONNRESET.
- Thread 1: tcp_do_segment()->tcp_close()->in_pcbdrop(),soisdisconnected()
- Thread 2: sys_close()...->soclose()->sodisconnect()->tcp_usr_disconnect()
Note that the lockless operation in sodisconnect() isn't correct, but
enforcing the socket lock there will not fix the problem.
[1] https://pubs.opengroup.org/onlinepubs/9799919799/
[2] https://github.com/freebsd-net/tcp-testsuite
[3] sed -i "" -Ee '/\+0\.00 getsockopt\(3, SOL_SOCKET, SO_ERROR, \[ECONNRESET\]/d' $(grep -lr ECONNRESET tcp-testsuite)
PR: 146845
Reviewed by: tuexen, rrs, imp
Differential Revision: https://reviews.freebsd.org/D48148
(cherry picked from commit 053a988497342a6fd0a717cc097d09c23f83e103)
This change is being done first so any functional changes from the tests
will be clearer to reviewers.
No functional change intended.
MFC after: 2 weeks
Ref: https://reviews.freebsd.org/D47826
(cherry picked from commit 991bd461625a2c521d5be4fd6938deed57f60972)
With the %b format specifier we need enough space to write a uintmax_t
in binary.
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1400
(cherry picked from commit d4f9e326393e3298062a58338e2c94ef6baff8b5)
Some devices might not have a software volume control, but still be
able to be set as recording sources.
PR: 279787
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D48730
(cherry picked from commit f121de8fbcbc8aa82f9fb59039c502406b7c88b6)
Fixes: e59991206b fts(3): be less strict when automount does its job under us walking autofs mount
(cherry picked from commit ab6a311c720e93c860d3dd4a335264d725db7a0d)
- Use a typical tagged list for the open flags instead of a literal
block. This permits using markup in the flag descriptions. Also,
drop the offset to avoid indenting the entire list.
- Note that O_RESOLVE_BENEATH only applies to openat(2)
- Use a clearer description of O_CLOEXEC (what it means, not the
internal flag it sets)
- Note that exactly one permission flag is required.
- Split up a paragraph on various flags so that each flag gets its own
paragraph. Some flags already had their own paragraph, so this is
more consistent. It also makes it clearer which flag a sentence is
talking about when a flag has more than one sentence.
- Appease some errors from igor and man2ps
- In the discussion about a returned directory descriptor opened with
O_SEARCH, avoid the use of Fa fd since the descriptor in question is
a return value and not an argument to open or openat.
- Various and sundry markup and language tweaks
Reviewed by: kib, emaste
Differential Revision: https://reviews.freebsd.org/D48253
(cherry picked from commit 826509a3c3642db6a110f8f43ae8860c40c72ad2)
- Use consistent language to describe user values unchanged by the
kernel.
- Replace passive language with active in a few places.
- Add a history note for kqueuex() and kqueue1().
- Add an MLINK and synopsis for kqueue1().
- Various wording and markup tweaks.
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D48203
(cherry picked from commit 9b1585384d53d0f9cc4585a6efd8cc95116407d7)
Currently, files that belong in the tests package are included in the
ssh, bsnmp, and clibs-dev packages:
ssh.plist
24:@dir(root,wheel,0755,) /usr/tests/secure/libexec
25:@(root,wheel,0444,) /usr/tests/secure/libexec/Kyuafile
bsnmp.plist
82:@dir(root,wheel,0755,) /usr/tests/lib/libbsnmp
83:@(root,wheel,0444,) /usr/tests/lib/libbsnmp/Kyuafile
84:@(root,wheel,0555,) /usr/tests/lib/libbsnmp/bsnmpd_test
clibs-dev.plist
2518:@dir(root,wheel,0755,) /usr/tests/lib/csu
2519:@(root,wheel,0444,) /usr/tests/lib/csu/Kyuafile
This is caused by the PACKAGE=foo assignment in foo/Makefile.inc which
overrides the default PACKAGE?=tests in bsd.test.mk.
To fix this, instead use PACKAGE?=foo in foo/Makefile.inc and set
PACKAGE=tests in foo/tests/Makefile.
PR: 249144
Reviewed by: bapt, emaste
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47025
(cherry picked from commit 3a56015a2f5d630910177fa79a522bb95511ccf7)
Clarify the RETURN VALUES section with improved structure,
the condition of the return value 0, and the setting of errno.
PR: 174581
Reviewed by: jhb, ziaee
Approved by: mhorne (mentor)
Differential Revision: https://reviews.freebsd.org/D48955
(cherry picked from commit 571df2c64a3c1af1fe011303ec08e391e887ecbc)
The SO_SETFIB option can be used to set a socket's FIB number, but there
is no way to retrieve it. Rename SO_SETFIB to SO_FIB and implement a
handler for it for getsockopt(2).
Reviewed by: glebius
MFC after: 2 weeks
Sponsored by: Klara, Inc.
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D48834
(cherry picked from commit ee951eb59f2136a604e3fbb12abf8d8344da0c99)
GETENTROPY_MAX should be defined in limits.h. EINVAL is the return
value for buflen > GETENTROPY_MAX.
PR: 282783
Reviewed by: markj, asomers, jhb
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D47689
Remove extra slashes that end up in the metalog. These double slashes
can produce an invalid specification file if there are subdirectories
down the hierarchy when sorted.
For example, consider the following metalog excerpt:
./base/aaa type=dir
./base//aaa/bbb type=dir
If sorted, would turn out:
./base//aaa/bbb type=dir
./base/aaa type=dir
Apparently missing the ./base/aaa directory in the specification.
Luckily here are no subdirectories.
Reviewed by: imp, emaste
Approved by: emaste (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D48779
(cherry picked from commit bccaf0262dcab84be49c42cc6b7a81c279c44b62)
Remove an extra slash that ends up in the metalog. This double slash
can produce an invalid specification file if there are subdirectories
down the hierarchy when sorted.
For example, consider the following metalog excerpt:
./base/aaa type=dir
./base//aaa/bbb type=dir
If sorted, would turn out:
./base//aaa/bbb type=dir
./base/aaa type=dir
Apparently missing the ./base/aaa directory in the specification.
Luckily here are no subdirectories.
Reviewed by: imp, emaste
Approved by: emaste (mentor)
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D48778
(cherry picked from commit 841856570e7b623c4f1283939936ffa005d2fcf4)
ETSI had one 160Mhz band in regdomain but the other two were missing.
Add them. I am always confused that the bands use the center frequency
of the 20Mhz edge channels rather than the actual edges so it seems we
are only configuring 140Mhz instead of 160Mhz.
We will have to go through the entire regdomain file one
day and make sure to verify all the power levels.
Sponsored by: The FreeSBD Foundation
Reviewed by: adrian
Differential Revision: https://reviews.freebsd.org/D48356
(cherry picked from commit a3a308f0f29b14d522c56dd88231e27fdf206104)
Standardize the definition of a UFS dinode
Differential Revision: https://reviews.freebsd.org/D48472
(cherry picked from commit 1111a44301da39d7b7459c784230e1405e8980f8)
(cherry picked from commit aa90fbed151de512ab6e59f75df009533a15751f)
(cherry picked from commit 256389eaf158acaf67f0530764be8af68edee78c)
(cherry picked from commit 6cd973d903c8f214d84daf91eb75047631bf1618)
(cherry picked from commit e1ebda4458bbaf7d85fb803e20f3afc5441f24d9)
These tests create a linked list with one entry for every group on the
running system. On a system with about 30,000 groups, the test took 69
seconds to run, and crashed Kyua with the below error:
kyua: E: string or blob too big (sqlite op: sqlite3_bind_blob) (sqlite db: /root/.kyua/store/results.usr_tests.20241231-203317-570235.db).
Fix the test by limiting it to operating on the first 1024 groups.
Apply the same change to getpw_test and getserv_test too, which are
vulnerable to the same problem.
Sponsored by: ConnectWise
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D48275
(cherry picked from commit d11904b350214943dedb64c7121d4602799d7afd)
len is unsigned (it is size_t), so cannot be negative.
Sponsored by: The FreeBSD Foundation
(cherry picked from commit fab411c4fd5224e3dd44e0eb288d60b27480e2d1)
We previously claimed that non-page-aligned addresses would return
EINVAL, but the address is in fact rounded down to the page boundary.
Reported by: Harald Eilertsen <haraldei@anduin.net>
Reviewed by: brooks
Sponsored by: The FreeBSD Foundation
Fixes: dabee6fecc ("kern_descrip.c: add fdshare()/fdcopy()")
Differential Revision: https://reviews.freebsd.org/D48465
(cherry picked from commit 9e36aaf0c24cf158e83c69c1d2312c000c3c36f3)
Regroup assignments tweaking preprocessor defines/undefs, and separately
those about include directories.
Re-order include directories a bit more logically, and remove redundant
ones.
Separate logical groups by blank lines.
Build artifacts have been verified to stay the same when produced with
an external LLVM 18 toolchain.
MFC after: 1 month
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D48070
(cherry picked from commit 618c97b87b7124cdfb10d2f33a213c3302c8a98b)
libder will be used in upcoming ECC support in the pkg(7) bootstrap to
read DER-encoded keys and signatures.
(cherry picked from commit f59bb61e1eb4d1e4fc3c60cc14779d0668267cb2)
When a hotplug callback has been registered, and the program using
libusb is calling libusb_exit then the thread handler is set to
NO_THREAD which result in the variable controlling the loop the be set
to 0, it does a last pass through device available without having done
a scan, which result in a sigbus after it tried to unregister all the
devices.
directly break the loop instead and cleanup the list of devices
this fixes the tests with LGPLed libusb's hotplugtest program
MFC After: 3 days
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D48298
(cherry picked from commit ba5834b8e11fd002a663d083a464e397e76cb3a9)
This reverts commit caab831338f4eeaa7455e981478be9fd414b7969, because
some new unresolved issues came up in bug 271087:
Some programs depend on these symbols, when they are compiled for armv6
or armv7. Closes#1560 (slightly changed due to sorting of the symbols).
PR: 271087
Reported by: mmel
MFC after: immediately
(cherry picked from commit b662ca1d6cd82044c6cb79075e1830b97594bef3)