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

Installation is currently hit & miss on mac os #1

Open
agroce opened this issue Dec 16, 2020 · 19 comments
Open

Installation is currently hit & miss on mac os #1

agroce opened this issue Dec 16, 2020 · 19 comments

Comments

@agroce
Copy link

agroce commented Dec 16, 2020

First, the proposed way to grab TinyInst doesn't work:

git clone --recurse-submodules [email protected]:googleprojectzero/TinyInst.git
Cloning into 'TinyInst'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Changing to just use the https for the TinyInst repo works.

Second, when you try to build:

(base) cmp3149:Jackalope adg326$ cd build
(base) cmp3149:build adg326$ cmake -G Xcode ..
-- The C compiler identification is AppleClang 12.0.0.12000032
-- The CXX compiler identification is AppleClang 12.0.0.12000032
CMake Error at TinyInst/third_party/CMakeLists.txt:18 (project):
  No CMAKE_C_COMPILER could be found.



CMake Error at TinyInst/third_party/CMakeLists.txt:18 (project):
  No CMAKE_CXX_COMPILER could be found.



-- Configuring incomplete, errors occurred!
See also "/Users/adg326/Jackalope/build/CMakeFiles/CMakeOutput.log".
@ifratric
Copy link
Collaborator

For the git error: Right, that only works if you have ssh key configured in github. I'll make a note of that in the readme.

First time I see the 2nd error though. Do you have Xcode installed and have you ran it at least once (it installs some tools only on the 1st run)?

@agroce
Copy link
Author

agroce commented Dec 16, 2020

Definitely have xcode installed/xcode-select ran long ago, etc.

Tried first on a "clean" setup but with git and command line dev, since I may point students at this in a class this spring, but then on my normal dev machine, which is compiling things all over the place. I'm very interested in getting this running, be really nice to have a mac-friendly fuzzer come with https://github.com/trailofbits/deepstate, especially one that makes custom mutators (so we could add awareness of test structure) easy!

@ifratric
Copy link
Collaborator

Does running
sudo xcode-select --reset
help?

@dgh05t
Copy link

dgh05t commented Dec 17, 2020

Hi,
Same problem here when compiling TinyInst.
and "sudo xcode-select --reset" doesn't help.

@dgh05t
Copy link

dgh05t commented Dec 17, 2020

issue solved with " brew upgrade cmake"

@ifratric
Copy link
Collaborator

Cool! Glad to hear that updating cmake resolves the issue.

@agroce Does this resolve the issue for you as well?

@agroce
Copy link
Author

agroce commented Dec 17, 2020

Will check!

@agroce
Copy link
Author

agroce commented Dec 17, 2020

Fixed. And

./fuzzer -in in -out out -t 1000 -delivery shmem -instrument_module test -target_module test -target_method __Z4fuzzPc -nargs 1 -iterations 10000 -persist -loop -cmp_coverage -- ./test -m @@

works. When I tried to use it on a DeepState executable, it didn't work, but I'm guessing this is just me not having grasped all the required arguments' meanings, etc.:

~/Jackalope/build/Release/fuzzer -in corpus -out fuzz -t 1000 -delivery file -instrument_module Runlen -target_module Runlen -target_method __Z4fuzzPc -nargs 1 -iterations 10000 -persist -loop -cmp_coverage -- ./Runlen --input_which_test Runlength_EncodeDecode --input_test_file @@
Fuzzer version 0.01
1 input files read
Running input sample corpus/ffd9de9abb7f26f888c09183b2da0e2b4292f17d.pass
[-] PROGRAM ABORT : Error ((os/kern) failure) calling task_for_pid
         Location : MachTarget(), /Users/adg326/Jackalope/TinyInst/macOs/machtarget.cpp:34

@ifratric
Copy link
Collaborator

ah, right, task_for_pid, that means the fuzzer doesn't have the rights to attach to the target process. This can be resolved in one of two ways:

  • Running the fuzzer with sudo (possibly SIP needs to be disabled as well, but not sure for non-system targets).

  • Depends on how the target is compiled. I noticed that if the target is compiled on the comand line (e.g. with clang, gcc, etc.) it results in this error. However, if the target is compiled from xcode, it just works with normal user permissions. Not sure exactly what xcode does differently.

@ifratric
Copy link
Collaborator

ifratric commented Dec 17, 2020

Likely related to the 2nd point about Xcode:

https://developer.apple.com/documentation/bundleresources/entitlements/com_apple_security_cs_debugger

Xcode automatically adds the Get Task Allow entitlement to apps that you build for debugging, while removing the entitlement before App Store submission. This enables Xcode itself to attach to and debug your app during development.

@agroce
Copy link
Author

agroce commented Dec 17, 2020

Aha! Permissions. Hmm. sudo should fix it, though for a more ambitious target not entirely thrilled to fuzz under sudo. :)

@agroce
Copy link
Author

agroce commented Dec 17, 2020

Will try out when I am around the machine.

@agroce
Copy link
Author

agroce commented Dec 18, 2020

sudo worked, but it hit another snag...

sudo ~/Jackalope/build/Release/fuzzer -in corpus -out fuzz -t 1000 -delivery file -instrument_module Runlen -nargs 1 -iterations 10000 -cmp_coverage -- ./Runlen --input_which_test Runlength_EncodeDecode --input_test_file @@
Fuzzer version 0.01
1 input files read
Running input sample corpus/ffd9de9abb7f26f888c09183b2da0e2b4292f17d.pass
Instrumented module Runlen, code size: 49152
TRACE: Initialized test input buffer with data from `fuzz/input_1`
TRACE: Running: Runlength_EncodeDecode from /Users/adg326/deepstate/examples/Runlen.cpp(55)
[-] PROGRAM ABORT : Debugger object could not be found in the map, task port = (3375)
         Location : catch_mach_exception_raise_state_identity(), /Users/adg326/Jackalope/TinyInst/macOS/debugger.cpp:1311

has it mostly been tried on xcode-compiled targets, rather than command line clang-built stuff?

@ifratric
Copy link
Collaborator

Hmm, that's a strange error to get, my test app works normally with sudo, but I can reproduce with your target. Not sure if sudo is to blame here or something else. Will investigate.

@ifratric
Copy link
Collaborator

So, it's not about sudo or build, I verified that the same error still occurs for Runlen even if it's built with Xcode and ran without sudo.

The error in question is raised because the debugger is getting an exception from an unexpected task port and thus doesn't know how to handle it.

It would be helpful if you could point out any potentially related behaviour in your target such as:

  • Does the target create child processes
  • Does the target itself act as a debugger
  • Does the target do something related to exception ports
  • Any other behavior you can think of that might be related.

@ifratric
Copy link
Collaborator

Right, fork() seems to be the problem here. If you add --fork=false to the Runlen command line arguments, it seems to work.

@agroce
Copy link
Author

agroce commented Dec 18, 2020

Thanks! Of course. I should have guessed, fork is always the villain.

@agroce
Copy link
Author

agroce commented Dec 18, 2020

Non-trivial enough I'll definitely want to set up a front end!

@agroce
Copy link
Author

agroce commented Dec 18, 2020

Works! Wonder if I can work around having to sudo...

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

No branches or pull requests

3 participants