DynamoRIO / DynamoRIO/dynamorio
Error happens when elf app doesn’t have a rseq_cs struct
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
**Describe the bug**
Running DynamoRIO to instrument any application on the fortigate(based on linux platform), a fault occurs.
`./drrun -- test ` (no client at all) results in an error: `Restartable sequence behavior is not supported: struct rseq is not in static thread-local storage.`
Note that running fortigate’s own app also result a error, include scp etc.
**To Reproduce**
Steps to reproduce the behavior:
1. Root the fortigate vm 7.2.4, and copy DynamoRIO linux release 10 to the vm. And copy any test app to the vm.
2. Precise command line for running the application: `./drrun -- test`
3. Exact output or incorrect behavior: `Restartable sequence behavior is not supported: struct rseq is not in static thread-local storage`
**Expected behavior**
No error, correct instrumentation.
**Screenshots or Pasted Text**
```
Restartable sequence behavior is not supported: struct rseq is not in static thread-local storage.
```
**Versions**
- What version of DynamoRIO are you using?
Tested the 10.0.0 release and also a fresh build on master.
- Does the latest build from https://github.com/DynamoRIO/dynamorio/releases solve the problem?
Not tested.
- What operating system version are you running on? ("Windows 10" is *not* sufficient: give the release number.)
Linux version 4.19.13 (root@build) (gcc version 10.3.0 (GCC)) #1 SMP Tue Jan 31 05:32:20 UTC 2023.
- Is your application 32-bit or 64-bit?
64 bit.
**Additional context**
This is the same rseq issue as described in https://github.com/DynamoRIO/dynamorio/issues/5431.
The problem might be related to rseq. I found the test app have no rseq_cs struct for each rseq region, which is described in https://dynamorio.org/API_BT.html#sec_rseq as limitation 2. I tried to use -[disable_rseq](https://dynamorio.org/page_deploy.html#op_disable_rseq) option, but it gets the same error.
I found in the https://github.com/DynamoRIO/dynamorio/issues/5431 discussing, [abhinav92003](https://github.com/abhinav92003) said “The final issue I'm running into is I think because the struct rseq is not in the static TLS anymore. (It causes an EINVAL in rseq tests and "struct rseq is not in static thread-local storage" in burst tests). This is as documented at https://sourceware.org/pipermail/libc-alpha/2021-November/133221.html. Also, https://lwn.net/Articles/883104/ says that the rseq registered by glibc is stored in the Thread Control Block maintained by glibc. I'm working on modifying rseq_locate_tls_offset for this.” Function rseq_locate_tls_offset returns 0, then drrun puts the error.
Contributor guide
Assessment
This issue has not been assessed yet.