DynamoRIO / DynamoRIO/dynamorio
os_tls_calloc does not handle alignment parameter correctly
- Dominant language
- C
- Stars
- 3.2k
- Forks
- 629
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 31
Description
The function is here:
https://github.com/DynamoRIO/dynamorio/blob/95fd0237a5b9c9ca1add88574f9bddca002a82e9/core/unix/os.c#L2507-L2538
If you ask for `num_slots > 1` then the implementation wants every slot to be aligned, which fails if the `alignment` is greater than the size of a slot and succeeds trivially otherwise, so the parameter is useless, I think.
You can fix this, I think, by adding `start != -1 ||` to the start of the condition on the line
https://github.com/DynamoRIO/dynamorio/blob/95fd0237a5b9c9ca1add88574f9bddca002a82e9/core/unix/os.c#L2519
so the condition reads: `(!client_tls_allocated[i] && (start != -1 || alignment == 0 || ALIGNED(...)))`
Contributor guide
Assessment
This issue has not been assessed yet.