pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

compiler-rt-netbsd: Initial libkvm support in sanitizers



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Tue Jan 9 22:23:26 2018 +0100
Changeset:	8d0f480c9a418b028743e3373d18d5a712ba7a8f

Modified Files:
	compiler-rt-netbsd/distinfo
	compiler-rt-netbsd/patches/patch-cmake_config-ix.cmake
	compiler-rt-netbsd/patches/patch-include_sanitizer_netbsd__syscall__hooks.h
	compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_CMakeLists.txt
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__interceptors__ioctl.inc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__syscalls.inc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
	compiler-rt-netbsd/patches/patch-utils_generate__netbsd__ioctls.awk
	compiler-rt-netbsd/patches/patch-utils_generate__netbsd__syscalls.awk
Added Files:
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h

Log Message:
compiler-rt-netbsd: Initial libkvm support in sanitizers

MSan with ps(1) breaks now in non-kvm(3) code.

$ ./ps
Uninitialized bytes in __interceptor_strcmp at offset 0 inside [0x71a000000008, 5)
==7197==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x7c5d7db0b373  (/lib/libc.so.12+0x10b373)
    #1 0x7c5d7db0bdf9 in _sysctlgetmibinfo (/lib/libc.so.12+0x10bdf9)
    #2 0x7c5d7daaa359 in _sysctlbyname (/lib/libc.so.12+0xaa359)
    #3 0x7c5d7daa65b6 in getdevmajor (/lib/libc.so.12+0xa65b6)
    #4 0x7c5d7daa0083  (/lib/libc.so.12+0xa0083)
    #5 0x7c5d7ea06ccd in pthread_once (/usr/lib/libpthread.so.1+0x6ccd)
    #6 0x7c5d7daa00cb in devname_r (/lib/libc.so.12+0xa00cb)
    #7 0x7c5d7daa0309 in __devname50 (/lib/libc.so.12+0xa0309)
    #8 0x49875e in tname /public/src.git/bin/ps/print.c:725:32
    #9 0x4a9bdf in main /public/src.git/bin/ps/ps.c:467:5
    #10 0x419ffa in ___start (/public/src.git/bin/ps/./ps+0x419ffa)

SUMMARY: MemorySanitizer: use-of-uninitialized-value (/lib/libc.so.12+0x10b373)
Exiting

Sponsored by <The NetBSD Foundation>

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=8d0f480c9a418b028743e3373d18d5a712ba7a8f

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 compiler-rt-netbsd/distinfo                        |  21 +-
 .../patches/patch-cmake_config-ix.cmake            |   2 +-
 ...atch-include_sanitizer_netbsd__syscall__hooks.h |   2 +-
 .../patches/patch-lib_msan_msan__interceptors.cc   |   2 +-
 .../patch-lib_sanitizer__common_CMakeLists.txt     |   4 +-
 ...zer__common_sanitizer__common__interceptors.inc | 257 ++++++++++++++++++++-
 ...mmon_sanitizer__netbsd__interceptors__ioctl.inc |   2 +-
 ...nitizer__common_sanitizer__netbsd__syscalls.inc |   2 +-
 ...zer__common_sanitizer__platform__interceptors.h |  11 +
 ...r__common_sanitizer__platform__limits__netbsd.h |  46 +++-
 .../patch-utils_generate__netbsd__ioctls.awk       |   2 +-
 .../patch-utils_generate__netbsd__syscalls.awk     |   2 +-
 12 files changed, 332 insertions(+), 21 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 17caf8efc8..566e085b0b 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -1,26 +1,27 @@
 $NetBSD: distinfo,v 1.35 2015/09/11 01:21:57 tnn Exp $
 
-SHA1 (patch-cmake_config-ix.cmake) = b863945f74990e30c6ae902953334f1324efc06d
+SHA1 (patch-cmake_config-ix.cmake) = dfc7a195cb774cc13cb495387781d600e16c82d9
 SHA1 (patch-include_CMakeLists.txt) = b6f2713b7e5337aed542442936b6f747efe0a607
