Skip to content
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

llvm_mode LTO instrumentlist and persistent tests fails on Alpine Linux riscv64 #2064

Open
ncopa opened this issue Apr 24, 2024 · 7 comments

Comments

@ncopa
Copy link

ncopa commented Apr 24, 2024

IMPORTANT

AFLplusplus-4.20c

Describe the bug
On alpine linux, riscv64 the LTO llvm_mode test fails.

[*] Testing: LTO llvm_mode
[!] LTO llvm_mode failed   
[!] llvm_mode LTO instrumentlist feature compilation failed
[!] llvm_mode LTO persistent mode feature compilation failed

To Reproduce

On an Alpin eLinux riscv64 machine run:

        export PATH="$PATH:/usr/lib/llvm17/bin"
        export NO_NYX=1
        export AFL_NO_X86=1
        export LLVM_LTO=1
        make PREFIX=/usr all

        CFLAGS= CXXFLAGS= make AFL_NO_X86=1 test

Expected behavior
Test passes

Screen output/Screenshots

[*] Testing: LTO llvm_mode
[!] LTO llvm_mode failed
[!] llvm_mode LTO instrumentlist feature compilation failed
[!] llvm_mode LTO persistent mode feature compilation failed

Additional context

This was discovered on riscv64.

algitbot pushed a commit to alpinelinux/aports that referenced this issue Apr 24, 2024
llvm LTO test fails on riscv64 and it seems not to be any easy way to
skip it for a given architecture. Lets skip all for now.

AFLplusplus/AFLplusplus#2064
@vanhauser-thc
Copy link
Member

does this work? clang -flto -o test test-instr.c

@vanhauser-thc
Copy link
Member

@ncopa ?

@vanhauser-thc
Copy link
Member

Also I see in the changelog in the redhat repo:

        # i686 support was silently removed in AFL++ 4.10c

this is not true. maybe there was a bug we were not aware of, but it is working perfectly fine in 4.20+ (as you can test by using our aflplusplus/aflplusplus docker container on docker hub).

the riscv or os390 are likely packaging errors in redhat, otherwise bugs in llvm itself. I do not see how this can be a bug in afl++.

lastly, if you have a redhat for arm64, except outdated afl-gcc/afl-clang instrumentation, everything is working there too.

@ncopa
Copy link
Author

ncopa commented May 7, 2024

does this work? clang -flto -o test test-instr.c

No because there exist a test directory. But I if output it to test1 it does work.

ncopa-edge-riscv64:~/aports/community/afl++/src/AFLplusplus-4.20c$ clang -flto -o test test-instr.c 
/usr/bin/ld: cannot open output file test: Is a directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ncopa-edge-riscv64:~/aports/community/afl++/src/AFLplusplus-4.20c$ clang -flto -o test1 test-instr.c
ncopa-edge-riscv64:~/aports/community/afl++/src/AFLplusplus-4.20c$

There is also a utils/persistent_mode/test-instr.c:

ncopa-edge-riscv64:~/aports/community/afl++/src/AFLplusplus-4.20c$ cd utils/persistent_mode/
ncopa-edge-riscv64:~/aports/community/afl++/src/AFLplusplus-4.20c/utils/persistent_mode$ clang -flto -o test test-instr.c 
test-instr.c:22:1: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
   22 | __AFL_FUZZ_INIT();
      | ^
      | int
test-instr.c:31:3: error: call to undeclared function '__AFL_INIT'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   31 |   __AFL_INIT();
      |   ^
test-instr.c:32:24: error: use of undeclared identifier '__AFL_FUZZ_TESTCASE_BUF'
   32 |   unsigned char *buf = __AFL_FUZZ_TESTCASE_BUF;
      |                        ^
test-instr.c:34:10: error: call to undeclared function '__AFL_LOOP'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
   34 |   while (__AFL_LOOP(UINT_MAX)) {  // if you have 100% stability
      |          ^
test-instr.c:36:24: error: use of undeclared identifier '__AFL_FUZZ_TESTCASE_LEN'
   36 |     unsigned int len = __AFL_FUZZ_TESTCASE_LEN;
      |                        ^

But I assume you meant the toplevel file.

@ncopa
Copy link
Author

ncopa commented May 7, 2024

Also I see in the changelog in the redhat repo:

I suppose you should mention that to redhat developers.

lastly, if you have a redhat for arm64,

Unfortunately, I have more than enough work with shipping Alpine releases so I can't help you fix redhat. Sorry.

@vanhauser-thc
Copy link
Member

ah I mixed up two different issues, sorry.

so clang -flto works, that rules out that the llvm installation is incomplete (the usual problem).

do you have a link to the build log of afl++ on riscv? I have never used alpine, so ...

and is there an easy way how I could reproduce/debug this? (I have no riscv linux)

@vanhauser-thc
Copy link
Member

I experience a problem on Debian riscv64 where LTO is not working, but that stems from two issues - first their binutils do not provide ld.gold and second the llvm-18 from apt.llvm.org is not providing libLLVMgold.so.

My guess is that is similar here.
what does this output?
AFL_PASSTHROUGH=1 ./afl-clang-fast -flto=full -o test-instr test-instr.c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants