-
Notifications
You must be signed in to change notification settings - Fork 2
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
__sanitizer_cov_8bit_counters_init never invoked for interpreter #12
Comments
azanegin
added a commit
to azanegin/luzer
that referenced
this issue
Dec 29, 2023
Until now, luzer had not used at all coverage information for interpreted code. Hook-based instrumentation collected data, but it were never passed to libfuzzer to drew features from. Memory always were allocated in a fixed default kMax... size. This commit includes a fix to properly pass counters to libfuzzer, two systems to approximate optimal amount of 8-bit counters: one based on testing, pre-run phase, and one based on active bytecode size. Also, a minor fix to signal handling. Fixes ligurio#12
This was referenced Dec 29, 2023
azanegin
added a commit
to azanegin/luzer
that referenced
this issue
Jan 24, 2024
Until now, luzer had not used at all coverage information for interpreted code. Hook-based instrumentation collected data, but it were never passed to libfuzzer to drew features from. Memory always were allocated in a fixed default kMax... size. This commit includes a fix to properly pass counters to libfuzzer, two systems to approximate optimal amount of 8-bit counters: one based on testing, pre-run phase, and one based on active bytecode size. Also, a minor fix to signal handling and parameter name changes to evade name shadowing of global variables. Fixes ligurio#12
azanegin
added a commit
to azanegin/luzer
that referenced
this issue
Jan 28, 2024
Until now, luzer had not used at all coverage information for interpreted code. Hook-based instrumentation collected data, but it were never passed to libfuzzer to drew features from. Memory always were allocated in a fixed default kMax... size. This commit includes a fix to properly pass counters to libfuzzer, two systems to approximate optimal amount of 8-bit counters: one based on testing, pre-run phase, and one based on active bytecode size. Changes to signatures of counter functions help fix bugs with sign arithmetic. Also, a minor fix to signal handling and parameter name changes to evade name shadowing of global variables. Fixes ligurio#12
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Will provide PR to fix in some time.
The
__sanitizer_cov_8bit_counters_init()
is a hook that LLVM SanitizerCoverage uses to point client code to inline counters that are incremented by instrumented code (well, when used 8bit-inline-ctrs instrumentation). Counters are usually allocated as a separate DSO section.LibFuzzer uses this hook to a add those counters to monitored list. Global DSO-wide constructor inside
sancov.module_ctor_8bit_counters
in each loaded module calls this hook with pointers to ctrs section.Code located here
luzer/luzer/luzer.c
Line 232 in 0179547
also invoke
__sanitizer_cov_8bit_counters_init()
. This is most likely intended for pointing to libfuzzer the region of counters that is used for interpreted code of the lua script.Running test script outputs the following:
This creates a false impression that
mmap
-ed counters for lua code are working. As I pointed out above, each instrumented DSO should call the hook once. Then,luzer.so
code should call the hook for dynamic counters. This is not the case.As we can see here,
_init()
hook is called just once. And this call is from none other place thanluzer.so
DSO constructor. No call for mmap-ed counters ever made. Why?luzer/luzer/counters.c
Line 126 in 0179547
This condition is always true, as (contrast to atheris) in this code no counters are ever registered.
Basically, right now the Lua "debug hook instrumentation" is useless. Only way it ever reaches LibFuzzer is via another bug: #11
But
luzer
works for compiled, native lua modules, that were build with SanCov and register their own counters.The text was updated successfully, but these errors were encountered: