-
-
Notifications
You must be signed in to change notification settings - Fork 394
Nyx hypercall API support for LibAFL QEMU #2801
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
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
61067a9
nyx api support
rmalmain 1874566
update hash
rmalmain 2c0e69b
clippy + fmt
rmalmain ba18349
Merge branch 'main' into nyx_api
rmalmain ec486bf
fix linux kernel fuzzer
rmalmain 88c338d
fixing some stuff
rmalmain fd388fd
nyx comments
rmalmain eb41150
hash_me -> hash_64_fast
rmalmain 53e5384
separate nyx driver from std driver
rmalmain fa35d43
import
rmalmain a7b0cd4
Merge branch 'main' into nyx_api
rmalmain e0e012f
do not check libmozjpeg format.
rmalmain aeaf970
fix bloom
rmalmain 3b153c8
Merge branch 'main' into nyx_api
rmalmain 6d78309
fix merge
rmalmain 0c6da52
fix qemu launcher
rmalmain 7000f49
update qemu hash
rmalmain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
obj-m += harness.o | ||
|
||
all: | ||
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules | ||
make -C /lib/modules/$(LINUX_MODULES)/build M=$(PWD) modules | ||
gcc -Wall -Werror -o user user.c | ||
|
||
clean: | ||
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean | ||
rm user | ||
make -C /lib/modules/$(LINUX_MODULES)/build M=$(PWD) clean | ||
rm -f user |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
#!/bin/bash | ||
|
||
LINUX_MODULES=$(pacman -Ql linux-headers | grep -m 1 -E '/usr/lib/modules/[^/]*/' | sed 's|.*/usr/lib/modules/\([^/]*\)/.*|\1|') | ||
export LINUX_MODULES | ||
|
||
cd /setup | ||
make clean | ||
make -j | ||
ls /setup | ||
make -j |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,10 @@ authors = ["Romain Malmain <[email protected]>"] | |
edition = "2021" | ||
|
||
[features] | ||
|
||
## Build and run the target with the Nyx API instead of the built-in LibAFL QEMU API. | ||
nyx = [] | ||
|
||
shared = ["libafl_qemu/shared"] | ||
|
||
[profile.release] | ||
|
@@ -16,15 +20,10 @@ codegen-units = 1 | |
[dependencies] | ||
libafl = { path = "../../../libafl" } | ||
libafl_bolts = { path = "../../../libafl_bolts" } | ||
libafl_qemu = { path = "../../../libafl_qemu", features = [ | ||
"x86_64", | ||
"systemmode", | ||
# "paranoid_debug" | ||
] } | ||
libafl_qemu_sys = { path = "../../../libafl_qemu/libafl_qemu_sys", features = [ | ||
libafl_qemu = { path = "../../../libafl_qemu", default-features = false, features = [ | ||
"x86_64", | ||
"systemmode", | ||
# "paranoid_debug" | ||
# "paranoid_debug", | ||
] } | ||
env_logger = "0.11.5" | ||
libafl_targets = { path = "../../../libafl_targets" } | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
env_scripts = [''' | ||
#!@duckscript | ||
profile = get_env PROFILE | ||
harness_api = get_env HARNESS_API | ||
if eq ${profile} "dev" | ||
set_env PROFILE_DIR debug | ||
else | ||
set_env PROFILE_DIR ${profile} | ||
end | ||
if eq ${harness_api} "nyx" | ||
set_env FEATURE nyx | ||
else | ||
set_env FEATURE "" | ||
end | ||
''', ''' | ||
#!@duckscript | ||
runs_on_ci = get_env RUN_ON_CI | ||
|
@@ -25,12 +33,12 @@ TARGET_DIR = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}" | |
LIBAFL_QEMU_CLONE_DIR = { value = "${CARGO_MAKE_CRATE_TARGET_DIRECTORY}/qemu-libafl-bridge", condition = { env_not_set = [ | ||
"LIBAFL_QEMU_DIR", | ||
] } } | ||
|
||
LINUX_BUILDER_URL = "[email protected]:AFLplusplus/linux-qemu-image-builder.git" | ||
LINUX_BUILDER_DIR = { value = "${TARGET_DIR}/linux_builder", condition = { env_not_set = [ | ||
"LINUX_BUILDER_DIR", | ||
] } } | ||
LINUX_BUILDER_OUT = "${LINUX_BUILDER_DIR}/output" | ||
HARNESS_API = { value = "lqemu", condition = { env_not_set = ["HARNESS_API"] } } | ||
|
||
[tasks.target_dir] | ||
condition = { files_not_exist = [ | ||
|
@@ -51,7 +59,22 @@ script = ''' | |
git clone ${LINUX_BUILDER_URL} ${LINUX_BUILDER_DIR} | ||
''' | ||
|
||
[tasks.compile_target] | ||
[tasks.compile_target_nyx] | ||
condition = { env = { "HARNESS_API" = "nyx" } } | ||
dependencies = ["target_dir", "linux_builder_dir"] | ||
command = "clang" | ||
args = [ | ||
"-O0", | ||
"-static", | ||
"${WORKING_DIR}/example/harness_nyx.c", | ||
"-o", | ||
"${TARGET_DIR}/runtime/harness", | ||
"-I", | ||
"${TARGET_DIR}/${PROFILE_DIR}/include", | ||
] | ||
|
||
[tasks.compile_target_native] | ||
condition = { env = { "HARNESS_API" = "lqemu" } } | ||
dependencies = ["target_dir", "linux_builder_dir"] | ||
command = "clang" | ||
args = [ | ||
|
@@ -64,6 +87,9 @@ args = [ | |
"${TARGET_DIR}/${PROFILE_DIR}/include", | ||
] | ||
|
||
[tasks.compile_target] | ||
dependencies = ["compile_target_native", "compile_target_nyx"] | ||
|
||
[tasks.target] | ||
dependencies = ["build", "compile_target"] | ||
script_runner = "@shell" | ||
|
@@ -96,7 +122,15 @@ ${LINUX_BUILDER_DIR}/update.sh | |
[tasks.build] | ||
dependencies = ["target_dir"] | ||
command = "cargo" | ||
args = ["build", "--profile", "${PROFILE}", "--target-dir", "${TARGET_DIR}"] | ||
args = [ | ||
"build", | ||
"--profile", | ||
"${PROFILE}", | ||
"--target-dir", | ||
"${TARGET_DIR}", | ||
"--features", | ||
"${FEATURE}", | ||
] | ||
|
||
[tasks.run] | ||
dependencies = ["build"] | ||
|
@@ -111,15 +145,15 @@ else | |
LIBAFL_QEMU_BIOS_DIR=${LIBAFL_QEMU_CLONE_DIR}/build/qemu-bundle/usr/local/share/qemu | ||
fi | ||
cp ${LINUX_BUILDER_OUT}/OVMF_CODE.fd ${LINUX_BUILDER_OUT}/OVMF_CODE.fd.clone | ||
cp ${LINUX_BUILDER_OUT}/OVMF_VARS.fd ${LINUX_BUILDER_OUT}/OVMF_VARS.fd.clone | ||
cp ${LINUX_BUILDER_OUT}/OVMF_CODE.4m.fd ${LINUX_BUILDER_OUT}/OVMF_CODE.fd.clone | ||
cp ${LINUX_BUILDER_OUT}/OVMF_VARS.4m.fd ${LINUX_BUILDER_OUT}/OVMF_VARS.fd.clone | ||
cp ${LINUX_BUILDER_OUT}/linux.qcow2 ${LINUX_BUILDER_OUT}/linux.qcow2.clone | ||
${TARGET_DIR}/${PROFILE_DIR}/qemu_linux_process \ | ||
-accel tcg \ | ||
-m 4G \ | ||
-drive if=pflash,format=raw,file="${LINUX_BUILDER_OUT}/OVMF_CODE.fd" `# OVMF code pflash` \ | ||
-drive if=pflash,format=raw,file="${LINUX_BUILDER_OUT}/OVMF_VARS.fd" `# OVMF vars pflash` \ | ||
-drive if=pflash,format=raw,file="${LINUX_BUILDER_OUT}/OVMF_CODE.4m.fd" `# OVMF code pflash` \ | ||
-drive if=pflash,format=raw,file="${LINUX_BUILDER_OUT}/OVMF_VARS.4m.fd" `# OVMF vars pflash` \ | ||
-device virtio-scsi-pci,id=scsi0 `# SCSI bus` \ | ||
-device scsi-hd,bus=scsi0.0,drive=disk,id=virtio-disk0,bootindex=1 \ | ||
-blockdev driver=file,filename="${LINUX_BUILDER_OUT}/linux.qcow2",node-name=storage `# Backend file of "disk"` \ | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time to add some comments here to explain the features? We're using this for the other crates.
Specifically, I would explain that this adds API compatibility but isn't doing the same as nyx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense, didn't know about this crate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we should put the precision in the nyx module doc then, this feature is only for the example fuzzer.