Skip to content

memhook: Memhook monitor usage may lead to segfaults/illegal errors #10943

@dsciebu

Description

@dsciebu

Describe the bug:

memhook_monitor intercepts a set of glibc functions like mmap, unmap, madvise, etc. This involves patching the code memory at runtime, where the original assembler from glibc is replaced with custom libfabric runtime-generated assembler. This custom assembler runs some libfabric caching maintenance code before executing the actual syscall. The interception is global and affects glibc function calls made by every function in the running process. When the memhook is released (e.g., on domain destruction), another unrelated thread might be executing the assembler while it is being reverted to its original state by libfabric. This rare situation can lead to segmentation faults or illegal operations at runtime.

To Reproduce:

Clone the reproducer repository: https://github.com/dsciebu/memhook_monitor.git
Follow the instructions in the repository to set up and run the reproducer.
Observe the behavior when the memhook is released.

Expected behavior

The glibc functions should execute without causing segmentation faults or illegal operations, even when the memhook is released.

Environment:

OS: Ubuntu 22.04/24.04 (should irrelevant though)
Provider: Irrelevant (but the reproducer demands verbs)
Endpoint type: Irrelevant (RDM is used in the reproducer)
Additional context Add any other context about the problem here.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions