stdio: Fix error case for positional %wN / %wfN
In the case were N was not a valid bit width, we were taking the wrong
error path.
Fixes: 5e809bf1c93f ("stdio: Fix positional %wN / %wfN conversion")
(cherry picked from commit 0bf5d86620d047b4551d7414bf8011a328264b3d)
stdio: Fix positional %F conversion
When a format uses positional arguments, __find_arguments() walks it
first to learn the type of every argument, and lists the floating
point conversions as A a E e f G g. F is missing, so a double that
is only referred to through %F never gets a type, its slot in the
argument table stays unset, and the conversion reads whatever is
there:
printf("[%1$F]\n", -INFINITY); [0.000000]
printf("[%1$F]\n", 1.5); [0.000000]
printf("[%F]\n", 1.5); [1.500000]
With a width taken from another argument, "%1$*2$F", vsnprintf(3)
returned lengths like 2103024 for a ten character result; abseil's
str_format test allocates that much and was killed for it on
FreeBSD. The same format with %1$f, or with any other conversion of
the same argument, works because those give it a type.
[9 lines not shown]
clang: Fix warnings in ARM GCS ACLE header
Including <arm_acle.h> in C code compiled with -Wstrict-prototypes
results in warnings (or errors if -Werror is in effect) due to missing
parameter lists for __gcspr() and __gcspopm().
Submitted upstream as PR#242286.
MFC after: 1 week
Reported by: Pete French <pete at twisted.org.uk>
Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D61503
(cherry picked from commit 74d72b3491e810068313e49629c3b8fe46f29318)
libgeom: Open the control device read-write
Try to open the control device read-write first, and fall back to
read-only if that fails and the error is EACCES. This prepares us for a
future in which GEOM requires write access to execute verbs that modify
the configuration.
MFC after: 1 week
Event: EuroBSDCon 2026 DevSummit
Reviewed by: imp, markj, emaste
Differential Revision: https://reviews.freebsd.org/D59592
(cherry picked from commit 1e9e198b7f064322687746d26b283c3fcbad4579)
geom: Check file flags before handling control request
Pass fflag down to g_ctl_req() and:
* Refuse all requests unless fflag has the FREAD bit set
* Refuse all but getxml unless fflag also has the FWRITE bit set
This should allow us to restore read access to /dev/geom.ctl for group
operator; they will then be able to run `gpart list` or `gpart backup`
but not commands that actually modify the table.
For backward compatibility, we set the FWRITE bit if it is not already
set and the calling thread has the PRIV_GEOM privilege, which is
automatically granted to a jailed or unjailed superuser. This should
cover the case of older binaries (which open /dev/geom.ctl read-only)
running as root on a newer kernel. Since we intend to merge this to
stable/15, the compatibility code is conditional on COMPAT_FREEBSD14.
[6 lines not shown]
stdio: Fix error case for positional %wN / %wfN
In the case were N was not a valid bit width, we were taking the wrong
error path.
Fixes: 5e809bf1c93f ("stdio: Fix positional %wN / %wfN conversion")
(cherry picked from commit 0bf5d86620d047b4551d7414bf8011a328264b3d)
clang: Fix warnings in ARM GCS ACLE header
Including <arm_acle.h> in C code compiled with -Wstrict-prototypes
results in warnings (or errors if -Werror is in effect) due to missing
parameter lists for __gcspr() and __gcspopm().
Submitted upstream as PR#242286.
MFC after: 1 week
Reported by: Pete French <pete at twisted.org.uk>
Reviewed by: dim
Differential Revision: https://reviews.freebsd.org/D61503
(cherry picked from commit 74d72b3491e810068313e49629c3b8fe46f29318)
stdio: Fix positional %F conversion
When a format uses positional arguments, __find_arguments() walks it
first to learn the type of every argument, and lists the floating
point conversions as A a E e f G g. F is missing, so a double that
is only referred to through %F never gets a type, its slot in the
argument table stays unset, and the conversion reads whatever is
there:
printf("[%1$F]\n", -INFINITY); [0.000000]
printf("[%1$F]\n", 1.5); [0.000000]
printf("[%F]\n", 1.5); [1.500000]
With a width taken from another argument, "%1$*2$F", vsnprintf(3)
returned lengths like 2103024 for a ten character result; abseil's
str_format test allocates that much and was killed for it on
FreeBSD. The same format with %1$f, or with any other conversion of
the same argument, works because those give it a type.
[9 lines not shown]
swapoff: don't leak vnode pointer to device
After looking up the device path, we compare the vnode to the vnode of
each swap device. Prior to this change we leaked a vnode reference to
the device we're trying to remove from the swap pool.
Effort: CHERI upstreaming
Reviewed by: kib, markj
Reported by: llm-postcr
MFC after: 3 days
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D61464
(cherry picked from commit 9506d8e0b1788068cbd4c2cbc984cb6ee0dcb0ab)
swapoff: release vnode held since swapon
kern_swapon looks up the proposed swap path and aquires a vnode which is
held (unlocked) throughout the life of the swap device. In the device
case (swapgeom) it was never released in the swapoff path.
Remove an incorrect comment about swapgeom_close being called from
biodone. It is only called directly via swapoff(2) or at the end of the
shutdown path.
Reviewed by: kib, markj
Reported by: llm-postcr
MFC after: 3 days
Sponsored by: Innovate UK
Differential Revision: https://reviews.freebsd.org/D61465
(cherry picked from commit 933f5f616a8a44b7af6cdccecf959ef1e8bab66e)
routing: Sort the nexthops of a group by metric
Sort the nexthops of a group by metric first and by index second,
and keep the metric of each nexthop in the unused storage field.
The nexthops with the lowest metric are the first ones in the array.
The group is sized and compiled from them without visiting every
nexthop for its metric, and the metric argument of these functions
goes away.
decompose_change_notification() walks two groups in their sort
order, so make it use the same comparison.
Reviewed by: glebius
Differential Revision: https://reviews.freebsd.org/D61637
routing: Fix the size of nexthop groups with mixed metrics
calc_min_mpath_slots_fast() selects the nexthops with the lowest
metric through wn[i].nh, but reads their weights from wn[i].storage,
a copy of the weights that is sorted independently of the nexthops.
In a group with more than one metric the weights of the wrong
nexthops are summed, and the weights of all nexthops take part in
the divisibility check, so the group gets a wrong number of slots
and a wrong traffic split.
Calculate the number of slots as the sum of the weights divided by
their greatest common divisor instead. It needs no sorted copy of
the weights and is exact where the old code gave up and used
RIB_MAX_MPATH_WIDTH slots.
The storage field is part of the bytes that identify a group. It is
no longer written by the calculation, so set it to zero.
Reviewed by: glebius
[2 lines not shown]
kobj: convert KOBJOPLOOKUP() to returning pointer to function
This makes KOBJOPLOOKUP() rather more suitable for purposes outside the
macros generated by makeobjops.awk. Of note other callers can lookup
the function on their parent class and call that explicitly.
Reviewed by: zlei
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D48408
snd_dummy: Do not use dummy_chan_io() as mpu401's interrupt handler
dummy_chan_io() runs with sc->lock held, but mpu401 calls its handler
from a callout with no mutex associated with it, so writing to the MIDI
device node caused a panic.
Give mpu401 its own handler, and leave MIDI to mpu401's timer instead of
the PCM callout.
Fixes: e963472ef853 ("snd_dummy: Initial MIDI support")
Sponsored by: The FreeBSD Foundation
(cherry picked from commit c8d1c94741231d95964b91910880769019478854)
snd_uaudio: Fix the MIDI TX round-robin
Nothing advances curr_cable, so umidi_bulk_write_callback() only
services cable 0, which is a problem on MIDI devices with more than one
jack.
Fixes: 039477d3e7e7 ("snd_uaudio: Simplify chan->curr_cable calculation in uaudio_bulk_write_callback()")
Sponsored by: The FreeBSD Foundation
MFC after: 1 day
(cherry picked from commit f58613868b50dfd6c2adc7128ea60d7b276fdbf1)
snd_uaudio: Do not touch mixer_lock when there is no mixer
Using the mixer lock unconditionally panics because the lock is
uninitialized on devices with no audio interfaces, for instance
MIDI-only keyboards.
Fixes: 9a00e0b8ca56 ("snd_uaudio: Do not use snd_mixer->lock as mixer_lock")
MFC after: 3 days
Sponsored by: The FreeBSD Foundation
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D61506
(cherry picked from commit dabd959b17597ad790327020a667ced9a05d7499)
sound: Remove stale midi module dependencies
midi(4) stopped being a module in 45bb10e0ed5a ("sound: Stop building
midi as a module"), so snd_cmi(4) and snd_emu10k1(4) fail to load
because they still depend on it.
Fixes: 45bb10e0ed5a ("sound: Stop building midi as a module")
Sponsored by: The FreeBSD Foundation
MFC after: 1 day
(cherry picked from commit 563c2f27e0ffec96a0ddd77b68c7ca6614d704af)
fbt/powerpc: don't instrument the trap entry path
On powerpc an fbt probe is a program interrupt that goes through the
normal trap path, powerpc_interrupt() -> trap() -> dtrace_trap(). A
probe on trap() or powerpc_interrupt() fires again on the way to its
own handler, so it recurses until the kernel stack runs out, and
enabling fbt::trap:entry panics the machine right away.
Skip both functions, like aarch64 and riscv skip their exception
handlers.
Reviewed by: jhibbits
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D61660