Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Feb 2022 14:03:54 +0000
From:      Amit kumar <akamit91@hotmail.com>
To:        "markj@FreeBSD.org" <markj@FreeBSD.org>
Cc:        "freebsd-dtrace@FreeBSD.org" <freebsd-dtrace@FreeBSD.org>
Subject:   Re: dtrace fails to trace on FreeBSD-14(CURRENT) with ASLR and W^X
Message-ID:  <SJ0PR18MB4932A03F77D5D999AEAE83C4DC339@SJ0PR18MB4932.namprd18.prod.outlook.com>
In-Reply-To: <Ygpe285ALGK1d5lm@nuc>
References:  <SJ0PR18MB49326C3D1DF915EB841CC2D8DC339@SJ0PR18MB4932.namprd18.prod.outlook.com> <Ygpe285ALGK1d5lm@nuc>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
>Does the problem persist with allow_wx = 1?
No In that case there would be no core dump, but the script would time out after 300 seconds.
Doing some manual experiments
It seems it fails to set the watchpoint or the probes wont fire

# sysctl kern.elf64.allow_wx=1
kern.elf64.allow_wx: 0 -> 1
# sysctl kern.elf64.aslr.enable=1
kern.elf64.aslr.enable: 1 -> 1
# sysctl kern.elf64.aslr.pie_enable=1
kern.elf64.aslr.pie_enable: 1 -> 1
# exec find / > /dev/null 2>&1 &
[1] 27041
akumar3-79afpc2-1# dtrace -n pid27041:a.out::
dtrace: description 'pid27041:a.out::' matched 6828 probes

CTRL+C

-Amit
________________________________
From: Mark Johnston <markjdb@gmail.com> on behalf of markj@FreeBSD.org <markj@freebsd.org>
Sent: Monday, February 14, 2022 7:23 PM
To: Amit kumar <akamit91@hotmail.com>
Cc: freebsd-dtrace@FreeBSD.org <freebsd-dtrace@freebsd.org>
Subject: Re: dtrace fails to trace on FreeBSD-14(CURRENT) with ASLR and W^X

On Mon, Feb 14, 2022 at 11:03:47AM +0000, Amit kumar wrote:
> Encountered this issue while running https://github.com/freebsd/freebsd-src/blob/main/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.emptystack.d
>
> a somewhat simpler method to reproduce
>
> configuration
> file /usr/bin/find
> /usr/bin/find: ELF 64-bit LSB shared object, x86-64, <.....>
>
> kern.elf64.allow_wx: 0
> kern.elf64.aslr.pie_enable: 1
> kern.elf64.aslr.enable: 1

Does the problem persist with allow_wx = 1?

