-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
fuzz-introspector needs ldflags but projects do not always use #7540
Comments
I suspect that's because LDFLAGS has never been documented at https://google.github.io/oss-fuzz/getting-started/new-project-guide/#Requirements. Other than that OSS-Fuzz has always used CFLAGS to pass linker options around (which in turn led to issues like mesonbuild/meson#4542 and mesonbuild/meson#8345). It would be great if those LDFLAGS issues could be fixed generally once and for all. Until then I'm not sure passing LDFLAGS is a good idea considering that it works just because build systems like meson get around those issues. |
Just to clarify what I was trying to say is that OSS-Fuzz should either keep passing linker flags via CFLAGS or start passing all the linker flags via LDFLAGS correctly. I don't think for example meson would (or should) support putting the linker flags in both CFLAGS and LDFLAGS and work that around every time it breaks. |
Judging by 05be069 it was decided that LDFLAGS should be passed there. Since it effectively means that for example the systemd build system has to support four different modes of building the fuzz targets I wonder if it's possible to turn the fuzz-introspector off there? I'm not sure it's maintainable at this point. |
Thanks @evverx -- 05be069 may be temporary depending on what we decide here. I think you're view on using CFLAGS is valid, however, I think it may have some complications with projects that do not pass on CFLAGS onto linking, e.g. which is likely the case for many projects that link without using CC. I ran into several builds that will fail if we don't have it in LDFLAGS, and often the failure happens when shared libraries are linked before reaching the fuzzing compilation part of the build process. I'll investigate more in-depth the consequences of doing it by way of CFLAGS in the near future though. Regardless of what we decide here then I think projects should be able to opt out of fuzz-introspector. |
I just checked the fuzz-introspector build status for systemd @evverx and it looks to be passing atm? You can see the build status for fuzz-introspector on oss-fuzz.com and build status |
I think most projects should be compatible with CFLAGS and CC. Otherwise they would fail to compile with afl++ and/or coverage. My understanding is that
It does but it isn't officially supported by |
My understanding of why afl++ works is because afl++ deploys its own linker (it is an issue on fuzz-introspector to use a similar approach ossf/fuzz-introspector#57 , but am not sure if it will come with unintended consequences though). Am not entirely sure about the details of the coverage though. Interesting with autocon/automake -- I think if we can push it into CFLAGS that would be the best -- again, will take a look at this in more detail in the near future. |
I think this is kind of hidden behind CC and CXX so if projects use CC, CXX, CFLAGS and CXXFLAGS as documented in https://google.github.io/oss-fuzz/getting-started/new-project-guide/#Requirements they should automagically be buildable with AFL. There have been issues like #5691 though where it wasn't clear what failed and why but as long as it's possible to temporarily turn it off to let OSS-Fuzz keep fuzzing projects it's safe to say that it's just a minor inconvenience. |
The use of LDFLAGS does not really follow the policy of OSS-Fuzz. This moves the linker flags into the sanitizer flags. Ref: google#7540 (comment)
* fuzz-introspector: remove use of LDFLAGS The use of LDFLAGS does not really follow the policy of OSS-Fuzz. This moves the linker flags into the sanitizer flags. Ref: #7540 (comment)
The set up was switched to pass the linker flags by way of cflags in #7573 I went through the OSS-Fuzz logs to identify those that went from success builds to failed builds (16th April success, 17th April fail), and got the following list:
I skimmed through some of the logs and it looks like some parts of the builds do not use lto for the compiling/linking which causes some undefined references. As far as I could tell this often happens because of some third party dependencies that are compiled from source. However, will have to look at them in more detail. |
@DavidKorczynski having taken a look at #7573 a bit closer I think
With
|
In theory it should fix the projects where |
|
Looking at the logs I have to admit I'm puzzled as to how it worked with LDFLAGS. Some projects appear to default to |
Moves -fuse-ld=gold to compile flags and removes -flto from linker flags. Should fix a number of the projects google#7540 (comment) Ref: google#7540 (comment) Ref: google#7540 (comment)
@DavidKorczynski FWIW I think if that PR fixes most of the projects it should be good to go (as long as fuzz-introspector build failures aren't reported on monorail and the badge doesn't turn yellow/red). |
Yeah I think so too - I wanted to give the devs from the meson team a bit of time to reply to your message before merging, however, we can always carry on the conversation after so will make it ready for review tomorrow -- it would be nice to merge to see the impact on all the projects |
I think currently it's possible to for example set the linker to |
I think another option would be to bring LDFLAGS back but all the projects where LDFLAGS isn't used would have to be patched by analogy with #7538 (which isn't perfect either). |
Yeah, I think at the moment I prefer the approach in #7583 because it follows the oss-fuzz way of doing things more, and using the previous approach will require modifying the remaining projects to be like #7538 may be undesired. #7583 is not ideal though and will probably require some hacky things in other projects -- I say let's merge #7583 in and see how the list of projects react in terms of how many build/fail |
Moves -fuse-ld=gold to compile flags and removes -flto from linker flags. Should fix a number of the projects #7540 (comment) Ref: #7540 (comment) Ref: #7540 (comment)
* fuzz-introspector: remove use of LDFLAGS The use of LDFLAGS does not really follow the policy of OSS-Fuzz. This moves the linker flags into the sanitizer flags. Ref: google#7540 (comment)
Moves -fuse-ld=gold to compile flags and removes -flto from linker flags. Should fix a number of the projects google#7540 (comment) Ref: google#7540 (comment) Ref: google#7540 (comment)
Fuzz Introspector sets
LDFLAGS
:oss-fuzz/infra/base-images/base-builder/compile
Line 150 in 2fe1b08
however, far from all projects are using the LDFLAGS provided by OSS-Fuzz and it's causing many of those to fail building with fuzz introspector, (one example is: #7538 but there are more). I am trying to find out what's the preferred solution for passing LDFLAGS to builds.
There are traces in the code for LDFLAGS previously being set by OSS-Fuzz:
oss-fuzz/infra/base-images/base-builder/Dockerfile
Lines 123 to 124 in 2fe1b08
but it seems like this was on the way out? As I see it there are some options
FUZZER_LDFLAGS
from above). This requires builds to use the LDFLAGS provided by OSS-Fuzz which may be a bit annoying -- I can do a run over the projects and get as many as possible. This would work but adds another requirement to builds.LIB_FUZZING_ENGINE
, although I'm not sure I like this solution a whole lot.LDFLAGS
(same as option (1) but will not set empty for non fuzz introspector builds) from OSS-Fuzz and perhaps some code as follows (e.g. icu: set LDFLAGS to fix fuzz-introspector #7538) :The text was updated successfully, but these errors were encountered: