Page MenuHomeFreeBSD

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

Authored by markj on Wed, Mar 5, 10:59 AM.
Tags
None
Referenced Files
F112553101: D49243.diff
Wed, Mar 19, 6:33 PM
Unknown Object (File)
Mon, Mar 10, 3:22 AM
Unknown Object (File)
Fri, Mar 7, 8:11 PM
Unknown Object (File)
Fri, Mar 7, 2:22 PM
Unknown Object (File)
Fri, Mar 7, 10:44 AM
Unknown Object (File)
Fri, Mar 7, 6:00 AM
Unknown Object (File)
Thu, Mar 6, 5:38 AM
Unknown Object (File)
Thu, Mar 6, 3:05 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 Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision was not accepted when it landed; it landed in state Needs Review.Mon, Mar 10, 3:05 AM
This revision was automatically updated to reflect the committed changes.