-SHA1 (patch-include_sanitizer_netbsd__syscall__hooks.h) = 8104f06ec9e1b7646e2906767ef557a2e7d089da
+SHA1 (patch-include_sanitizer_netbsd__syscall__hooks.h) = 9b4900e42388d560e75b35a071b35dd75a70fe62
 SHA1 (patch-lib_asan_asan__interceptors.cc) = ea4005ce02775060ff52af76d568c450892067b5
 SHA1 (patch-lib_esan_esan__interceptors.cpp) = a7103ca053e92a810c87c593262bb386f3d02606
 SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = 38ca750154dfc9843a56748078235824b772a147
 SHA1 (patch-lib_hwasan_hwasan__interceptors.cc) = 45fd48ae7bb21878432f925dea7af8d9f0ee0b02
-SHA1 (patch-lib_msan_msan__interceptors.cc) = 77f8abc8dfdc5212b7991fd6e9a724990aa4f8cb
+SHA1 (patch-lib_msan_msan__interceptors.cc) = 92ed308e84b0845f15110e0167f265ed5cea2580
 SHA1 (patch-lib_msan_msan__linux.cc) = d75d7587071a9e7a3f6a08a3008af55319e62cab
-SHA1 (patch-lib_sanitizer__common_CMakeLists.txt) = e6f0ecddd946981e9a4b76fd5325f56c2343edcd
-SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = 0837dfc7937d93b5811eae751d754006daba26dc
+SHA1 (patch-lib_sanitizer__common_CMakeLists.txt) = fcbf2987ccab5258fe760aef6ef47bd97e0e0b2c
+SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = e4ec25bef1effa4649f9989ea74a997315ba368d
 SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors__ioctl.inc) = 231f519a0564aa69d746a7f0bbee1b1aeed927a7
 SHA1 (patch-lib_sanitizer__common_sanitizer__internal__defs.h) = 126424635f89439e89371a57754232082e2290c6
-SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd__interceptors__ioctl.inc) = 0050635f92a9fa772303d3cddebd01f1f386c44a
-SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd__syscalls.inc) = 460fc4a35f689d0fba6579e22de6c78aa0d252f7
+SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd__interceptors__ioctl.inc) = c351daa33f782bfe644f7b8517618a12328c7996
+SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd__syscalls.inc) = 35fae2ad655097b5dc019f6e3e82ed415f92db07
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = 063eb96ea0d41c9359df4c347c4da08a995f0702
 SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc) = 206f075ce7fa3445abd7207dfc96c615dd841c13
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h) = 390589d3adec17df72fa71f2bf0a3b32d387d167
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h) = 0275ddf3c60d43d793f656a76c5cccc46f28116a
 SHA1 (patch-lib_scudo_scudo__platform.h) = 6b07d34d5f1209c7f1bf21fdf0cda5cbe88b802f
 SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = 4fbaa64e3f8d28cdbab6783c296dfd31cecb45a5
 SHA1 (patch-test_asan_lit.cfg) = 121fb6db88a17b8b588a40ee022a9a219d84493f
 SHA1 (patch-test_lsan_lit.common.cfg) = 10dc251f80efb96d015a22c740dc20b1843b9a11
 SHA1 (patch-test_scudo_lit.cfg) = 171f340505f7c87f74a7814b9c4d12d7fcbc5690
-SHA1 (patch-utils_generate__netbsd__ioctls.awk) = 369b26ac9c66803045bf3ca01b7e476819da15f7
-SHA1 (patch-utils_generate__netbsd__syscalls.awk) = bb702f4239fef65813bef4732edd8912eeaef681
+SHA1 (patch-utils_generate__netbsd__ioctls.awk) = da4a60c43df5cd9b022ff108ac5120486f76a1d2
+SHA1 (patch-utils_generate__netbsd__syscalls.awk) = 9a767008efc35b0b509287e6c2ccc14f49446323
diff --git a/compiler-rt-netbsd/patches/patch-cmake_config-ix.cmake b/compiler-rt-netbsd/patches/patch-cmake_config-ix.cmake
index ad59a3c3ff..0e10ad2312 100644
--- a/compiler-rt-netbsd/patches/patch-cmake_config-ix.cmake
+++ b/compiler-rt-netbsd/patches/patch-cmake_config-ix.cmake
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- cmake/config-ix.cmake.orig	2017-12-21 18:53:10.000000000 +0000
+--- cmake/config-ix.cmake.orig	2018-01-08 15:33:13.000000000 +0000
 +++ cmake/config-ix.cmake
 @@ -542,7 +542,7 @@ else()
  endif()
