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
Unknown Object (File)
Sat, Oct 25, 12:56 AM
Unknown Object (File)
Thu, Oct 16, 7:09 AM
Unknown Object (File)
Wed, Oct 15, 10:35 PM
Unknown Object (File)
Mon, Oct 13, 9:56 AM
Unknown Object (File)
Mon, Oct 13, 8:17 AM
Unknown Object (File)
Mon, Oct 13, 8:17 AM
Unknown Object (File)
Mon, Oct 13, 5:01 AM
Unknown Object (File)
Mon, Oct 13, 4:25 AM
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 Skipped
Unit
Tests Skipped
Build Status
Buildable 62769
Build 59653: arc lint + arc unit