dtrace: conditionally load the systrace_linux klds when loading dtrace.

When dtrace starts, it tries to detect if the dtrace klds are loaded,
and if not, it loads them by loading the dtraceall kld. This module
depends on most dtrace modules, including systrace for the native
freebsd and freebsd32 ABIs. However, it does not depend on the
systrace_linux klds, as they in turn depend on the linux ABI klds, and
we don't want to load an ABI module that the user has not explicitly
requested. This can leave a naive user in a state where they think all
syscall providers have been loaded, yet linux ABI syscalls are
"invisible" to dtrace.

To fix this, check to see if the linux ABI modules are loaded. If they
are, then load their systrace klds.

Reviewed by: markj, (emaste & jhb, earlier versions)
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D37986
This commit is contained in:
Andrew Gallatin 2023-01-23 20:27:17 -05:00
parent 9c996882b0
commit da81cc6035

View File

@ -1115,6 +1115,15 @@ dt_vopen(int version, int flags, int *errp,
*/
if (err == ENOENT && modfind("dtraceall") < 0) {
kldload("dtraceall"); /* ignore the error */
#if __SIZEOF_LONG__ == 8
if (modfind("linux64elf") >= 0)
kldload("systrace_linux");
if (modfind("linuxelf") >= 0)
kldload("systrace_linux32");
#else
if (modfind("linuxelf") >= 0) {
kldload("systrace_linux");
#endif
dtfd = open("/dev/dtrace/dtrace", O_RDWR | O_CLOEXEC);
err = errno;
}