DynamoRIO / DynamoRIO/dynamorio

Bug when add attach mode to aarch64 Linux

Open
#4,246 7 comments 0 reactions 0 assignees View on GitHub
OpSys-AArch64
Dominant language
C
Stars
3.2k
Forks
629
Avg merge
2d 15h
Merged PRs (30d)
31

Description

I add some code in injector.c, which is use ptrace to inject libdynamorio.so to target process.

It works fine in x86.

When port to aarch64, when it enter `privload_early_inject` , I found that the value of `dynamo_initialized` is `58`.

so I add code in `privload_early_inject` to make sure that `dynamo_initialized` is `false`.

```
@@ -1815,6 +1815,8 @@ privload_early_inject(void **sp, byte *old_libdr_base, size_t old_libdr_size)
memquery_iter_t iter;
app_pc interp_map;

dynamo_initialized = false; // add patch
```

Will this cause any problems in some case? And do you have any idea about this situation?

Then I found that get_thread_private_dcontext return `0xfffffffffffffffb`, which lead `segv` in later code.
```
@@ -2804,7 +2804,7 @@ get_thread_private_dcontext(void)
* thread's initialization (see comments below on that).
*/
if (!is_thread_tls_initialized())
return (IF_CLIENT_INTERFACE(standalone_library ? GLOBAL_DCONTEXT :) NULL);
```

I found GLOBAL_DCONTEXT is `0xffffffffffffffff` (why it could return `0xfffffffffffffffb`), so I modify the code in get_thread_private_dcontext to make it return NULL if `!is_thread_tls_initialized()`:
```
@@ -2804,7 +2804,7 @@ get_thread_private_dcontext(void)
* thread's initialization (see comments below on that).
*/
if (!is_thread_tls_initialized())
return NULL; // changed !!!
```

Will this cause any problems in some case? And do you have any idea about this situation?

Base on this
```
https://github.com/DynamoRIO/dynamorio/pull/3328
```

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.