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(Dockerfile): setup for building libafl_qemu in Docker #1899

Merged
merged 7 commits into from
Mar 12, 2024

Conversation

vringar
Copy link
Contributor

@vringar vringar commented Feb 29, 2024

Closes #1895

@vringar vringar marked this pull request as draft February 29, 2024 15:37
@vringar
Copy link
Contributor Author

vringar commented Feb 29, 2024

This is currently a draft, as llvm.sh doesn't install llvm-config and also doesn't support installing version 18 on Debian Bookworm which is the current base of the Rust images.

@tokatoka
Copy link
Member

llvm.sh doesn't install llvm-config

for this you can simply apt install llvm-config-18 after running llvm.sh

@vringar
Copy link
Contributor Author

vringar commented Feb 29, 2024

But unfortunately ./llvm.sh 18 in line 24 of the docker file fails with the error message:

+ apt-get install -y clang-18 lldb-18 lld-18 clangd-18
Reading package lists...
Building dependency tree...
Reading state information...
E: Unable to locate package clang-18
E: Unable to locate package lldb-18
E: Unable to locate package lld-18
E: Unable to locate package clangd-18

@vringar
Copy link
Contributor Author

vringar commented Feb 29, 2024

Other people have had the same issue (the adding of the repository with add-apt-repository doesn't seem to work) and there is a workaround (llvm/llvm-project#62475 (comment)) but I'm unsure if I should implement the workaround or if I should try and land the fix against the source repo.
Would you be open to accept the workaround?

@vringar
Copy link
Contributor Author

vringar commented Feb 29, 2024

For future reference: There is no need install llvm-config separately it is part of the llvm-18 package as llvm-config-18

@vringar
Copy link
Contributor Author

vringar commented Feb 29, 2024

Okay, the build now gets to the point that new bindings get generated which differ from the current bindings (unsafe extern "C" vs extern "C") here.
Do you consider resolving this in scope for this PR or should it be separate?

@vringar vringar changed the title fix(Dockerfile): add build_linux.rs to libafl_qemu and libafl_qemu_sys fix(Dockerfile): setup for building libafl_qemu in Docker Feb 29, 2024
@tokatoka
Copy link
Member

tokatoka commented Mar 1, 2024

you can just include it here if you found the fix

@vringar vringar marked this pull request as ready for review March 3, 2024 14:31
@vringar
Copy link
Contributor Author

vringar commented Mar 3, 2024

Steps to verify this fix works:

docker build -t libafl . && docker run --name libafl --rm -it libafl
# In the now open shell
cargo build --no-default-features -p libafl_qemu && cargo build --no-default-features -p libafl_qemu --release

Also changed the dev container to use the new syntax.

I also tried to verify that this works by running the fuzzers/qemu_systemmode example but I'm not able to interpret the runtime output of the fuzzer. (It does build and start)

@tokatoka
Copy link
Member

tokatoka commented Mar 3, 2024

error[E0308]: arguments to this function are incorrect
     --> /home/runner/work/LibAFL/LibAFL/libafl_qemu/src/emu.rs:1533:23
      |
1533  |             let num = libafl_qemu_sys::libafl_add_cmp_hook(gen, exec1, exec2, exec4, exec8, data);
      |                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      |
note: expected normal fn, found unsafe fn
     --> /home/runner/work/LibAFL/LibAFL/libafl_qemu/src/emu.rs:1533:60
      |
1533  |             let num = libafl_qemu_sys::libafl_add_cmp_hook(gen, exec1, exec2, exec4, exec8, data);
      |                                                            ^^^
      = note: expected enum `std::option::Option<extern "C" fn(_, _, _) -> _>`
                 found enum `std::option::Option<unsafe extern "C" fn(_, _, _) -> _>`

still there's this error (in qemu_fuzzers CI build)

@tokatoka
Copy link
Member

tokatoka commented Mar 6, 2024

is this ready?

@domenukk domenukk merged commit fe1c7a3 into AFLplusplus:main Mar 12, 2024
26 checks passed
@vringar vringar deleted the fix/docker_libaflqemu branch March 17, 2024 16:32
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.

Can't build libafl_qemu in Dockerfile
3 participants