diff --git a/compiler-rt-netbsd/patches/patch-include_sanitizer_netbsd__syscall__hooks.h b/compiler-rt-netbsd/patches/patch-include_sanitizer_netbsd__syscall__hooks.h
index 3c2500f8cb..4f626b6071 100644
--- a/compiler-rt-netbsd/patches/patch-include_sanitizer_netbsd__syscall__hooks.h
+++ b/compiler-rt-netbsd/patches/patch-include_sanitizer_netbsd__syscall__hooks.h
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- include/sanitizer/netbsd_syscall_hooks.h.orig	2017-12-29 22:46:24.550628204 +0000
+--- include/sanitizer/netbsd_syscall_hooks.h.orig	2018-01-09 21:22:24.945820046 +0000
 +++ include/sanitizer/netbsd_syscall_hooks.h
 @@ -0,0 +1,4730 @@
 +//===-- netbsd_syscall_hooks.h --------------------------------------------===//
diff --git a/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc b/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
index 7389c228db..7b23c629c8 100644
--- a/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
+++ b/compiler-rt-netbsd/patches/patch-lib_msan_msan__interceptors.cc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/msan/msan_interceptors.cc.orig	2018-01-08 15:33:13.616083625 +0000
+--- lib/msan/msan_interceptors.cc.orig	2018-01-08 15:33:13.000000000 +0000
 +++ lib/msan/msan_interceptors.cc
 @@ -33,6 +33,7 @@
  #include "sanitizer_common/sanitizer_libc.h"
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_CMakeLists.txt b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_CMakeLists.txt
index 65e18ceb32..2c4d6e9922 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_CMakeLists.txt
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_CMakeLists.txt
@@ -1,8 +1,8 @@
 $NetBSD$
 
---- lib/sanitizer_common/CMakeLists.txt.orig	2017-12-04 19:21:19.000000000 +0000
+--- lib/sanitizer_common/CMakeLists.txt.orig	2018-01-08 15:33:13.000000000 +0000
 +++ lib/sanitizer_common/CMakeLists.txt
