Skip to content

libafl_libfuzzer: rename all symbols#1565

Merged
domenukk merged 7 commits into
mainfrom
libfuzzer-allocator
Nov 20, 2023
Merged

libafl_libfuzzer: rename all symbols#1565
domenukk merged 7 commits into
mainfrom
libfuzzer-allocator

Conversation

@addisoncrump

@addisoncrump addisoncrump commented Sep 27, 2023

Copy link
Copy Markdown
Member

Previously we were unable to use mimalloc due to symbol conflict with the default rust allocator. This avoids this issue by renaming the symbols responsible for allocation.

Note that, in rare circumstances, we would deadlock while handling an ASAN error due to allocations inside of a signal handler. This sidesteps the issue by avoiding the use of the async-signal-unsafe malloc.

@addisoncrump addisoncrump changed the title libafl_libfuzzer: avoid panic by using mimalloc libafl_libfuzzer: avoid deadlock by using mimalloc Sep 27, 2023
@addisoncrump
addisoncrump marked this pull request as draft September 27, 2023 16:16
@addisoncrump

Copy link
Copy Markdown
Member Author

Seems that the target is sometimes using data from the fuzzer runtime, leading to invalid frees. Investigating.

@addisoncrump addisoncrump changed the title libafl_libfuzzer: avoid deadlock by using mimalloc libafl_libfuzzer: rename all symbols Sep 27, 2023
@addisoncrump

Copy link
Copy Markdown
Member Author

In the process of doing this, I discovered that it was necessary to rename just about everything. So I did.

@addisoncrump
addisoncrump marked this pull request as ready for review September 27, 2023 17:49
@tokatoka

Copy link
Copy Markdown
Member

i'll build it, run it and tomorrow morning we see if the problem still lingers.
it happens very rarely, at least last time it happened after 6 ~ 7 hours.

@tokatoka

Copy link
Copy Markdown
Member

jlumbroso/free-disk-space#17
This seems like to be the solution

@tokatoka

Copy link
Copy Markdown
Member

#1559
QEMU fuzzers are problematic. We can't run them in the same container as fuzzers (Ubuntu)
One, they take too long. Two, we shouldn't build them sequentially, there's simply no diskspace available

@tokatoka

Copy link
Copy Markdown
Member

let's see if it's fixed

@addisoncrump

addisoncrump commented Sep 27, 2023

Copy link
Copy Markdown
Member Author

This affects way more than this PR 😅 Maybe make a separate PR if this works?

@tokatoka

Copy link
Copy Markdown
Member

#1567

@tokatoka

Copy link
Copy Markdown
Member

now you have clippy

@addisoncrump

Copy link
Copy Markdown
Member Author

GDB and LLDB both support the new renaming pattern. c++filt, llvm-cxxfilt, and rustc-demangle do not correctly decode the renaming, but that is a sacrifice I'm willing to make.
See upstream tooling fix: rust-lang/rustc-demangle#65

@tokatoka

tokatoka commented Sep 28, 2023

Copy link
Copy Markdown
Member

should we make this default-features?

for sandwich, most people don't disable asan. so i think it's better to have this as default

Comment thread libafl_libfuzzer/build.rs
let mut command = Command::new(rust_lld);
command
.args(["-flavor", "gnu"])
.arg("-r")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

partial linking works with GNU ld too in case

Comment thread libafl_libfuzzer/build.rs

// redefine all the rust-mangled symbols we can
// TODO this will break when v0 mangling is stabilised
for line in BufReader::new(child.stdout.take().unwrap()).lines() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can't we just avoid to export symbols when generating the runtime lib? like partial linking and then remove all symbols

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We want to retain these symbols for both debugging purposes and because we need to retain certain unmangled symbols (e.g. LLVMFuzzerRuntime, LLVMFuzzerMutate, etc.)

@addisoncrump

Copy link
Copy Markdown
Member Author

should we make this default-features?

This is always enabled on Unix. Not sure how to do this on Windows.

Comment thread libafl_libfuzzer/Cargo.toml
@addisoncrump
addisoncrump force-pushed the libfuzzer-allocator branch 2 times, most recently from 32a749b to 02d8b87 Compare October 4, 2023 15:56
@andreafioraldi

Copy link
Copy Markdown
Member

Status of this?

@addisoncrump

Copy link
Copy Markdown
Member Author

Just fighting the CI at this point. Something weird is happening with the FreeBSD test.

@domenukk

domenukk commented Nov 3, 2023

Copy link
Copy Markdown
Member

Can we merge?

@addisoncrump

Copy link
Copy Markdown
Member Author

This is ready to go if anyone wants to give it a final pass.

@domenukk
domenukk merged commit 1e96652 into main Nov 20, 2023
@domenukk
domenukk deleted the libfuzzer-allocator branch November 20, 2023 20:55
tokatoka pushed a commit that referenced this pull request Nov 21, 2023
* rename allocator symbols to avoid conflict with mimalloc

* re-add llvm-tools to CI

* rename everything

* fixup clippy lint

* make fuzzer entries more noticeable :)

* rabbit mode

* clippy
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