DynamoRIO / DynamoRIO/dynamorio

handle early injection into a #! script

Open
#3,115 0 comments 0 reactions 0 assignees View on GitHub
Component-UI good first issue help wanted OpSys-UNIX Usability
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

This issue covers getting drrun with early injection to execute a script.
This used to work with late injection but was never a high priority and it
regressed when we went to early injection.

Xref #1925 and 30a73d72ed910d66b6f1356e5946f4145fc84a94 removing some
drinjectlib blockers.

Xref #2091 for handling an observed execve of a #! script, and its
1b763ba775b8f43fff347ff90eaa628bdc3af942 adding script parsing logic which
should be shareable here.

Today this is what happens:
```
$ bin64/drrun -- /tmp/abc.sh

```

```
(gdb) bt
#0 report_dynamorio_problem (dcontext=0x0, dumpcore_flag=16, exception_addr=0x0, report_ebp=0x0, fmt=0x7fd01f5b5fcf "Usage error: %s (%s, line %d)")
at /home/bruening/dr/git/src/core/utils.c:2127
#1 0x00007fd01f3762e9 in external_error (file=0x7fd01f60fbc0 "/home/bruening/dr/git/src/core/unix/loader.c", line=1814,
msg=0x7fd01f6103e0 "Failed to read app ELF headers. Check path and architecture.") at /home/bruening/dr/git/src/core/utils.c:202
#2 0x00007fd01f5720f0 in privload_early_inject (sp=0x7ffc75699c20, old_libdr_base=0x0, old_libdr_size=140722278341216)
at /home/bruening/dr/git/src/core/unix/loader.c:1812
#3 0x00007fd01f522828 in reloaded_xfer () at /home/bruening/dr/git/src/core/arch/x86/x86.asm:1187
#4 0x0000000000000001 in ?? ()
#5 0x00007ffc7569b164 in ?? ()
#6 0x0000000000000000 in ?? ()
(gdb) up 2
#2 0x00007fd01f5720f0 in privload_early_inject (sp=0x7ffc75699c20, old_libdr_base=0x0, old_libdr_size=140722278341216)
at /home/bruening/dr/git/src/core/unix/loader.c:1812
1812 apicheck(success,
(gdb) p exe_path
$1 = 0x7ffc7569bf9d "/tmp/abc.sh"
```

It works fine if we're in control of the parent:
```
$ bin64/drrun -- suite/tests/bin/linux.execve64 /tmp/abc.sh

parent is running under DynamoRIO
<-- parent 195512 forked child 195513 -->
parent waiting for child
child is running under DynamoRIO
<-- execve /bin/bogus_will_fail -->
<-- execve /bin/bash -->

abc

child has exited

```

```
$ bin64/drrun -- bash -c /tmp/abc.sh

<-- execve /bin/bash -->

abc

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.