-@@ -116,6 +116,7 @@ set(SANITIZER_HEADERS
+@@ -119,6 +119,7 @@ set(SANITIZER_HEADERS
    sanitizer_list.h
    sanitizer_mac.h
    sanitizer_mutex.h
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
index 9178b8379f..840c701cc5 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_common_interceptors.inc.orig	2017-12-21 18:53:10.000000000 +0000
+--- lib/sanitizer_common/sanitizer_common_interceptors.inc.orig	2018-01-08 15:33:14.000000000 +0000
 +++ lib/sanitizer_common/sanitizer_common_interceptors.inc
 @@ -1703,6 +1703,7 @@ FORMAT_INTERCEPTOR_IMPL(__isoc99_snprint
  
@@ -10,3 +10,258 @@ $NetBSD$
  INTERCEPTOR(int, ioctl, int d, unsigned long request, ...) {
    // We need a frame pointer, because we call into ioctl_common_[pre|post] which
    // can trigger a report and we need to be able to unwind through this
+@@ -6452,6 +6453,246 @@ INTERCEPTOR(wchar_t *, wcsncat, wchar_t 
+ #define INIT_WCSCAT
+ #endif
+ 
++#if SANITIZER_INTERCEPT_KVM
++INTERCEPTOR(int, kvm_close, struct __sanitizer_kvm *kd) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_close, kd);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_close)(kd);
++}
++
++INTERCEPTOR(int, kvm_dump_header, struct __sanitizer_kvm *kd, bool (*write_buf)(void*,void*,uptr), void *cookie, int dumpsize) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_dump_header, kd, write_buf, cookie, dumpsize);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_dump_header)(kd, write_buf, cookie, dumpsize);
++}
++
++INTERCEPTOR(int, kvm_dump_inval, struct __sanitizer_kvm *kd) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_dump_inval, kd);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_dump_inval)(kd);
++}
++
++INTERCEPTOR(int, kvm_dump_mkheader, struct __sanitizer_kvm *kd, OFF_T dump_off) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_dump_mkheader, kd, dump_off);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_dump_mkheader)(kd, dump_off);
++}
++
++INTERCEPTOR(int, kvm_dump_wrtheader, struct __sanitizer_kvm *kd, __sanitizer_FILE *fp, int dumpsize) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_dump_wrtheader, kd, fp, dumpsize);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_dump_wrtheader)(kd, fp, dumpsize);
++}
++
++INTERCEPTOR(char **, kvm_getargv, struct __sanitizer_kvm *kd, void *kp, int nchr) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getargv, kd, kp, nchr);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_getargv)(kd, kp, nchr);
++}
++
++INTERCEPTOR(char **, kvm_getargv2, struct __sanitizer_kvm *kd, void *kp, int nchr) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getargv2, kd, kp, nchr);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_getargv2)(kd, kp, nchr);
++}
++
++INTERCEPTOR(char **, kvm_getenvv, struct __sanitizer_kvm *kd, void *kp, int nchr) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getenvv, kd, kp, nchr);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_getenvv)(kd, kp, nchr);
++}
++
++INTERCEPTOR(char **, kvm_getenvv2, struct __sanitizer_kvm *kd, void *kp, int nchr) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getenvv2, kd, kp, nchr);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_getenvv2)(kd, kp, nchr);
++}
++
++INTERCEPTOR(char *, kvm_geterr, struct __sanitizer_kvm *kd) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_geterr, kd);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_geterr)(kd);
++}
++
++INTERCEPTOR(int, kvm_getloadavg, struct __sanitizer_kvm *kd, double loadavg[], int nelem) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getloadavg, kd, loadavg, nelem);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_getloadavg)(kd, loadavg, nelem);
++}
++
++INTERCEPTOR(char *, kvm_getfiles, struct __sanitizer_kvm *kd, int op, int arg, int *cnt) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getfiles, kd, op, arg, cnt);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_getfiles)(kd, op, arg, cnt);
++}
++
++INTERCEPTOR(char *, kvm_getkernelname, struct __sanitizer_kvm *kd) {
++  void *ctx;
++  char *name;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getkernelname, kd);
++  name = REAL(kvm_getkernelname)(kd);
++  if (name)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, name, REAL(strlen)(name) + 1);
++  return name;
++}
++
++INTERCEPTOR(void *, kvm_getlwps, struct __sanitizer_kvm *kd, int pid, unsigned long paddr, uptr esize, int *cnt) {
++  void *ctx;
++  void *res;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getlwps, kd, pid, paddr, esize, cnt);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  res = REAL(kvm_getlwps)(kd, pid, paddr, esize, cnt);
++  if (res) {
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cnt, sizeof(int));
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, res, esize * (*cnt));
++  }
++  return res;
++}
++
++INTERCEPTOR(void *, kvm_getproc2, struct __sanitizer_kvm *kd, int op, int arg, uptr esize, int *cnt) {
++  void *ctx;
++  void *res;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getproc2, kd, op, arg, esize, cnt);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  res = REAL(kvm_getproc2)(kd, op, arg, esize, cnt);
++  if (res) {
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, cnt, sizeof(int));
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, res, esize * (*cnt));
++  }
++  return res;
++}
++
++INTERCEPTOR(void *, kvm_getprocs, struct __sanitizer_kvm *kd, int op, int arg, int *cnt) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_getprocs, kd, op, arg, cnt);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_getprocs)(kd, op, arg, cnt);
++}
++
++INTERCEPTOR(int, kvm_nlist, struct __sanitizer_kvm *kd, void *nl) {
++  void *ctx;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_nlist, kd, nl);
++  if (kd)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return REAL(kvm_nlist)(kd, nl);
++}
++
++INTERCEPTOR(struct __sanitizer_kvm *, kvm_open, char *uf, char *mf, char *sf, int flag, char *program) {
++  void *ctx;
++  struct __sanitizer_kvm *kd;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_open, uf, mf, sf, flag, program);
++  if (uf)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, uf, REAL(strlen)(uf) + 1);
++  if (mf)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, mf, REAL(strlen)(mf) + 1);
++  if (sf)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, sf, REAL(strlen)(sf) + 1);
++  kd = REAL(kvm_open)(uf, mf, sf, flag, program);
++  if (kd)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return kd;
++}
++
++INTERCEPTOR(struct __sanitizer_kvm *, kvm_openfiles, char *uf, char *mf, char *sf, int flag, char *program) {
++  void *ctx;
++  struct __sanitizer_kvm *kd;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_openfiles, uf, mf, sf, flag, program);
++  if (uf)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, uf, REAL(strlen)(uf) + 1);
++  if (mf)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, mf, REAL(strlen)(mf) + 1);
++  if (sf)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, sf, REAL(strlen)(sf) + 1);
++  kd = REAL(kvm_openfiles)(uf, mf, sf, flag, program);
++  if (kd)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, kd, sizeof(struct __sanitizer_kvm));
++  return kd;
++}
++
++INTERCEPTOR(uptr, kvm_read, struct __sanitizer_kvm *kd, unsigned long kva, void *buf, uptr len) {
++  void *ctx;
++  uptr res;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_read, kd, kva, buf, len);
++  res = REAL(kvm_read)(kd, kva, buf, len);
++  if (res)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, res);
++  return res;
++}
++
++INTERCEPTOR(uptr, kvm_uread, struct __sanitizer_kvm *kd, unsigned long uva, void *buf, uptr len) {
++  void *ctx;
++  uptr res;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_uread, kd, uva, buf, len);
++  res = REAL(kvm_uread)(kd, uva, buf, len);
++  if (res)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, buf, res);
++  return res;
++}
++
++INTERCEPTOR(uptr, kvm_write, struct __sanitizer_kvm *kd, unsigned long kva, void *buf, uptr len) {
++  void *ctx;
++  uptr res;
++  COMMON_INTERCEPTOR_ENTER(ctx, kvm_write, kd, kva, buf, len);
++  res = REAL(kvm_uread)(kd, kva, buf, len);
++  if (res)
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, buf, res);
++  return res;
++}
++
++#define INIT_KVM \
++  COMMON_INTERCEPT_FUNCTION(kvm_close); \
++  COMMON_INTERCEPT_FUNCTION(kvm_dump_header); \
++  COMMON_INTERCEPT_FUNCTION(kvm_dump_inval); \
++  COMMON_INTERCEPT_FUNCTION(kvm_dump_mkheader); \
++  COMMON_INTERCEPT_FUNCTION(kvm_dump_wrtheader); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getargv); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getargv2); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getenvv); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getenvv2); \
++  COMMON_INTERCEPT_FUNCTION(kvm_geterr); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getfiles); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getkernelname); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getloadavg); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getlwps); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getproc2); \
++  COMMON_INTERCEPT_FUNCTION(kvm_getprocs); \
++  COMMON_INTERCEPT_FUNCTION(kvm_nlist); \
++  COMMON_INTERCEPT_FUNCTION(kvm_open); \
++  COMMON_INTERCEPT_FUNCTION(kvm_openfiles); \
++  COMMON_INTERCEPT_FUNCTION(kvm_read); \
++  COMMON_INTERCEPT_FUNCTION(kvm_uread); \
++  COMMON_INTERCEPT_FUNCTION(kvm_write)
++#else
++#define INIT_KVM
++#endif
++
+ static void InitializeCommonInterceptors() {
+   static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
+   interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap();
+@@ -6663,6 +6904,7 @@ static void InitializeCommonInterceptors
+   INIT_GETLOADAVG;
+   INIT_WCSLEN;
+   INIT_WCSCAT;
++  INIT_KVM;
+ 
+ #if SANITIZER_NETBSD
+   COMMON_INTERCEPT_FUNCTION(__libc_mutex_lock);
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__interceptors__ioctl.inc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__interceptors__ioctl.inc
index ed6221036d..6d0a2de351 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__interceptors__ioctl.inc
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__interceptors__ioctl.inc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_netbsd_interceptors_ioctl.inc.orig	2017-12-29 22:46:24.553501326 +0000
+--- lib/sanitizer_common/sanitizer_netbsd_interceptors_ioctl.inc.orig	2018-01-09 21:22:24.948571630 +0000
 +++ lib/sanitizer_common/sanitizer_netbsd_interceptors_ioctl.inc
 @@ -0,0 +1,1490 @@
 +//===-- sanitizer_common_interceptors_ioctl.inc -----------------*- C++ -*-===//
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__syscalls.inc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__syscalls.inc
index 87f43bc34d..be64d517d7 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__syscalls.inc
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__netbsd__syscalls.inc
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- lib/sanitizer_common/sanitizer_netbsd_syscalls.inc.orig	2017-12-29 22:46:24.554391054 +0000
+--- lib/sanitizer_common/sanitizer_netbsd_syscalls.inc.orig	2018-01-09 21:22:24.949458680 +0000
 +++ lib/sanitizer_common/sanitizer_netbsd_syscalls.inc
 @@ -0,0 +1,3793 @@
 +//===-- sanitizer_common_syscalls.inc ---------------------------*- C++ -*-===//
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
new file mode 100644
index 0000000000..46d2cb5709
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
@@ -0,0 +1,11 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_platform_interceptors.h.orig	2018-01-08 15:33:13.000000000 +0000
++++ lib/sanitizer_common/sanitizer_platform_interceptors.h
+@@ -432,4 +432,6 @@
+ #define SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION (!SI_WINDOWS && SI_NOT_FUCHSIA)
+ #define SANITIZER_INTERCEPT_BSD_SIGNAL SI_ANDROID
+ 
++#define SANITIZER_INTERCEPT_KVM SI_NETBSD
++
+ #endif  // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
index 462e99a25d..ed0b2d3e66 100644
--- a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h
@@ -184,7 +184,51 @@ $NetBSD$
  struct __sanitizer_wordexp_t {
    uptr we_wordc;
    char **we_wordv;
-@@ -374,185 +462,1712 @@ struct __sanitizer_ifconf {
+@@ -350,6 +438,43 @@ struct __sanitizer_ifconf {
+   } ifc_ifcu;
+ };
+ 
++
++struct __sanitizer_kvm {
++  const char *program;
++  char *errp;
++  char errbuf[2048]; // _POSIX2_LINE_MAX
++  int pmfd;
++  int vmfd;
++  int swfd;
++  int nlfd;
++  char alive;
++  void *procbase;
++  void *procbase2;
++  void *lwpbase;
++  uptr procbase_len;
++  uptr procbase2_len;
++  uptr lwpbase_len;
++  unsigned long usrstack;
++  unsigned long min_uva, max_uva;
++  int nbpg;
++  char *swapspc;
++  char *argspc, *argbuf;
++  uptr argspc_len;
++  char **argv;
++  int argc;
++  void *kcore_hdr;
++  uptr cpu_dsize;
++  void *cpu_data;
++  u64 dump_off;
++  void *vmst;
++  void *vm_page_buckets;
++  int vm_page_hash_mask;
++  uptr fdalign;
++  void *iobuf;
++  uptr iobufsz;
++  char kernelname[1024];
++};
++
+ #define IOC_NRBITS 8
+ #define IOC_TYPEBITS 8
+ #define IOC_SIZEBITS 14
+@@ -374,185 +499,1712 @@ struct __sanitizer_ifconf {
  #define IOC_NR(nr) (((nr) >> IOC_NRSHIFT) & IOC_NRMASK)
  #define IOC_SIZE(nr) (((nr) >> IOC_SIZESHIFT) & IOC_SIZEMASK)
  
diff --git a/compiler-rt-netbsd/patches/patch-utils_generate__netbsd__ioctls.awk b/compiler-rt-netbsd/patches/patch-utils_generate__netbsd__ioctls.awk
index 957f938464..bca8f6fa3f 100644
--- a/compiler-rt-netbsd/patches/patch-utils_generate__netbsd__ioctls.awk
+++ b/compiler-rt-netbsd/patches/patch-utils_generate__netbsd__ioctls.awk
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- utils/generate_netbsd_ioctls.awk.orig	2017-12-29 22:46:24.556731939 +0000
+--- utils/generate_netbsd_ioctls.awk.orig	2018-01-09 21:22:24.951931928 +0000
 +++ utils/generate_netbsd_ioctls.awk
 @@ -0,0 +1,755 @@
 +#!/usr/bin/awk -f
diff --git a/compiler-rt-netbsd/patches/patch-utils_generate__netbsd__syscalls.awk b/compiler-rt-netbsd/patches/patch-utils_generate__netbsd__syscalls.awk
index 3466e5e2e8..bd7f3185c3 100644
--- a/compiler-rt-netbsd/patches/patch-utils_generate__netbsd__syscalls.awk
+++ b/compiler-rt-netbsd/patches/patch-utils_generate__netbsd__syscalls.awk
@@ -1,6 +1,6 @@
 $NetBSD$
 
---- utils/generate_netbsd_syscalls.awk.orig	2017-12-29 22:46:24.557432667 +0000
+--- utils/generate_netbsd_syscalls.awk.orig	2018-01-09 21:22:24.952625369 +0000
 +++ utils/generate_netbsd_syscalls.awk
 @@ -0,0 +1,2989 @@
 +#!/usr/bin/awk -f


Home | Main Index | Thread Index | Old Index