Bug 234350 - [dtrace] Dtrace cannot print string arguments to system calls.
Summary: [dtrace] Dtrace cannot print string arguments to system calls.
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 12.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Mark Johnston
: 234352 (view as bug list)
Depends on:
Reported: 2018-12-24 12:30 UTC by shamaz.mazum
Modified: 2019-02-05 19:07 UTC (History)
0 users

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description shamaz.mazum 2018-12-24 12:30:40 UTC
I try to execute Dtrace like so:

dtrace -n 'syscall::open*:entry { printf("%s %s", execname, copyinstr(arg0)); }'

and get some strange errors:

dtrace: error on enabled probe ID 2 (ID 76423: syscall:freebsd:open:entry): invalid address (0x8002543a3) in action #2 at DIF offset 12

like when stringof() were used instead of copyinstr().

FreeBSD version 12.0-RELEASE.
Comment 1 Mark Johnston freebsd_committer 2018-12-24 16:19:43 UTC
*** Bug 234352 has been marked as a duplicate of this bug. ***
Comment 2 Mark Johnston freebsd_committer 2018-12-24 16:21:11 UTC
This might be a known regression fixed in r342053.  Can you paste the first 20
lines of your dmesg here?
Comment 3 shamaz.mazum 2018-12-24 16:43:02 UTC
(In reply to Mark Johnston from comment #2)

This is output of dmesg. By the way, sorry for sending PR twice, I had networking problem.

Copyright (c) 1992-2018 The FreeBSD Project.
Copyright (c) 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
        The Regents of the University of California. All rights reserved.
FreeBSD is a registered trademark of The FreeBSD Foundation.
FreeBSD 12.0-RELEASE 952c9691f1b(release/12.0.0) MYKERNEL120 amd64
FreeBSD clang version 6.0.1 (tags/RELEASE_601/final 335540) (based on LLVM 6.0.1)
VT(vga): resolution 640x480
CPU: AMD Ryzen 5 1600X Six-Core Processor            (3593.34-MHz K8-class CPU)
  Origin="AuthenticAMD"  Id=0x800f11  Family=0x17  Model=0x1  Stepping=1
  AMD Features=0x2e500800<SYSCALL,NX,MMX+,FFXSR,Page1GB,RDTSCP,LM>
  Structured Extended Features=0x209c01a9<FSGSBASE,BMI1,AVX2,SMEP,BMI2,RDSEED,ADX,SMAP,CLFLUSHOPT,SHA>
  AMD Extended Feature Extensions ID EBX=0x7<CLZERO,IRPerf,XSaveErPtr>
  SVM: NP,NRIP,VClean,AFlush,DAssist,NAsids=32768
  TSC: P-state invariant, performance statistics
real memory  = 17179869184 (16384 MB)
avail memory = 16557715456 (15790 MB)
Comment 4 Mark Johnston freebsd_committer 2018-12-24 16:50:12 UTC
Your processor implements SMAP, so it is indeed affected.  You can try applying this patch to your kernel to fix the problem: https://svnweb.freebsd.org/changeset/base/342267

I believe we will also release an errata notice and patch for 12.0, so you'll be able to use freebsd-update to fix the problem.
Comment 5 shamaz.mazum 2018-12-24 16:56:30 UTC
Thank you very much!
Comment 6 shamaz.mazum 2018-12-24 17:41:44 UTC
(In reply to Mark Johnston from comment #4)
Update: the suggested patch seems to be working only partially. I can see strings passed from userspace, but there are also many errors like so:

dtrace: error on enabled probe ID 1 (ID 77393: syscall:freebsd:openat:entry): invalid address (0xffffffffffffff9c) in action #2 at DIF offset 12

Seems like kernel space address, is it not? Also, it is always the same address (0xffffffffffffff9c).
Comment 7 Mark Johnston freebsd_committer 2018-12-24 17:43:46 UTC
(In reply to shamaz.mazum from comment #6)
Yes, that is expected.  Note that the new errors are coming from syscall::openat:entry rather than syscall::open:entry.  The first argument to openat(2) is a file descriptor, not a string.
Comment 8 shamaz.mazum 2018-12-24 18:39:27 UTC
(In reply to Mark Johnston from comment #7)

Oh, my bad. Thanks
Comment 9 Mark Johnston freebsd_committer 2019-02-05 19:07:20 UTC
The issue is fixed in 12.0-p3.