Ed Maste [Wed, 27 Sep 2023 13:36:33 +0000 (09:36 -0400)]
freebsd-update: handle file -> directory on upgrade
Upgrading from FreeBSD 13.2 to 14.0 failed with
install: ///usr/include/c++/v1/__string exists but is not a directory
because __string changed from a file to a directory with an LLVM
upgrade.
Now, remove the existing file when the type conflicts. Note that this
is only an interim fix to facilitate upgrades from 13.2 for 14.0 BETA
testing. This change does not handle the directory -> file case and
further work is needed.
PR: 273661
Reviewed by: dim, gordon
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41893
Christos Zoulas [Wed, 30 Aug 2023 20:37:24 +0000 (20:37 +0000)]
regcomp: use unsigned char when testing for escapes
- cast GETNEXT to unsigned where it is being promoted to int to prevent
sign-extension (really it would have been better for PEEK*() and
GETNEXT() to return unsigned char; this would have removed a ton of
(uch) casts, but it is too intrusive for now).
- fix an isalpha that should have been iswalpha
It's possible for misuse of cdev KPIs or for bugs in devfs itself to
result in e.g. a cdev object's container being freed while still on the
global list used to populate each devfs mount; see PR 273418 for a
recent example.
Since a node may be marked inactive well before it is reaped from the
list, add a new flag solely to track list membership, and employ it in
some basic list integrity assertions to catch bad actors.
When using printm(), one should always pass a scratch pointer to it.
This is achieved by calling printm with memref
BEGIN { printm(fixed_len, memref(ptr, var_len)); }
which will return a pointer to the DTrace scratch space of size
sizeof(uintptr_t) * 2. However, one can easily call printm() as follows
BEGIN { printm(10, (void *)NULL); }
and panic the kernel as a result. This commit does two things:
(1) adds a new macro DTRACE_INSCRATCHPTR(mstate, ptr, howmany) which
checks if a certain pointer is in the DTrace scratch space;
(2) uses DTRACE_INSCRATCHPTR() to implement a check on printm()'s DIFO
return value in order to avoid the panic and sets CPU_DTRACE_BADADDR
if the address is not in the scratch space.
sockets: re-check socket state after call to pr_rcvd()
Socket state may have changed after dropping the receive
buffer lock in order to call pr_rcvd(). If the buffer is
empty, re-check the state after reaquiring the lock and
skip calling sbwait() if the socket is in error or the
peer has closed.
ipfilter: Avoid allocating a new ipf token when not needed
Only allocate a new ipftoken_t if one cannot be found. This eliminates
allocating unnecessary token structures that will never be used when
performing simple lookups for existing token structures.
groff 1.23.0 changed the semantics of the -man parameter, and many
manual pages are not rendered. The -mandoc parameter brings back
the old behavior, as in groff 1.22.4 and earlier.
PR: 273565, 273245
Reviewed by: emaste, bapt
MFC after: 1 week for all supported branches (stable/12, 13, 14)
Differential Revision: https://reviews.freebsd.org/D41737
Newer versions of the AX88179 interweave dummies alongside valid
packet headers in bulk IN transfer data. This was probably done for
backward compatibility with existing drivers.
However current driver records these dummy headers as dropped frames,
leading to stats misreporting one Ierr per Ipkt.
This skips those dummy headers silently, thereby not generating Ierrs
for them.
Sebastian Huber [Tue, 19 Jul 2022 18:09:43 +0000 (20:09 +0200)]
buf.h: Fix declaration of unmapped_buf
For architectures with a small-data area, the __read_mostly section must
present at the object declaration.
(emaste note: This does not appear to have an affect within FreeBSD, but
may be needed by downstream projects that handle __read_mostly /
__section(".data.read_mostly") differently.)
If we hit the csfailed case in pf_create_state() we may have allocated
a state, so we must also free it. While here reduce the amount of
duplicated cleanup code.
Andrew Turner [Mon, 18 Sep 2023 16:34:51 +0000 (17:34 +0100)]
arm64: Fix errata workarounds that depend on smccc
Some arm64 errata depend on calling into the firmware via the SMCCC
interface. This needs to happen after the psci driver has attached
as they share the interface.
Fix this by allowing the workarounds to mark when they depend on
device drivers attaching.
This is only an issue on CPU 0 as the workarounds are applied later
for the non-boot CPUs.
Reviewed by: emaste
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D41916
Andrew Turner [Tue, 22 Aug 2023 10:51:26 +0000 (11:51 +0100)]
gicv3: Split out finding the page size
When adding indirect (2 level) tabled we will need to know the page
size to calculate the size of the level 1 table. To allow for this find
the page size before entering the loop to calculate the final register
value.
Andrew Turner [Thu, 6 Jul 2023 14:40:01 +0000 (15:40 +0100)]
arm64: Update the ID_AA64PFR1_EL1 fields
While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40896
Andrew Turner [Thu, 6 Jul 2023 14:02:35 +0000 (15:02 +0100)]
arm64: Update the ID_AA64PFR0_EL1 fields
While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40895
Andrew Turner [Thu, 6 Jul 2023 12:34:28 +0000 (13:34 +0100)]
arm64: Update the ID_AA64MMFR0_EL1 fields
While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40890
Andrew Turner [Thu, 6 Jul 2023 10:01:11 +0000 (11:01 +0100)]
arm64: Update the ID_AA64ISAR1_EL1 fields
While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40889
Andrew Turner [Thu, 6 Jul 2023 09:19:21 +0000 (10:19 +0100)]
arm64: Update the ID_AA64ISAR0_EL1 fields
While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40888
Andrew Turner [Mon, 13 Mar 2023 09:17:32 +0000 (09:17 +0000)]
arm64: Update the ID_AA64DFR0_EL1 fields
While here move to decimal for the _op and _CR definitions to be used
by a future macro to define the register when the assembler doesn't
know about it.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40887
Mark Johnston [Wed, 28 Jun 2023 20:13:37 +0000 (16:13 -0400)]
arm64: Make register definitions const
No functional change intended.
Reviewed by: andrew
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Sponsored by: Klara, Inc. (hardware)
Differential Revision: https://reviews.freebsd.org/D40502
Andrew Turner [Tue, 27 Jun 2023 08:32:12 +0000 (09:32 +0100)]
Continue searching for an irq map from the start
When searching for a free irq map location continue the search from the
beginning of the list. There may be holes in the map before
irq_map_first_free_idx, e.g. when removing an entries in order will
increase the index past the current free entry.
PR: 271990
Reviewed by: mhorne
Sponsored by: Arm Ltd
Andrew Turner [Fri, 9 Jun 2023 08:36:12 +0000 (09:36 +0100)]
Add more arm64 ID registers to the user_regs array
This is a mapping from ID register value to offset in struct cpu_desc.
These registers may be needed with future architecture revisions either
by userspace or by bhyve.
Andrew Turner [Tue, 23 May 2023 09:21:39 +0000 (10:21 +0100)]
Print registers on an arm64 spinlock data abort
When checking if the spinlock count is correct in a data abort we can
panic without printing the registers. These are useful to debug the
abort, e.g. by giving the fault address register.
Reviewed by: kib
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D40228
Andrew Turner [Thu, 4 May 2023 10:30:57 +0000 (11:30 +0100)]
Add more arm64 special registers
These will be used by bhyve
Reviewed by: markj
Sponsored by: Arm Ltd
Sponsored by: Innovate UK
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D40128
Andrew Turner [Fri, 31 Mar 2023 12:34:51 +0000 (13:34 +0100)]
Move arm64 EENTRY uses before ENTRY
The ENTRY macro adds instructions to the start of a function but not
EENTRY. To use these instructions in both functions move the EENTRY
use before the ENTRY use.
Andrew Turner [Fri, 31 Mar 2023 09:15:45 +0000 (10:15 +0100)]
Handle the arm64 unknown exception separately
Rather than falling through to the default case handle the unknown
exception with its own panic message. As ESR_EL1 is zero for this
exception stop printing it.
The removed text claimed that memcpy is implemented using bcopy and thus
strings may overlap. Use of bcopy is an implementation detail that is
no longer true, even if the implementation (on some archs) does allow
overlap.
In any case behaviour is undefined per the C standard if memcpy is
called with overlapping objects, and this man page already claimed that
src and dst may not overlap.
Reviewed by: kib
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D31192
Daniel Tameling [Sat, 1 Jul 2023 08:43:40 +0000 (10:43 +0200)]
rc.subr: don't require service to be enabled for `status`
For a service that sets an rcvar, there is a check whether it has been
enabled before the actual command is executed. If the check fails, one
gets a message to enable it and the returned exit status is 0.
However, this is usually undesirable for the status command, which is
a) supposed to check whether the service is running anyway and
b) returns a non-zero exit code if that is not the case.
Thus, skip the check for the status command.
Ed Maste [Wed, 30 Aug 2023 20:49:44 +0000 (16:49 -0400)]
Update WITH_/WITHOUT_SSP descriptions
ProPolice refers to a specific implementation by Hiroaki Etoh and
Kunikazu Yoda. The implementation in contemporary Clang and GCC is
somewhat different and newer, so use a generic term in the src.conf
descriptions.
When parsing a rule to rotate log files on a specific week day,
parseDWM() can advance the time to the next week. If the next week is
in the next month, then tm_mon is incremented. However, the increment
was failing to handle the wraparound from December to January, so when
parsing a rule during the last week of the December, the month would
advance to month 12. This triggered an out-of-bounds read of the
mtab[] array in days_pmonth() after parseDWM() returned. To fix,
this change resets the month to January and increment the year when
the month increment wraps.
The default rule for /var/log/weekly.log triggers this during the
last week of December each year.
Reported by: CHERI
Obtained from: CheriBSD
Reviewed by: jhb
Sponsored by: The University of Cambridge, Google Inc.
Differential Revision: <https://reviews.freebsd.org/D33687>
Bartosz Sobczak [Mon, 21 Aug 2023 11:28:58 +0000 (13:28 +0200)]
irdma(4): remove artificial completion generator
Removing artificial completion generator as there had been no indication
of the code being required for E810 cards. Further more it was found
that the code may have unpleasant side effects on user experience when
using ucmatose tool.
Bartosz Sobczak [Mon, 21 Aug 2023 11:56:57 +0000 (13:56 +0200)]
irdma(4): use related vnet for searching netdev
It was found through testing that when ULP uses individual vnet, the
search for the correct vlan_id may failing because of no proper
interface with given address.
The solution is to use vnet associated to the connection whenever
possible.
Notable changes:
- pf-reset handling improvements, including fixes in communication with if_ice(4)
- avoid racing when handling various events
- adding sw stats sysctls
- hand over pe_criterr handling from ice(4) to irdma(4)
- debug prints adjustments
- fix crash after changes in irdma_add_mqh_ifa_cb
Additional fixes in stable/13 but not in original cherry-picked commit:
- code appearance improvements
- bug fixes in fbsd_kcompat.c
- avoid waiting procedures under lock in irdma_add_mqh_ifa_cb
- busy wait for manage_qhash
- stats don't need to be RDTUN, RD is enough
Bartosz Sobczak [Tue, 28 Mar 2023 21:15:15 +0000 (14:15 -0700)]
irdma(4): Upgrade the driver to 1.1.11-k
Summary of changes:
- postpone mtu size assignment during load to avoid race condition
- refactor some of the debug prints
- add request reset handler
- refactor flush scheduler to increase efficiency and avoid racing
- put correct vlan_tag for UD traffic with PFC
- suspend QP before going to ERROR state to avoid CQP timout
- fix arithmetic error on irdma_debug_bugf
- allow debug flag to be settable during driver load
- introduce meaningful default values for DCQCN algorithm
- interrupt naming convention improvements
- skip unsignaled completions in poll_cmpl
Alan Somers [Tue, 12 Sep 2023 01:20:39 +0000 (19:20 -0600)]
Fix zfsd with the device_removal pool feature.
Previously zfsd would crash in the presence of a pool with a
top-level-vdev that had previously been removed. The crash happened
because the configuration nvlist of such a TLV contains an empty
ZPOOL_CONFIG_CHILDREN array, which led to a pop_front from an empty
list, which has undefined behavior.
The crash only happened in stable/14 and later, probably do to
differences in libcxx, but the change should be MFCed anyway.
Ed Maste [Sat, 16 Sep 2023 20:46:16 +0000 (21:46 +0100)]
freebsd-update: do not restart sshd when updating jail/basedir
In 6cd1bc531609 for PR 263489 I changed freebsd-update to restart sshd
after upgrade, to avoid an upgrade-related incompatibility that made it
impossible to login.
This is intended to avoid losing access to remote hosts, and ought not
apply to upgrading jails (from outside).
PR: 263489, 272282
Reported by: otis
Reviewed by: otis, kevans
MFC after: 3 days
Sponsored by: The FreeBSD Foundation Fixes: 6cd1bc531609 ("freebsd-update: restart sshd after upgrade")
Differential Revision: https://reviews.freebsd.org/D41890
Richard Yao [Tue, 10 Jan 2023 20:44:35 +0000 (15:44 -0500)]
Cleanup: Replace oldstyle struct hack with C99 flexible array members
The Linux 5.16.14 kernel's coccicheck caught this. The semantic
patch that caught it was:
./scripts/coccinelle/misc/flexible_array.cocci
However, unlike the cases where the GNU zero length array extension had
been used, coccicheck would not suggest patches for the older style
single member arrays. That was good because blindly changing them would
break size calculations in most cases.
Therefore, this required care to make sure that we did not break size
calculations. In the case of `indirect_split_t`, we use
`offsetof(indirect_split_t, is_child[is->is_children])` to calculate
size. This might be subtly wrong according to an old mailing list
thread:
That is because the C99 specification should consider the flexible array
members to start at the end of a structure, but compilers prefer to put
padding at the end. A suggestion was made to allow compilers to allocate
padding after the VLA like compilers already did:
However, upon thinking about it, whether or not we allocate end of
structure padding does not matter, so using offsetof() to calculate the
size of the structure is fine, so long as we do not mix it with sizeof()
on structures with no array members.
In the case that we mix them and padding causes offsetof(struct_t,
vla_member[0]) to differ from sizeof(struct_t), we would be doing unsafe
operations if we underallocate via `offsetof()` and then overcopy via
sizeof().
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14372
Yuri Pankov [Tue, 28 Mar 2023 15:10:47 +0000 (17:10 +0200)]
libc: use separate collate objects for C, POSIX, and C.UTF-8
Fix newlocale() overwriting the locale name in collate object
when same instance was used for those locales, and querylocale()
reporting unexpected value for LC_COLLATE_MASK.