NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/58630: dtrace is "hit or miss", but mostly "miss"



The following reply was made to PR bin/58630; it has been noted by GNATS.

From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: bin/58630: dtrace is "hit or miss", but mostly "miss"
Date: Sat, 24 Aug 2024 05:33:58 +0000 (UTC)

 On Fri, 23 Aug 2024, he%NetBSD.org@localhost wrote:
 
 > 	What's even more strange is that this error is not
 > 	consistently observed among my different systems:
 >
 
 ```
 $ env DTRACE_DEBUG=1 dtrace -s ./probes.d -h -o probes.h
 libdtrace DEBUG: failed to open /dev/ksyms: Permission denied
 [...]
 dtrace: failed to compile script ./probes.d: "/usr/lib/dtrace/psinfo.d", line 46: syntax error near "u_int"
 
 $ ls -l /dev/ksyms
 cr--r-----  1 root  kmem  85, 0 Jan 31  2024 /dev/ksyms
 
 $ sudo chmod o+r /dev/ksyms
 
 $ dtrace -s ./probes.d -h -o probes.h && echo OK
 OK
 
 $
 ```
 
 Is /dev/ksyms world-readable on the other systems, or is dtrace setuid there?
 
 I wonder if something like this would do instead of reading from /dev/ksyms?
 
 ```
 diff -urN a/src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c b/src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c
 --- a/src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c	2024-04-02 02:28:51.360422339 +0000
 +++ b/src/external/cddl/osnet/dist/lib/libdtrace/common/dt_module.c	2024-08-24 05:23:22.497654556 +0000
 @@ -1186,7 +1186,14 @@
   	bool ismod;
 
   	if (strcmp("netbsd", name) == 0) {
 -		strlcpy(fname, _PATH_KSYMS, sizeof fname);
 +		char tmp[MAXPATHLEN];
 +		len = sizeof(tmp);
 +#if defined(__i386__) || defined(__x86_64__)
 +		if (sysctlbyname("machdep.booted_kernel", tmp, &len, NULL, 0) == 0) 
 +			snprintf(fname, sizeof fname, "%s%s", tmp[0] == '/' ? "" : "/", tmp);
 +		else
 +#endif
 +			strlcpy(fname, _PATH_KSYMS, sizeof fname);
   		ismod = false;
   	} else {
 
 ```
 
 -RVP
 


Home | Main Index | Thread Index | Old Index