Skip to content

Fix for Pointer Authentication #144

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

Closed
wants to merge 4 commits into from
Closed

Conversation

bgaechter
Copy link

Properly strip PAC signatures from an arm64 process

Description of changes:
The build on Apple M1 notebooks currently fails with the following errors
/src/backward.h:4032:64: error: no member named 'pc' in '__darwin_mcontext64' error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.pc);

src/backward.h:4032:63: error: member reference type 'struct __darwin_mcontext64 *' is a pointer; did you mean to use '->'? error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.pc);

This is happens because of PAC. This change handles PAC and make the code compile again on M1 Macbooks.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

bgaechter and others added 2 commits May 13, 2022 15:30
Properly strip PAC signatures from an arm64 process
Comment on lines 4031 to +4032
# elif defined(__aarch64__)
error_addr = reinterpret_cast<void*>(uctx->uc_mcontext.pc);
error_addr = reinterpret_cast<void*>(uctx->uc_mcontext->__ss.__pc);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Confirmed that this works on my M1 Mac. Before merging, I also want to check that this works on Linux aarch64, as that's not currently covered by the test workflows

@bmoffatt
Copy link
Collaborator

yeah that did not go well on Linux/aarch64!

bryan@air aws-lambda-cpp % docker run --rm -it -v `pwd`:/src public.ecr.aws/amazonlinux/amazonlinux:2
bash-4.2# yum install -q -y curl-devel openssl-devel gcc-c++ ninja-build cmake3
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
bash-4.2# cmake3 -S /src -B /src/build -G Ninja
-- The CXX compiler identification is GNU 7.3.1
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found CURL: /usr/lib64/libcurl.so (found version "7.79.1")
-- Looking for backtrace
-- Looking for backtrace - found
-- backtrace facility detected in default set of libraries
-- Found Backtrace: /usr/include
-- Configuring done
-- Generating done
-- Build files have been written to: /src/build
bash-4.2# cmake3 --build /src/build
[4/5] Building CXX object CMakeFiles/aws-lambda-runtime.dir/src/backward.cpp.o
FAILED: CMakeFiles/aws-lambda-runtime.dir/src/backward.cpp.o
/usr/bin/c++  -DAWS_LAMBDA_LOG=0 -I../include -flto -fno-fat-lto-objects   -fno-exceptions -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion -std=gnu++11 -MD -MT CMakeFiles/aws-lambda-runtime.dir/src/backward.cpp.o -MF CMakeFiles/aws-lambda-runtime.dir/src/backward.cpp.o.d -o CMakeFiles/aws-lambda-runtime.dir/src/backward.cpp.o -c ../src/backward.cpp
In file included from ../src/backward.cpp:26:0:
../src/backward.h: In static member function 'static void backward::SignalHandling::handleSignal(int, siginfo_t*, void*)':
../src/backward.h:4032:63: error: base operand of '->' has non-pointer type 'mcontext_t {aka sigcontext}'
         error_addr = reinterpret_cast<void*>(uctx->uc_mcontext->__ss.__pc);
                                                               ^~
ninja: build stopped: subcommand failed.
bash-4.2# uname -a
Linux 7f7d47b6b999 5.10.104-linuxkit #1 SMP PREEMPT Thu Mar 17 17:05:54 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

Needs more ifdef!

Probably a fresh update of backward.h is actually what we want

@bmoffatt
Copy link
Collaborator

This should be resolved now with #154

@bmoffatt bmoffatt closed this Aug 23, 2022
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.

2 participants