loopback: fix use-after-free
Once we hand an mbuf over to netisr_queue() we may no longer access it.
Save the length before the call so we can use it to increment counters
afterwards.
Fixes: 956acdce0505 ("loopback: Account for packet drops")
Sponsored by: Rubicon Communications, LLC ("Netgate")
pf: do not allow flags to be changed with securelevel set
With securelevel set (for pf that means >= 3) we're expected to reject
rule changes. However, we allowed interface flags to be changed, which
would allow 'set skip on X' to be changed.
Remove DIOCSETIFFLAG and DIOCCLRIFFLAG from the securelevel whitelist.
MFC after: 1 week
Reported by: cyberkittens
Sponsored by: Rubicon Communications, LLC ("Netgate")
pf: only allow a subset of netlink calls when securelevel is set
Extend the genl_cmd struct to allow calls to also carry a securelevel.
If that's set compare the current securelevel to only allow the call if
the level is lower than that.
If no value is specified continue to allow calls in any securelevel,
as before.
This allows us to easily implement the same securelevel restrictions for
pf as we have for the corresponding ioctls.
Reviewed by: glebius
MFC after: 1 week
Sponsored by: Rubicon Communications, LLC ("Netgate")
Differential Revision: https://reviews.freebsd.org/D56390
rtw89: fix mismerge
Due to FreeBSD-specific code it seems a code update was not applied
to the FreeBSD part during the v6.17 driver update.
Add the missing lines.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Fixes: b35044b38f74c
sound examples: Add mmap example
This example opens separate OSS capture and playback channels in mmap
mode, places them into a sync group, and starts them together so both
ring buffers advance on the same device timeline. It then monitors the
capture mmap pointer with SNDCTL_DSP_GETIPTR, converts that pointer into
monotonic absolute progress using the reported block count, and copies
newly recorded audio from the input ring to the matching region of the
output ring.
The main loop is driven by an absolute monotonic frame clock rather than
a fixed relative usleep delay. Wakeups are scheduled from the sample
rate using a small frame step similar to the SOSSO timing model, while
the audio path itself stays intentionally simple: just copy input to
output, with no explicit xrun recovery or processing beyond ring
wraparound handling.
MFC after: 1 week
Reviewed by: christos
[3 lines not shown]
dpaa2: ni: add more stats and link information
In addition to the locally generated statistics counters, dpaa2 ni
provides a larger set of counters than we currently export via
sysctl. Add (most of) the missing counters and descriptions.
Around Page 3/4 there are some things left to do if we want.
Also the manual was not clear on the descriptions of 3/0 and 3/1.
The second half of the change adds another sysctl note which exports
the link-state, speed, and capabilities set as a text-blob. This is
especially interesting in case the "ni" stops passing packets.
From what I have found in that case the (internal) link state of the
ni goes DOWN but we do not see an interrupt for a link-state change.
Being able to diagnose the state helps to (manually) fix it for now
by changing the media status to 10BaseT or none and then back to auto.
That usually brings the internal link state back UP.
MFC after: 3 days
[3 lines not shown]
bsdinstall.8: Document DISTRIBUTIONS defaults correctly
Some targets override the default value of DISTRIBUTIONS.
Document that in the manual page.
Reported by: Nia Alarie <nia at NetBSD.org>
Reviewed by: jlduran
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56528
routing: Make ip[6]_tryforward() FIB-aware for local traffic
`ip_tryforward()` and `ip6_tryforward()` checks whether the destination
address is local or not without considering if it belongs to the current FIB.
If the destination is local but not in our FIB, forward it instead
of returning it to ip_input().
PR: 292319
Reviewed by: zlei
MFC after: 1 week
MFC to: stable/15
Differential Revision: https://reviews.freebsd.org/D56353
(cherry picked from commit bf41d86df0d9dc4a1342c579f4e72db3c66b3443)
mtree: stop creating /usr/share/doc/ncurses
In base 68ad2b0d7af2a the ncurses html documentation was removed, and
entries added to ObsoleteFiles.inc to get rid of /usr/share/doc/ncurses,
but the directory was still being re-created via BSD.usr.dist. Remove it
from there too.
Fixes: 68ad2b0d7af2a
MFC after: 1 month
(cherry picked from commit 212272a43767c3d7be3ddb87605612f6164774c1)
geom manuals: Clarify units
The gpart manual says that sizes are specified in blocks, unless an SI
unit suffix is provided. This confuses new operators because GEOM uses
binary bytes, a large difference at modern storage pool sizes. Rewrite
suffixes in all GEOM manuals to consistently clarify this, matching what
we and the rest of the industry have been doing in other documentation.
While here, use non-breaking spaces between numbers and units, unless
they are already written with a hyphen.
MFC after: 3 days
Reviewed by: fuz
Reported by: bbaovanc <bbaovanc at bbaovanc.com>
Differential Revision: https://reviews.freebsd.org/D56534
fusefs: better handling for low-memory conditions
Under conditions of low memory, getblk can fail. fusefs was not
handling those failures very systematically. It was always using
PCATCH, which appears to have been originally copy/pasted from the NFS
client code, but isn't always appropriate:
* During fuse_vnode_setsize_immediate, which can be called from many
different VOPs and from the vn_delayed_setsize mechanism, remove
PCATCH. Some of these callers cannot tolerate allocate failure.
* In fuse_inval_buf_range, don't assume that getblk will always succeed.
* When calling fuse_inval_buf_range from VOP_ALLOCATE,
VOP_COPY_FILE_RANGE, or VOP_WRITE (with IO_DIRECT), return EINTR if
the allocation fails.
* When calling fuse_inval_buf_range from VOP_DEALLOCATE, remove PCATCH.
This VOP must not fail with EINTR.
[7 lines not shown]
include/stdbit.h: declare size_t, (u)int*_t, and (u)int_least*_t
These are required by ISO/IEC 9899:2024 § 7.18.1 ¶ 1 but were forgotten
in my initial work.
The current approach leaks intptr_t, uintptr_t, intmax_t, and uintmax_t
through <sys/_stdint.h>. This could be avoided using a more complicated
approach if desired.
PR: 294131
Fixes: 6296500a85c8474e3ff3fe2f8e4a9d56dd0acd64
Reported by: Collin Funk <collin.funk1 at gmail.com>
Reviewed by: imp
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56515
amd64: fix INVLPGB range invalidation
AMD64 Architecture Programmer's Manual Volume 3 says the following:
> ECX[15:0] contains a count of the number of sequential pages to
> invalidate in addition to the original virtual address, starting from
> the virtual address specified in rAX. A count of 0 invalidates a
> single page. ECX[31]=0 indicates to increment the virtual address at
> the 4K boundary. ECX[31]=1 indicates to increment the virtual address
> at the 2M boundary. The maximum count supported is reported in
> CPUID function 8000_0008h, EDX[15:0].
ECX[31] being what we call INVLPGB_2M_CNT, signaling to increment the
VA by 2M.
> This instruction invalidates the TLB entry or entries, regardless of
> the page size (4 Kbytes, 2 Mbytes, 4 Mbytes, or 1 Gbyte). [...]
Combined with this, my interpretation of the current code is: if
[20 lines not shown]
membarrier(2): use atomic for lockless read of curproc->p_flag2
Reviewed by: markj, Ricardo Branco <rbranco at suse.com>
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D56507
rtld: fix processing of preloaded z_initfirst objects
After we found some preloaded z_initfirst object, we must process till
the end of the preload list still, not stopping on the first found
object.
Reported by: des
Reviewed by: des, markj, siderop1 at netapp.com
Fixes: 78aaab9f1cf359f3b7325e4369653f6b50593393
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
Differential revision: https://reviews.freebsd.org/D56466
ctld: Return from the inner "main" loop on EINTR
This ensures that child processes are reaped in the outer loop in
main().
PR: 294035
Reviewed by: asomers
Fixes: 66b107e82b2f ("ctld: Use kevent(2) for socket events rather than select(2)")
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D56525
nvmf_che: Don't leak a socket if an error occurs finalizing the socket
If soreserve() or sosetopt() (to set TCP_NODELAY) fails after claiming
the socket from the file descriptor, explicitly close the socket
before returning failure.
Sponsored by: Chelsio Communications
Differential Revision: https://reviews.freebsd.org/D55493
geom_part: Restore the human readable format of size
Prior to the change 4f809ffec69c, the sizes are formated by
humanize_number(3) with the flag HN_DECIMAL, which displays the result
using one decimal place when it is less than 10. That is more accurate
and useful. Add equivalent field modifier hn-decimal to xo_emit() to
restore the previous behavior.
Reported by: Mark Millard
Reviewed by: js
Fixes: 4f809ffec69c gpart: add libxo support for "show" subcommand + man page updates
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D56514
pf: Use MTX_DUPOK to initialize hash chain mutexes
pf_udp_mapping_insert() may lock more than one row at a time.
Fixes: cd5ff4e841fb ("pf: use hashalloc(9) for key, id, src-node and udp-endpoint hashes")
Reviewed by: kp
Differential Revision: https://reviews.freebsd.org/D56501
ntp_adjtime.2: Increase visibility
+ s/ntp/ntpd/ for correctness + apropos results in document description
+ silence a linter warning by escaping a period with a zero-width space
MFC after: 3 days
(cherry picked from commit b49b3ccd40bda02f530c679f23f42ba9e0e4b2e2)
freebsd-base.7: Break examples into subsections
Break the examples into subsections, so that we can have multi-step
examples.
MFC after: 3 days (to 15 only)
Discussed with: ivy
Differential Revision: https://reviews.freebsd.org/D55526
(cherry picked from commit 5f922bd20d81af4b5759b8f104d5c22ee3e5cd1b)
Bourne shell -> POSIX shell
The FreeBSD shell is a POSIX compatible shell. It evolved over several
decades from the Almquist shell, which was preceeded a decade before
that by the Bourne shell. Most readers today have never seen a Bourne
shell. If someone wants to learn to use our shell, they need to look for
tutorials on the POSIX shell. Align descriptions through out the tree
with this reality, consistent with it's manual and common parlance.
We made a similar change to the doc tree in b4d6eb01540fe.
MFC after: 3 days
Reviewed by: carlavilla
Differential Revision: https://reviews.freebsd.org/D56382
(cherry picked from commit dc140a9fc151f3717bce2157f49070daafa13ec0)