sysconf(_SC_PAGESIZE) is called very early, during sanitizer init and
any instrumented code (a wrapper/interceptor will likely be instrumented)
calling back to sanitizer before init is done will most surely crash.
Details
Diff Detail
- Build Status
Buildable 4846 Build 4846: arc lint + arc unit
Event Timeline
So is this to avoid potential future crashes when sysconf gets an interceptor? Can we instead call REAL(sysconf)?
No, it's intended to bypass interceptors defined in other libraries. REAL(sysconf) bypasses our own interceptor and REAL(...) functions are not ready yet at the moment we call sysconf(_SC_PAGESIZE) first time anyway.
If that something that sanitizers need to protect against, then it sounds like we should do a direct syscall instead. Dlsym is also a complicated thing and it can call other possibly-intercepted functions, e.g. malloc or pthread_mutex_lock, IIRC.
Anyway, I'm not opposing this change, I was just curious why we need it.
sysconf for the page size is not a syscall on most platforms.
On linux it reads auxv, which could also be done through getauxval() on glibc and bionic, and, it appears, freebsd. But in bionic it is broken.
It appears that dlsym() also cannot be used during init stage, this code path calls into instrumented code as well under some sanitizers. PTAL.
LGTM
test/sanitizer_common/TestCases/Linux/sysconf_interceptor_bypass_test.cc | ||
---|---|---|
18 ↗ | (On Diff #92357) | Does the test fail w/o this change? |