HomeFreeBSD

fasttrap: Avoid creating WX mappings

Description

fasttrap: Avoid creating WX mappings

fasttrap instruments certain instructions by overwriting them and
copying the original instruction to some per-thread scratch space which
is executed after the probe fires. This trampoline jumps back to the
tracepoint after executing the original instruction.

The created mapping has both write and execute permissions, and so this
mechanism doesn't work when allow_wx is disabled. Work around the
restriction by using proc_rwmem() to write to the trampoline.

Reviewed by: vangyzen
Tested by: Amit <akamit91@hotmail.com>
MFC after: 2 weeks
Sponsored by: The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D34304

Details

Provenance
markjAuthored on Mar 1 2022, 4:53 PM
Reviewer
vangyzen
Differential Revision
D34304: fasttrap: Avoid creating WX mappings
Parents
rG83958173eb7d: fasttrap: Assert that fasttrap_fork() successfully unmaps scratch space
Branches
Unknown
Tags
Unknown