Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide syscall wrappers for mmap and munmap #486

Merged
merged 2 commits into from
Apr 3, 2023

Conversation

bertwesarg
Copy link
Contributor

These functions are assumed to be direct wrappers to the syscalls, but in the past (see Open MPI) and also now (see UCX) runtimes do intercept these functions and do AS-unsafe stuff inside there runtimes. Hence provide internal syscall wrappers for these functions to improve AS-safety.

@bregma
Copy link
Member

bregma commented Mar 30, 2023

We have to support targets other than GNU/Linux. Embedded GNU libc calls with Linux kernel bindings is not going to fly.

@bertwesarg
Copy link
Contributor Author

We have to support targets other than GNU/Linux. Embedded GNU libc calls with Linux kernel bindings is not going to fly.

please point me how to make this portable then. thanks

Copy link
Member

@bregma bregma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Include file needs #ifdefing but otherwise looks good.

@@ -58,6 +58,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
#include <errno.h>
#include <stdio.h>

#include <sys/syscall.h> /* For SYS_xxx definitions */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This non-portable header needs to be surrounded with an #if defined(HAVE_SYS_SYSCALL_H).

JoZie and others added 2 commits April 2, 2023 20:47
This improves the AS-safety, because `munmap` may be intercepted and call
not AS-safe functions (e.g., malloc), which then leads to deadlocks.
(see Open MPI in the past or UCX)
Libunwind assumes that `mmap` "goes straight through to a system call stub".
But this might not be true as other runtimes (I'm looking at you UCX)
wrap `mmap` and do AS-unsafe stuff again.
@bregma bregma merged commit 5010beb into libunwind:master Apr 3, 2023
@bertwesarg bertwesarg deleted the mmap-syscalls branch April 5, 2023 05:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants