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

Fix trace mode on arm64 #354

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

neverpanic
Copy link
Member

Fix trace mode on arm64 by stripping the CPU subtype that enables pointer authentication in the Mach-O headers of Apple's binaries.

Re-enable darwintrace proc tests on arm64.

@neverpanic
Copy link
Member Author

Actually, this code should probably be updated with bounds checks for all the access into the mmap(2)'d file.

@neverpanic neverpanic marked this pull request as draft November 3, 2024 21:37
@neverpanic
Copy link
Member Author

Actually, this code should probably be updated with bounds checks for all the access into the mmap(2)'d file.

Done.

@neverpanic neverpanic marked this pull request as ready for review November 4, 2024 20:29
@neverpanic neverpanic force-pushed the cal-fix-arm64-tracmode branch 3 times, most recently from 3e7b15e to 84c5efd Compare November 4, 2024 22:33
neverpanic and others added 5 commits November 15, 2024 11:43
Access would previously be allowed, too, because these files are not
installed by a MacPorts port. They did generate a warning, though, which
is not necessary. Adding an explicit whitelist entry silences them.
When we modify the copying algorithm for the trace mode SIP workaround,
re-copy the files if the mtime didn't change since they were initially
copied, but their ctime is older than that of the Pextlib.dylib (or
darwintrace.dylib) that contains the copying code.

This allows us to modify the copying algorithm, which will then cause
all previously copied files to be considered outdated.
Fix trace mode on arm64 by stripping the CPU subtype that enables
pointer authentication in the Mach-O headers of Apple's binaries.

Closes: https://trac.macports.org/ticket/66358
Relax the path check in sipp_copy_proc.c so that it also passes in the
build tree, not only in the install location.
Invoking [setup] enables the tracing sandbox, which means that binaries
started after that must be started via system or must not be arm64e
system binaries (which are untraceable unmodified and will crash with
DYLD_INSERT_LIBRARIES set).

The reverse applies for [expect] in the cleanup phase.

Use system for invocations of system utilities that should be traced
when invoked after [setup]. Move invocations that don't need to be
traced after [expect] in cleanup.

Add infrastructure required to use system (e.g., allow access to the
shell and provide `ui_info` and `ui_debug`).
@jmroot
Copy link
Member

jmroot commented Nov 15, 2024

Thanks for this. I'll try to review it before too long.

@neverpanic
Copy link
Member Author

Note that this doesn't correctly work on macOS 14 yet. See the discussion in the ticket.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants