DynamoRIO / DynamoRIO/dynamorio

os_tls_calloc does not handle alignment parameter correctly

Open
#6,608 0 comments 0 reactions 0 assignees View on GitHub
OpSys-UNIX
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

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.