Skip to content

Conversation

@andyross
Copy link
Contributor

@andyross andyross commented Jul 3, 2024

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:

  1. 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.

  2. 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)

@andyross
Copy link
Contributor Author

andyross commented Jul 3, 2024

An attempt at a root cause fix for the regression blocking #9278

@aescolar this is a SOF patch, but please review

@andyross andyross requested a review from cujomalainey July 3, 2024 19:05
@marc-hb marc-hb added bug Something isn't working as expected P1 Blocker bugs or important features labels Jul 3, 2024
@marc-hb marc-hb changed the title platform/posix: Port fuzzer to upstream "native_sim" board [SKIP SOF-TEST] platform/posix: Port fuzzer to upstream "native_sim" board Jul 3, 2024
Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

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

Thanks for the very quick response!

To be on the safe side, did you try the EOF_TEST_PATCH test?

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>
@andyross
Copy link
Contributor Author

andyross commented Jul 3, 2024

did you try the EOF_TEST_PATCH test?

Didn't noticed that. I have now, it works fine and definitely blows up when needed.

@kv2019i kv2019i merged commit 2688f63 into thesofproject:main Jul 4, 2024
@kv2019i
Copy link
Collaborator

kv2019i commented Jul 4, 2024

FYI - fuzzer tests passing in mainline PR testing now https://github.com/thesofproject/sof/actions/runs/9790387872

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected P1 Blocker bugs or important features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants