kldxref: Properly handle reading strings near the end of an ELF file
If a string is at or near the end of an input file and the amount of
remaining data in the file is smaller than the maximum string size,
the pread(2) system call would return a short read which is treated as
an error. Instead, add a new helper function for reading a string
which permits short reads so long as the data read from the file
contains a terminated string.
Reported by: jrtc27
Reviewed by: jrtc27
Sponsored by: University of Cambridge, Google, Inc.
Differential Revision: https://reviews.freebsd.org/D44419
loader.4th dictthreshold too small
The dictthreshold in stand/forth/loader.4th is too small
resulting in full dictionary.
Reviewed by: stevek, imp
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D44414
uboot/Makefile move BINDIR
Set BINDIR before we include bsd.init.mk
so we can override it via local.init.mk
Reviewed by: imp
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D44413
nfsd.8: Document ways to minimize Copy operation times
For NFSv4.2, a Copy operation can take a long time to complete.
If there is a concurrent ExchangeID or DelegReturn operation
which requires the exclusive lock on all NFSv4 state, this can
result in a stall of the nfsd server.
This patch documents ways to avoid this problem.
This is a content change.
Reviewed by: karels, wollman, pauamma_gundo.com (manpages)
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D44395
tcp: clear all TCP timers in tcp_timer_stop() when in callout
When a TCP callout decides to disable self, e.g. tcp_timer_2msl() calling
tcp_close(), we must also clear all other possible timers. Otherwise,
upon return, the callout would be scheduled again in tcp_timer_enter().
Revert 57e27ff07aff, which was a temporary partial revert of otherwise
correct 62d47d73b7eb, that exposed the problem being fixed now. Add an
extra assertion in tcp_timer_enter() to check we aren't arming callout for
a closed connection.
Reviewed by: rscheff
random(9): bump removal to FreeBSD 15.0
It has not yet been removed, and still has some in-tree consumers.
PR: 277655
Sponsored by: The FreeBSD Foundation
tcp_rack.4: Update the SEE ALSO section
Correct the surname of one of authors of RFC 8985 and add RFC 5681 and
RFC 6937 (PRR: Proportional Rate Reduction for TCP).
Reviewed by: tuexen
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D44399
arm64: Return all registers to gdb when able
When the kdb thread is the current thread we read the registers from
the trap frame. As this contains all general purpose registers we can
use it to read these in the gdb stub. This allows us to include the
non-callee saved registers, e.g. function arguments.
Reviewed by: imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D44360
uart: Add uart_cpu_acpi_setup to setup the uart
In preperation for adding debug port support add a generic function
to setup the uart from ACPI tables.
Reviewed by: imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D44358
uart: Split out initilisation of the acpi devinfo
Split out the common parts of building the uart devinfo from ACPI
tables from the SPCR parser. This will be used when we support the DBG2
table to find the debug uart to be used by the kernel gdb stub.
Reviewed by: imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D44357
arm64: Rename drop_to_el1 to enter_kernel_el
In the future we may not drop to EL1, e.g. when we support FEAT_VHE
where the kernel runs in EL2.
Reviewed by: emaste, imp
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D43976
netlink: fix route protocol constant values to match Linux
Although these particular constants aren't supported, the incorrect
values break bird 2.15 operation.
PR: 277618
Reported by: Ondrej Zajicek <santiago at crfreenet.org>
(cherry picked from commit 16f8d8829472dfdf6b3b2bb21d652f0bafefccbc)
netlink: fix route protocol constant values to match Linux
Although these particular constants aren't supported, the incorrect
values break bird 2.15 operation.
PR: 277618
Reported by: Ondrej Zajicek <santiago at crfreenet.org>
(cherry picked from commit 16f8d8829472dfdf6b3b2bb21d652f0bafefccbc)
tcp: remove IS_FASTOPEN() macro
The macro is more obfuscating than helping as it just checks a single flag
of t_flags. All other t_flags bits are checked without a macro.
A bigger problem was that declaration of the macro in tcp_var.h depended
on a kernel option. It is a bad practice to create such definitions in
installable headers.
Reviewed by: rscheff, tuexen, kib
Differential Revision: https://reviews.freebsd.org/D44362
crunchgen: slap a dependency on the generated makefile for .lo
crunchgen generates a foo.lo for each binary it will end up crunching
into the final product. While they have a dependency on the libs that
are used to link them, nothing will force relinking if the set of libs
needed to link them is changed. Because of this, incremental builds may
not be possible if one builds a version of, e.g., rescue/ with a broken
set of libs specified for a project -- a subsequent fix won't be rolled
in cleanly, it will require purging the rescue/ objdir.
This is a bit crude, but the foo.mk we generate doesn't actually get
regenerated all that often in practice, so a spurious relink for the
vast majority of crunched objects won't actually happen all that often.
Reviewed by: bapt, emaste, imp
(cherry picked from commit 6e2cfb24ee87fec0f538d04cd69d76a8d58c324f)
libsysdecode: add a decoder for pollfd events
We'll use this in another change to read pollfd arrays coming from a
successful poll(2) operation.
Reviewed by: bapt, jhb
(cherry picked from commit bd23e71f91ceec5dfdffc28bbd0020849fdd20b4)
ktrace: log genio events on failed write
Visibility into the contents of the buffer when a write(2) has failed
can be immensely useful in debugging IPC issues -- pushing this to
discuss the idea, or maybe an alternative where we can set a flag like
KTRFAC_ERRIO to enable it.
When a genio event is potentially raised after an error, currently we'll
just free the uio and return. However, such data can be useful when
debugging communication between processes to, e.g., understand what the
remote side should have grabbed before closing a pipe. Tap out the
entire buffer on failure rather than simply discarding it.
Reviewed by: kib, markj
(cherry picked from commit 47ad4f2d45e406c6316909bc12bc760b2fdd6afb)
kdump: decode pollfd struct arrays coming from poll(2)
We'll handle these just as we do kevents, one per line with subsequent
lines indented sufficiently to distinguish them from the upcoming
return value.
Sample, with indentation stripped and revents changed to '...' in the
first one to keep the line length down:
CALL poll(0x820610560,0x3,0)
STRU struct pollfd[] = { { fd=0, events=0x1<POLLIN>, revents=0x11<...>
{ fd=1, events=0x4<POLLOUT>, revents=0x4<POLLOUT>}
{ fd=-1, events=0x4<POLLOUT>, revents=0} }
RET poll 2
Reviewed by: bapt, jhb
(cherry picked from commit 02c57f7b48772c5ec4e3a0a3405273b387b9bb08)
kern: poll: tap out the pollfd array on successful return
We do this in kern_poll() to include freebsd32 but exclude the linux
compat layer. The ABI should be the same, but the POLL constants are
probably different or should be assumed so.
Reviewed by: bapt, jhb
(cherry picked from commit b5d2165b9046572c9361a8e8b09323a6001ac586)
rtld: add some dlopen tests
dlopen_basic just tests that libthr.so can be dlopen()ed, which will
just serve as a sanity check that "libthr.so" is a thing that can be
dlopened in case we get a weird failure in dlopen_recursing.
dlopen_recursing tests a regression reported after the libsys split,
where some dlopen() may cause infinite recursion and a resulting crash.
This case is inspired by bdrewery's description of what seemed to be
causing his issue.
The corresponding fix landed in commit
968a18975ad ("rtld: ignore load_filtees() calls if we already [...]")
Reviewed by: kib
(cherry picked from commit c5796f1572c82b88e8b6a2810c92f30e5ac3e118)
sockets: remove unused KPIs to manipulate sockets
These KPIs were added in dd0e6c383a9f0 and through 15 years had zero use.
They slightly remind what IfAPI does for struct ifnet. But IfAPI does
that for the sake of large collection of NIC drivers not being aware of
struct ifnet. For the sockets it is unclear what could be a large
collection of externally written kernel modules that need extensively use
sockets and not be aware of their internals at the same time. This
isolation of a structure knowledge requires a lot of work, and just
throwing in a few KPIs isn't helpful.
Reviewed by: kib, olce, markj
Differential Revision: https://reviews.freebsd.org/D44311
inpcb: remove unused KPIs to manipulate inpcbs
These KPIs were added in 9d29c635daa69 and through 15 years had zero use.
They slightly remind what IfAPI does for struct ifnet. But IfAPI does
that for the sake of large collection of NIC drivers not being aware of
struct ifnet. For the inpcb it is unclear what could be a large
collection of externally written kernel modules that need extensively use
inpcb and not be aware of its internals at the same time. This isolation
of a structure knowledge requires a lot of work, and just throwing in a
few KPIs isn't helpful.
Reviewed by: kib, bz, markj
Differential Revision: https://reviews.freebsd.org/D44310
timerfd_create: accept CLOCK_UPTIME/CLOCK_BOOTTIME
This is a common use case when using timerfd_create to actually use
it with CLOCK_BOOTTIME on linux which is CLOCK_UPTIME for us.
Note that currently on freebsd CLOCK_BOOTTIME is CLOCK_UPTIME, but the
semantic is supposed to be different, this has to be fixed later.
Tested with the fnott notification software
Reviewed by: des, imp
Differential Revision: https://reviews.freebsd.org/D44253
(cherry picked from commit cf742faa39a58a9b43b671c66097e6880459d4ae)
(cherry picked from commit 0ecf0b26a750582b804e238e6446db55188d7fdc)