[PATCH] D54076: Add interceptors for the sysctl(3) API family from NetBSD

Vitaly Buka via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 7 16:29:37 PST 2018


vitalybuka requested changes to this revision.
vitalybuka added inline comments.
This revision now requires changes to proceed.


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7283
+    if (oldlenp)
+      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, oldlenp, sizeof(*oldlenp));
+    if (oldp && oldlenp)
----------------
Here and below
```
if (oldlenp) {
      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, oldlenp, sizeof(*oldlenp));
      if (oldp)
          COMMON_INTERCEPTOR_WRITE_RANGE(ctx, oldp, *oldlenp);
}
```


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7332
+    if (name && namelenp)
+      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, name, *namelenp);
+  }
----------------
*namelenp * sizeof(*name) ?


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7334
+  }
+  if (cname && csz) {
+    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, csz, sizeof(*csz));
----------------
this should be as well under "if (!res) {"



================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7336
+    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, csz, sizeof(*csz));
+    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cname, *csz);
+  }
----------------
```
if (csz) {
  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, csz, sizeof(*csz));
  if (cname)
     COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cname, *csz);
}
```


================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7355
+    if (name && namelenp)
+      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, name, *namelenp);
+  }
----------------
should this be
```
*namelenp * sizeof(*name)
```
?



> The number of	elements in the mib array is given by the location specified by sizep before the call, and that location gives the number of entries copied	after a suc-    cessful call.





================
Comment at: lib/sanitizer_common/sanitizer_common_interceptors.inc:7376
+
+INTERCEPTOR(void *, asysctlbyname, const char *sname, SIZE_T *len) {
+  void *ctx;
----------------
> The asysctl() and asysctlbyname() functions are wrappers for sysctl() and
> sysctlbyname().  They return memory allocated with malloc(3) and resize
> the buffer in a loop until all data fits.

if so we should not intercept asysctl and  asysctlbyname


Repository:
  rL LLVM

https://reviews.llvm.org/D54076





More information about the llvm-commits mailing list