> # dtrace -n pid92817:::entry
> dtrace: description 'pid92817:::entry' matched 4380 probes
> [2]  + trace trap (core dumped)  exec find / > /dev/null 2>&1
>
> # exec find / > /dev/null 2>&1 &
> [1] 85293
> # dtrace -n pid85293:a.out::
> dtrace: description 'pid85293:a.out::' matched 6828 probes
> [1] + trace trap (core dumped) exec find / > /dev/null 2>&1
> CPU ID FUNCTION:NAME
> 1 89149 find_execute:1f8
>
> looking at find core in gdb
> (gdb) p $_siginfo
> $1 = {
>   si_signo = 5,
>   si_errno = 0,
>   si_code = 3,
>   .
>   .
>   .
>
> Can someone help me understand why am I seeing core due to SIGTRAP TRAP_DTRACE ?
>
> Regards
> Amit

[-- Attachment #2 --]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:&quot;Segoe UI&quot;, &quot;Segoe UI Web (West European)&quot;, -apple-system, BlinkMacSystemFont, Roboto, &quot;Helvetica Neue&quot;, sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">&gt;Does the problem persist with allow_wx
 = 1?</span><br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:&quot;Segoe UI&quot;, &quot;Segoe UI Web (West European)&quot;, -apple-system, BlinkMacSystemFont, Roboto, &quot;Helvetica Neue&quot;, sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">No In that case there would be no
 core dump, but the script would time out after 300 seconds.</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="font-family:&quot;Segoe UI&quot;, &quot;Segoe UI Web (West European)&quot;, -apple-system, BlinkMacSystemFont, Roboto, &quot;Helvetica Neue&quot;, sans-serif;font-size:14.6667px;background-color:rgb(255, 255, 255);display:inline !important">Doing some manual experiments</span></div>
<div style="color: rgb(0, 0, 0);"><span style="font-size: 14.6667px;">It seems it fails to set the watchpoint or the probes wont fire</span></div>
<div style="color: rgb(0, 0, 0);"><span style="font-size: 14.6667px;"><br>
</span></div>
<div style="color: rgb(0, 0, 0);"><span style="font-size: 14.6667px;"># sysctl kern.elf64.allow_wx=1
<div>kern.elf64.allow_wx: 0 -&gt; 1</div>
<div># sysctl kern.elf64.aslr.enable=1</div>
<div>kern.elf64.aslr.enable: 1 -&gt; 1</div>
<div># sysctl kern.elf64.aslr.pie_enable=1</div>
<div>kern.elf64.aslr.pie_enable: 1 -&gt; 1</div>
<div># exec find / &gt; /dev/null 2&gt;&amp;1 &amp;</div>
<div>[1] 27041</div>
<div>akumar3-79afpc2-1# dtrace -n pid27041:a.out::</div>
dtrace: description 'pid27041:a.out::' matched 6828 probes</span></div>
<div style="color: rgb(0, 0, 0);"><span style="font-size: 14.6667px;"><br>
</span></div>
<div style="color: rgb(0, 0, 0);"><span style="font-size: 14.6667px;">CTRL+C&nbsp;</span></div>
<div style="color: rgb(0, 0, 0);"><span style="font-size: 14.6667px;"><br>
</span></div>
<div style="color: rgb(0, 0, 0);"><span style="font-size: 14.6667px;">-Amit</span></div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Mark Johnston &lt;markjdb@gmail.com&gt; on behalf of markj@FreeBSD.org &lt;markj@freebsd.org&gt;<br>
<b>Sent:</b> Monday, February 14, 2022 7:23 PM<br>
<b>To:</b> Amit kumar &lt;akamit91@hotmail.com&gt;<br>
<b>Cc:</b> freebsd-dtrace@FreeBSD.org &lt;freebsd-dtrace@freebsd.org&gt;<br>
<b>Subject:</b> Re: dtrace fails to trace on FreeBSD-14(CURRENT) with ASLR and W^X</font>
<div>&nbsp;</div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">On Mon, Feb 14, 2022 at 11:03:47AM +0000, Amit kumar wrote:<br>
&gt; Encountered this issue while running <a href="https://github.com/freebsd/freebsd-src/blob/main/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.emptystack.d">;
https://github.com/freebsd/freebsd-src/blob/main/cddl/contrib/opensolaris/cmd/dtrace/test/tst/common/pid/tst.emptystack.d</a><br>;
&gt; <br>
&gt; a somewhat simpler method to reproduce<br>
&gt; <br>
&gt; configuration<br>
&gt; file /usr/bin/find<br>
&gt; /usr/bin/find: ELF 64-bit LSB shared object, x86-64, &lt;.....&gt;<br>
&gt; <br>
&gt; kern.elf64.allow_wx: 0<br>
&gt; kern.elf64.aslr.pie_enable: 1<br>
&gt; kern.elf64.aslr.enable: 1<br>
<br>
Does the problem persist with allow_wx = 1?<br>
<br>
&gt; # dtrace -n pid92817:::entry<br>
&gt; dtrace: description 'pid92817:::entry' matched 4380 probes<br>
&gt; [2]&nbsp; + trace trap (core dumped)&nbsp; exec find / &gt; /dev/null 2&gt;&amp;1<br>
&gt; <br>
&gt; # exec find / &gt; /dev/null 2&gt;&amp;1 &amp;<br>
&gt; [1] 85293<br>
&gt; # dtrace -n pid85293:a.out::<br>
&gt; dtrace: description 'pid85293:a.out::' matched 6828 probes<br>
&gt; [1] + trace trap (core dumped) exec find / &gt; /dev/null 2&gt;&amp;1<br>
&gt; CPU ID FUNCTION:NAME<br>
&gt; 1 89149 find_execute:1f8<br>
&gt; <br>
&gt; looking at find core in gdb<br>
&gt; (gdb) p $_siginfo<br>
&gt; $1 = {<br>
&gt;&nbsp;&nbsp; si_signo = 5,<br>
&gt;&nbsp;&nbsp; si_errno = 0,<br>
&gt;&nbsp;&nbsp; si_code = 3,<br>
&gt;&nbsp;&nbsp; .<br>
&gt;&nbsp;&nbsp; .<br>
&gt;&nbsp;&nbsp; .<br>
&gt; <br>
&gt; Can someone help me understand why am I seeing core due to SIGTRAP TRAP_DTRACE ?<br>
&gt; <br>
&gt; Regards<br>
&gt; Amit<br>
</div>
</span></font></div>
</body>
</html>
help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?SJ0PR18MB4932A03F77D5D999AEAE83C4DC339>