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

libafl-fuzz: introduce nyx_mode #2503

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

R9295
Copy link
Collaborator

@R9295 R9295 commented Aug 29, 2024

Let's see if the CI works. We need an intel CPU for nyx_mode

@tokatoka
Copy link
Member

can you cargo fmt? (inside your others/libafl-fuzz

@R9295
Copy link
Collaborator Author

R9295 commented Aug 29, 2024

Looks like nyx mode won't run on github CI according @vanhauser-thc 's script. Can someone with an intel CPU please test?

@rmalmain
Copy link
Collaborator

I have a machine on which i usually run kAFL. I can run the tests there if you want.
Do i need a specific version of the kernel to have the tests running?


rm -rf ./test/nyx-test

python3 ${AFL_DIR}/nyx_mode/packer/packer/nyx_packer.py \
Copy link
Member

Choose a reason for hiding this comment

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

you can't do this on gh ci

Copy link
Collaborator

Choose a reason for hiding this comment

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

to integrate this in ci we would need a dedicated machine.
for now I'll just run the test on my machine and see if it works when @R9295 replies

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks @tokatoka & @rmalmain . I've got access to an Intel machine now. I'll change libafl-fuzz's nyx mode to use libafl_nyx instead of AFL++'s nyx_mode cause libnyx is Rust anyways so IMO it makes more sense

@domenukk
Copy link
Member

domenukk commented Sep 8, 2024

Any news here?

@R9295
Copy link
Collaborator Author

R9295 commented Sep 12, 2024

@rmalmain Could you please test this on a machine with kvm? you just need to run cargo make test_nyx_mode

@rmalmain
Copy link
Collaborator

@rmalmain Could you please test this on a machine with kvm? you just need to run cargo make test_nyx_mode

No problem, I'll run it now @R9295

@rmalmain
Copy link
Collaborator

rmalmain commented Sep 12, 2024

@R9295 i received a link error during building:

/usr/bin/ld: /tmp/lto-llvm-05edc4.o: in function `main':
ld-temp.o:(.text.main+0x300): undefined reference to `net_fuzz_bitmap'
/usr/bin/ld: ld-temp.o:(.text.main+0x30e): undefined reference to `pt_decoder_init'
/usr/bin/ld: ld-temp.o:(.text.main+0x32c): undefined reference to `init_disassembler'
/usr/bin/ld: ld-temp.o:(.text.main+0x342): undefined reference to `fuzz_bitmap_reset'
/usr/bin/ld: ld-temp.o:(.text.main+0x34b): undefined reference to `destroy_disassembler'
/usr/bin/ld: ld-temp.o:(.text.main+0x353): undefined reference to `pt_decoder_destroy'
/usr/bin/ld: ld-temp.o:(.text.main+0x3aa): undefined reference to `decode_buffer'
/usr/bin/ld: ld-temp.o:(.text.main+0x3eb): undefined reference to `pt_decoder_get_page_fault_addr'
/usr/bin/ld: ld-temp.o:(.text.main+0x44d): undefined reference to `destroy_disassembler'
/usr/bin/ld: ld-temp.o:(.text.main+0x456): undefined reference to `pt_decoder_destroy'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Makefile:34: ptdump_static] Error 1
cp: cannot stat 'libnyx/libnyx/target/release/liblibnyx.so': No such file or directory

@R9295
Copy link
Collaborator Author

R9295 commented Sep 12, 2024

@rmalmain is this a Rust (libafl-fuzz / libafl_nyx) issue or a AFL++ one?

@R9295
Copy link
Collaborator Author

R9295 commented Sep 12, 2024

Could you please try again?

@rmalmain
Copy link
Collaborator

the error does not trigger when CC is not clang (i have a very recent version, should be the problem)
I'll try again with your change

@rmalmain
Copy link
Collaborator

didn't change much on my side

@R9295
Copy link
Collaborator Author

R9295 commented Sep 12, 2024

@rmalmain thanks. I'll need to have a look myself cause this is compiling just fine on my Intel THinkpad with clang-18 (just no kvm stuff so it won't actually run). I'll DIY it

@rmalmain
Copy link
Collaborator

I tried with multiple versions of clang:

  • clang 19: cf the error message above
  • clang 17, clang 18, gcc: various errors (expected i guess)
    pip error:
b'[...]/LibAFL/libafl_nyx/packer/linux_initramfs\n'
[ERROR]   Package 'msgpack' is missing (Hint: `pip install msgpack`)!
[ERROR]   Tool 'lddtree' is missing (Hint: run `sudo apt install pax-utils`)!

kvm backdoor error:

[QEMU-Nyx] ERROR: vmware backdoor is not enabled...

	Run the following commands to fix the issue:
	-----------------------------------------
	sudo modprobe -r kvm-intel
	sudo modprobe -r kvm
	sudo modprobe  kvm enable_vmware_backdoor=y
	sudo modprobe  kvm-intel
	cat /sys/module/kvm/parameters/enable_vmware_backdoor
	-----------------------------------------

for the last few errors i guess it's the user's responsibility to handle that?

otherwise it ended up working correctly

@R9295
Copy link
Collaborator Author

R9295 commented Sep 12, 2024

Ah I see. Thanks @rmalmain

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.

4 participants