[SKIP SOF-TEST] platform/posix: Port fuzzer to upstream "native_sim" board#9280
Merged
kv2019i merged 1 commit intothesofproject:mainfrom Jul 4, 2024
Merged
[SKIP SOF-TEST] platform/posix: Port fuzzer to upstream "native_sim" board#9280kv2019i merged 1 commit intothesofproject:mainfrom
kv2019i merged 1 commit intothesofproject:mainfrom
Conversation
Contributor
Author
aescolar
reviewed
Jul 3, 2024
marc-hb
approved these changes
Jul 3, 2024
Collaborator
marc-hb
left a comment
There was a problem hiding this comment.
Thanks for the very quick response!
To be on the safe side, did you try the EOF_TEST_PATCH test?
aescolar
reviewed
Jul 3, 2024
The older native_posix board is being deprecated, use native_sim, which is the future-proof API. Mostly just swap the board target and change the C API names. Note the NATIVE_SIMULATOR_IF decoaration on LLVMFuzzerTestOneInput(): that forces the function to be included in the first-stage zephyr.elf link (otherwise it would be dropped as Zephyr/SOF itself doesn't reference the entry point) and to be visible as a global symbol to the libfuzzer instrumentation layer. Signed-off-by: Andy Ross <andyross@google.com>
Contributor
Author
Didn't noticed that. I have now, it works fine and definitely blows up when needed. |
marc-hb
approved these changes
Jul 3, 2024
kv2019i
approved these changes
Jul 4, 2024
Collaborator
|
FYI - fuzzer tests passing in mainline PR testing now https://github.com/thesofproject/sof/actions/runs/9790387872 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The older native_posix board is being deprecated, use native_sim, which is the future-proof API. In theory this should be as simple as just swapping the board name at the west level, but there are a few changes:
The C API is broadly identical between the two, modulo some prefix renaming.
Unfortunately linkage is more of a hassle, as the fuzzing framework inverts the sense of "entry point" and causes some trouble with the way native_sim does its two-stage link. We have to add some hackery:
Make sure the fuzz entry point doesn't get dropped during the initial zephyr.elf link, as it calls OS/sim layer and not the reverse.
Force it to be a global symbol in the final stage, so it can be seen by the code in libfuzzer that needs to call it (normally all Zephyr-side symbols are forced to be library-private to prevent collisions with the global Linux/glibc namespace environment)