[PATCH] Moar string interceptors: strstr, strcasestr, strcspn, strpbrk

Yury Gribov tetra2005 at gmail.com
Wed Dec 24 12:16:00 PST 2014


================
Comment at: lib/msan/msan_interceptors.cc:96
@@ -95,1 +95,3 @@
 
+#define CHECK_UNPOISONED_STRING(x, n)                           \
+  CHECK_UNPOISONED((x),                                         \
----------------
glider wrote:
> Am I right that you're only using this macro with n=0?
I think Maria wanted added n to anticipate future work on conservative length checking.

================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:4759
@@ -4631,2 +4758,3 @@
   COMMON_INTERCEPTOR_ENTER_NOIGNORE(ctx, dlopen, filename, flag);
+  COMMON_INTERCEPTOR_READ_STRING(ctx, filename, 0);
   void *res = REAL(dlopen)(filename, flag);
----------------
glider wrote:
> Chrome's net_unittests crash for me with the following stacktrace:
> 
> ```
> Program received signal SIGSEGV, Segmentation fault.
> __sanitizer::internal_strlen (s=s at entry=0x0)
>     at /usr/local/google/ssd/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_libc.cc:155
> 155	  while (s[i]) i++;
> (gdb) bt
> #0  __sanitizer::internal_strlen (s=s at entry=0x0)
>     at /usr/local/google/ssd/llvm/projects/compiler-rt/lib/sanitizer_common/sanitizer_libc.cc:155
> #1  0x000000000059f080 in __interceptor_dlopen (filename=filename at entry=0x0, 
>     flag=flag at entry=1)
>     at /usr/local/google/ssd/llvm/projects/compiler-rt/lib/asan/../sanitizer_common/sanitizer_common_interceptors.inc:4759
> #2  0x00007ffff5167ec2 in pr_FindSymbolInProg (
>     name=0x7ffff517f29f "nspr_use_zone_allocator") at prmem.c:98
> #3  0x00007ffff5167fad in _PR_InitZones () at prmem.c:154
> ...
> ```
> 
> We'll need to add yet another dlopen() test once we figure out what's wrong.
Looks like COMMON_INTERCEPTOR_READ_STRING needs a check for NULL.

================
Comment at: test/asan/Unit/lit.site.cfg.in:27
@@ +26,2 @@
+# Disable strict str checks in unit tests
+config.environment['ASAN_OPTIONS'] = 'strict_str=false'
----------------
glider wrote:
> Why do you need this line?
AFAIR unit tests are not strict_str-safe.

http://reviews.llvm.org/D6056

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list