briansmith / ring

Safe, fast, small crypto using Rust
Other
3.69k stars 697 forks source link

Fuzzing in OSS-Fuzz, linking issue #1915

Open zi0Black opened 8 months ago

zi0Black commented 8 months ago

Hi, I am having some headaches with a project on OSS-Fuzz which imports Ring. I wondered if there are specific flags to pass in CXXFLAGS required to correctly link with libFuzzer?

I noticed that there is a placeholder for Ring in OSS-Fuzz: https://github.com/google/oss-fuzz/pull/1930, so I thought maybe someone tried to build in that environment /cc @briansmith

Small snippet of the error generated by the linker:

 = note: ld.lld: error: undefined symbol: __sanitizer_cov_8bit_counters_init                                                                       
          >>> referenced by aes_nohw.c                                                                                                              
          >>>               aes_nohw.o:(sancov.module_ctor_8bit_counters) in archive /src/aptos-core/testsuite/fuzzer/target/release/deps/libring-63
c758c7847ddbd8.rlib                                                                                                                                 

          ld.lld: error: undefined symbol: __sanitizer_cov_pcs_init                                                                                 
          >>> referenced by aes_nohw.c                                                                                                              
          >>>               aes_nohw.o:(sancov.module_ctor_8bit_counters) in archive /src/aptos-core/testsuite/fuzzer/target/release/deps/libring-63
c758c7847ddbd8.rlib                                                                                                                                 

          ld.lld: error: undefined symbol: __asan_init                                                                                              
          >>> referenced by aes_nohw.c                                                                                                              
          >>>               aes_nohw.o:(asan.module_ctor) in archive /src/aptos-core/testsuite/fuzzer/target/release/deps/libring-63c758c7847ddbd8.r
lib                                                                                                                                                 
          >>> referenced by montgomery.c                                                                                                            
          >>>               montgomery.o:(asan.module_ctor) in archive /src/aptos-core/testsuite/fuzzer/target/release/deps/libring-63c758c7847ddbd8
.rlib                                                                                                                                               
          >>> referenced by montgomery_inv.c                                                                                                        
          >>>               montgomery_inv.o:(asan.module_ctor) in archive /src/aptos-core/testsuite/fuzzer/target/release/deps/libring-63c758c7847d
dbd8.rlib                                                                                                                                           
          >>> referenced 11 more times

Clearing out OSS-Fuzz 'CXXFLAGS' and 'CFLAGS' so that all C/CPP code isn't instrumented is a workaround, but it's dirty, and I find other fixes to build other dependencies. So I'm hoping to make this work in a more elegant way too.