-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
initial support for integrated fuzzing #20725
Conversation
a2fdc16
to
25fc237
Compare
* Add the `-ffuzz` and `-fno-fuzz` CLI arguments. * Detect fuzz testing flags from zig cc. * Set the correct clang flags when fuzz testing is requested. It can be combined with TSAN and UBSAN. * Compilation: build fuzzer library when needed which is currently an empty zig file. * Add optforfuzzing to every function in the llvm backend for modules that have requested fuzzing. * In ZigLLVMTargetMachineEmitToFile, add the optimization passes for sanitizer coverage. * std.mem.eql uses a naive implementation optimized for fuzzing when builtin.fuzz is true. Tracked by #20702
This is needed to ensure that start code does not try to access thread local storage before it has set up thread local storage.
I have committed to implementing this next month this as part of my term project. Is there a space for collaboration? I have to implement this either way and I would love to contribute my implementation upstream. |
Sure. I'll have the system wired together shortly, so you can see how it is all supposed to work. Then it is a matter of improving the genetic algorithm. We can look at afl-fuzz.c for inspiration. |
This prevents it from trying to access thread local storage before it has set up thread local storage, particularly when code coverage instrumentation is enabled.
`-fno-sanitize=function` must come after `-fsanitize=undefined` or it has no effect.
@@ -263,6 +264,14 @@ pub const list = list: { | |||
.illegal_outside_function = true, | |||
}, | |||
}, | |||
.{ | |||
"@disableInstrumentation", |
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.
Should we add this built-in to the langref?
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.
i think it makes sense to leave out of the langref but include in the spec
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.
Should we add this built-in to the langref?
Yes of course
i think it makes sense to leave out of the langref but include in the spec
This not Meghan's Opinion Tracker. Provide technical arguments, or keep your opinion to yourself.
Initial implementation of #20702.
-ffuzz
and-fno-fuzz
CLI arguments.combined with TSAN and UBSAN.
empty zig file.
that have requested fuzzing.
sanitizer coverage.
builtin.fuzz is true.
@disableInstrumentation
builtin and use it in start code to prevent using threadlocal variables before threadlocal storage is initialized.Current status:
I'm putting this up because I think it will already benefit zig-afl-kit mainly because of making
std.mem.eql
optimize for fuzzing when-ffuzz
is selected. Probably also because of theoptforfuzzing
attribute on all the functions in the LLVM backend.Closes #5484. See #20702 for follow-up issues.
Next steps: