Don't hard code the page in FuzzerUtil.h, this breaks on
e.g. LoongArch which defaults to a 16KiB page size.
Details
- Reviewers
vitalybuka SixWeining xen0n xry111 MaskRay XiaodongLoong tangyouling - Group Reviewers
Restricted Project - Commits
- rGbaa1488c1693: [fuzzer] Don't hard-code page size in FuzzerUtil.h
rGcb9f2de2e802: Revert "[fuzzer] Don't hard-code page size in FuzzerUtil.h"
rGa2b677e81537: [fuzzer] Don't hard-code page size in FuzzerUtil.h
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This change makes sense on LoongArch, and should cause no behavioral change on 4KiB-page platforms like X86, but more testing on other architectures (e.g. AArch64 systems with 16KiB or 64KiB pages) would be welcome.
I'd leave the approval for other sanitizer reviewers.
getpagesize is not recommended. Linux can use getauxval(AT_PAGESZ).
HandleInline8bitCountersInit is called once for an executable/DSO, so a function call isn't too expensive, but better to avoid calling it 2 times for RoundUpByPage/RoundDownByPage, and possibly multiple times in HandleInline8bitCountersInit.
@kcc made https://reviews.llvm.org/rG6fd4d8ab9c6e6ddb67df5d822f855de980d1eea6 in 2019, noted down that it is "Needed for future optimization."
It seems that enabled is always true and OneFullPage is unused. Is there a pending optimization which has not landed?
Can it be defined as follows?
#if SANITIZER_USE_GETAUXVAL #include <sys/auxv.h> #endif inline size_t PageSize() { #if SANITIZER_USE_GETAUXVAL return getauxval(AT_PAGESZ); #else return 4096; #endif }
It still needs to be like GetPageSize() in sanitizer_linux.cpp?
#if !SANITIZER_ANDROID uptr GetPageSize() { #if SANITIZER_LINUX && (defined(__x86_64__) || defined(__i386__)) && \ defined(EXEC_PAGESIZE) return EXEC_PAGESIZE; #elif SANITIZER_FREEBSD || SANITIZER_NETBSD // Use sysctl as sysconf can trigger interceptors internally. int pz = 0; uptr pzl = sizeof(pz); int mib[2] = {CTL_HW, HW_PAGESIZE}; int rv = internal_sysctl(mib, 2, &pz, &pzl, nullptr, 0); CHECK_EQ(rv, 0); return (uptr)pz; #elif SANITIZER_USE_GETAUXVAL return getauxval(AT_PAGESZ); #else return sysconf(_SC_PAGESIZE); // EXEC_PAGESIZE may not be trustworthy. #endif } #endif // !SANITIZER_ANDROID
In the previous snapshot initialization was not thread safe.
and we don't want to inline initialization all over the program
and rename is unnececary
Hi, this has broken the lldb bots on Darwin systems; there is no <sys/auxv.h> there. Can you please revert or replace it with a has_include(sys/auxv.h) etc and fall back to the old hardcoded value?
I reverted this change in cb9f2de2e80292c0445c99be754fcc78b94b0f16 to unblock the CI test bots.
Yes, this broke tests on Darwin systems. I'm sorry for that.
Instead, I prefer to use the sysconf(_SC_PAGESIZE) function which is more available on most systems including Darwin systems to obtain the page size.
I have submitted the revised changes in https://reviews.llvm.org/D151530.
sanitizer_common is not used by fuzzer, so no SANITIZER_USE_GETAUXVAL