kern: rename crsetgroups_fallback, document it in ucred(9)
As of FreeBSD 15.0, crsetgroups() *only* sets supplementary groups,
while crsetgroups_and_egid() will do both using an array of the same
style that previous versions used for crsetgroups() -- i.e., the first
element is the egid, and the remainder are supplementary groups.
Unlike the previous iteration of crsetgroups(), crsetgroups_and_egid()
is less prone to misuse as the caller must provide a default egid to use
in case the array is empty. This is particularly useful for groups
being set from data provided by userland.
Reviewed by: olce
Suggested by: olce
Differential Revision: https://reviews.freebsd.org/D51647
kern: add a new ucred flag for groups having been set
Now that we can legitimately have ngroups == 0 as a result of calling
crsetgroups(), set a flag when we've set groups for the sake of sanity
checking usage of crextend(). While it's true this flag will only
really be used under INVARIANTS, it's only the second flag bit that
we're adding in 16 years.
Reviewed by: olce
Differential Revision: https://reviews.freebsd.org/D51646
libsa: errors with pointer conversion
loader ip implementation is using pointer to structure ip to receive
the packet and is using this pointer to cast on other data types
(namely structure arphdr). Problem does arise when those data structures
are declared with different alignment rules and when/if the compiler
does check those rules. To work around and silence warnings, use
void * generic pointer instead.
Error seen with gcc 14 (-Werror=address-of-packed-member).
Reviewed by: imp
Differential Revision: https://reviews.freebsd.org/D51662
release: No newaliases when cross-building VMs
We've been running newaliases(8) when cross-building VMs for a long
time, and it's not entirely clear why -- especially since we don't
do it when we're building a native VM image.
If someone knows why running newaliases is important we can add it
back later, but only after newaliases gets unbroken: As of last week
(a3d4ae7cf351) newaliases fails with EPERM on /etc/dma/dma.conf.
This should unbreak VM (and cloudware) cross-builds.
With hat: re@
LinuxKPI: pci: fix argument type to linuxkpi_pci_iomap[_range]
The last argument (maxlen) to linuxkpi_pci_iomap_range and
linuxkpi_pci_iomap is an unsigned long not an int. LinuxKPI is
not using that argument in the end but fix it where needed.
While here adjust the name to 'maxlen' and remove the "mmio_" to
bar and off.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D51651
dwmmc: cleanup cmd and locking, consistency between mmc and mmccam
In general sprinkle locking assertions and harmonized KASSERTs
throughout the upper part of the driver to document expectations.
In dwmmc_cmd_done() "cmd" should be set correctly and be used for
both MMCCAM and classic mmc rather than special-casing mmccam.
In dwmmc_next_operation() place variable declarations on the top
for both cases before the first debug and lock assertion calls;
then factor out common parts at the end and put both cases in the
same order.
By calling dwmmc_next_operation() directly from both dwmmc_request()
in the mmc case, and dwmmc_cam_request() in the mmccase (rather than)
chaining calls in the latter, we avoid unlocking the sc in the mmccam
case and have a consistent call path from both; also removing the
mmccam #ifdef from dwmmc_request() brings more clarity.
In dwmmc_next_operation() enhance the panic/error messages with
some extra information and assert that we come in with a cam pinfo
on CAM_ACTIVE_INDEX.
[4 lines not shown]
bsnmp: wlan: use correct value for rssi
net80211 keeps the rssi value in 0.5bm relative to the noise floor
(see comment in ieee80211_node.h). Do proper maths to get a plain
rssi value back (once further fixes are in net80211).
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D50930
LinuxKPI: pci: use unsigned int for vendor/device arguments
Linux drivers may pass a typed PCI_ANY_ID (-1U) in which then leads
to a warning that the value gets truncated. Switch argument types
to unsigned int (or uint32_t as we use in struct pci_device_id) to
avoid the problem.
Sponsored by: The FreeBSD Foundation
Discussed in: D50008
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D51652
LinuxKPI: pci: harmonize #defines
In some blocks of #defines spacing, trailing \ and indentation of a
second line differed. Some of them are currently fine on a single
line but future additions may not fit in that scheme.
Harmonize them into a #define X\t\t\t...\\n<4 spaces>Y scheme.
No functional changes.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D51650
LinuxKPI: acpi: fix guid_t argument type
acpi_check_dsm() and acpi_evaluate_dsm_typed() take a guid_t argument
and not a char *. For in-tree Linux based drivers this leads to a
compile error due to a warning. Fix the function argument type and
cast internally.
While this made the long statements in the wrapper functions for *_dsm_*
even less readable split them up using a local variable.
Sponsored by: The FreeBSD Foundation
MFC after: 3 days
Reviewed by: emaste
Differential Revision: https://reviews.freebsd.org/D51649
aio: Fix a race in sys_aio_cancel()
sys_aio_cancel() loops over pending jobs for the process, cancelling
some of them. To cancel a job with a cancel callback, it must drop the
job list mutex. It uses flags, KAIOCB_CANCELLING and KAIOCB_CANCELLED,
to make sure that a job isn't double-cancelled. However, when iterating
over the list it uses TAILQ_FOREACH_SAFE and thus assumes that the next
job isn't going to be removed while the lock is dropped. Of course,
this assumption is false.
We could simply start search from the beginning after cancelling a job,
but that might be quite expensive. Instead, introduce the notion of a
marker job, used to keep track of one's position in the queue. Use it
in sys_aio_cancel() to resume iteration after a job is cancelled.
Reported by: syzkaller
Reviewed by: kib, jhb
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D51626
dbm_nextkey: Always return an error if we've reached the end of the database
POSIX.1 states that `dbm_nextkey` must return an invalid key
(i.e., `key.dptr == NULL`) after the end of the database was reached.
The current implementation of `hash_seq` will incorrectly restart
the key sequence after the end of the database is reached.
Fix this by checking the "current bucket" index when R_NEXT is passed.
Sponsored by: Klara, Inc.
Differential Revision: https://reviews.freebsd.org/D51635
Reviewed by: markj
tcp hpts: cleanup header file
Cleanup tcp_hpts.h by
* move definition used only in tcp_hpts.c to that file
* fix a typo
* remove duplicate declarion of tcp_min_hptsi_time
* rearange declarations for simpler reading
Approved by: tuexen
MFC after: 1 week
Sponsored by: Netflix, Inc.
tcp: improve variable and constant names
Don't use ticks in variable names or constant when they don't have
a relation to ticks. Use slots or usecs.
No functional change intended.
Reviewed by: tuexen
MFC after: 1 week
Sponsored by: Netflix, Inc.
tcp: improve function names
tcp_tv_to_usectick(), tcp_tv_to_mssectick(), and tcp_tv_to_lusectick()
are not related to ticks. Therefore remove the trailing 'tick'.
No functional change intended.
Reviewed by: tuexen
MFC after: 1 week
Sponsored by: Netflix, Inc.
style.9: Fix "parantheses" typos in the new C++ section
PR: 288564
Fixes: 4b02ad9d5063 ("style.9: Add a C++ section")
Sponsored by: The FreeBSD Foundation (commit)
netlink: Fully clear parser state between messages
Failing to reset the cookie between messages can lead to an attempt
to interpret a zeroed buffer as a struct nlattr, causing a length
calculation to underflow, resulting in a memcpy() call where the
length exceeds the actual size of the buffer.
MFC after: 1 week
PR: 283797
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D51634
clang-scan-deps: Pass ${TDFILE} to tblgen, not ${.ALLSRC}
${.ALLSRC} can include the dependency OptParser.td, which causes
llvm-tblgen to fail since it only accepts a single input argument.
Use ${TDFILE} directly instead, which matches the other invocations
of tblgen in the LLVM Makefiles.
Fixes: d3c06bed2c16 ("clang: install clang-scan-deps")
MFC after: 3 days
Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D51569
(cherry picked from commit ad023bc26e106e28e1b4845f991b52b533bd0802)
param.h: bump __FreeBSD_version for be1f7435ef218b
I meant to review the diff again to make sure that __FreeBSD_version had
not progressed in the interim, but failed to do so- belatedly bump it
for a struct ucred ABI change.
Fixes: be1f7435ef21 ("kern: start tracking cr_gid outside of [...]")