Page MenuHomeFreeBSD

libdtrace: Fix an off-by-one in CPU ID handling
ClosedPublic

Authored by markj on Mar 5 2025, 10:59 AM.
Tags
None
Referenced Files
F122028840: D49243.id151911.diff
Tue, Jul 1, 2:21 PM
F122008154: D49243.id.diff
Tue, Jul 1, 10:09 AM
Unknown Object (File)
Mon, Jun 30, 2:46 PM
Unknown Object (File)
Sun, Jun 29, 6:54 PM
Unknown Object (File)
Sun, Jun 29, 7:16 AM
Unknown Object (File)
Wed, Jun 25, 9:39 AM
Unknown Object (File)
Mon, Jun 23, 2:53 PM
Unknown Object (File)
Sun, Jun 15, 11:59 PM
Subscribers

Details

Summary

The illumos-specific _SC_CPUID_MAX is the largest CPU ID in the system. This
was mapped to _SC_NPROCESSORS_CONF, which is the total number of CPUs recognized
by the kernel. If CPU IDs are contiguous, as is the case on amd64 and arm64,
this value is one greater than the maximum ID. As a result, when consuming
per-CPU dtrace buffers, libdtrace tries to fetch from a non-existent CPU. This
is mostly harmless in practice, but still wrong.

As we don't have a sysconf value for the maximum CPU ID, add a wrapper which
fetches it using the kern.smp.maxid sysctl.

Sponsored by: Innovate UK

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable