pkgsrc-WIP-changes archive

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

compiler-rt-netbsd: Add initial support for intercepting ioctl(3)



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Wed Jan 10 06:12:39 2018 +0100
Changeset:	74a98387982118c53b873a871b62f5e6c37c70f6

Modified Files:
	compiler-rt-netbsd/distinfo
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__common__interceptors.inc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__platform__interceptors.h
Added Files:
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
	compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__freebsd.cc

Log Message:
compiler-rt-netbsd: Add initial support for intercepting ioctl(3)

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=74a98387982118c53b873a871b62f5e6c37c70f6

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

diffstat:
 compiler-rt-netbsd/distinfo                        |  6 ++--
 ...zer__common_sanitizer__common__interceptors.inc | 42 ++++++++++++++++++++--
 ...patch-lib_sanitizer__common_sanitizer__linux.cc | 17 +++++++++
 ...zer__common_sanitizer__platform__interceptors.h |  3 +-
 ...nitizer__common_sanitizer__procmaps__freebsd.cc | 14 ++++++++
 5 files changed, 77 insertions(+), 5 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index 135a7a36b7..b34cc38536 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -10,14 +10,16 @@ SHA1 (patch-lib_hwasan_hwasan__interceptors.cc) = 45fd48ae7bb21878432f925dea7af8
 SHA1 (patch-lib_msan_msan__interceptors.cc) = 92ed308e84b0845f15110e0167f265ed5cea2580
 SHA1 (patch-lib_msan_msan__linux.cc) = d75d7587071a9e7a3f6a08a3008af55319e62cab
 SHA1 (patch-lib_sanitizer__common_CMakeLists.txt) = fcbf2987ccab5258fe760aef6ef47bd97e0e0b2c
-SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = dd3cff382af879365cf78f2539f1789bbbfd3f17
+SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = b1b91d58b48c6709e653efd4ca0842ade3cde274
 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__linux.cc) = 77b7e2d6b177166c4f83bbd550d0e5bacf9a4cc0
 SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd__interceptors__ioctl.inc) = 0ed3a4a6467c73247e646e2f7ac8f5ea9e3f4da7
 SHA1 (patch-lib_sanitizer__common_sanitizer__netbsd__syscalls.inc) = 6d94bc705f62aeeda363f19a6f073738d3bae3b0
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = f4e69e0e3a27f763bd4064d34eec1aaa965b79b8
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = 6ad9d650ccd9cf4c7ea2afc22fa96bed4d10f249
 SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc) = ae99697d5331e6b05f26f74c48119f5cacd4c4e0
 SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h) = 19490197ac6d275d777f5b79b96c25aa6d4e3d71
+SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__freebsd.cc) = c34f35173466e8fd6d65c550f303fdede9e47bec
 SHA1 (patch-lib_scudo_scudo__platform.h) = 6b07d34d5f1209c7f1bf21fdf0cda5cbe88b802f
 SHA1 (patch-lib_tsan_rtl_tsan__interceptors.cc) = 4fbaa64e3f8d28cdbab6783c296dfd31cecb45a5
 SHA1 (patch-test_asan_lit.cfg) = 121fb6db88a17b8b588a40ee022a9a219d84493f
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 09595d7b09..56f88b5331 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
@@ -18,7 +18,7 @@ $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 +6454,304 @@ INTERCEPTOR(wchar_t *, wcsncat, wchar_t 
+@@ -6452,6 +6454,341 @@ INTERCEPTOR(wchar_t *, wcsncat, wchar_t 
  #define INIT_WCSCAT
  #endif
  
@@ -319,16 +319,54 @@ $NetBSD$
 +#else
 +#define INIT_DEVNAME
 +#endif
++
++#if SANITIZER_INTERCEPT_SYSCTL
++INTERCEPTOR(int, sysctl, int *name, unsigned int namelen, void *oldp, uptr *oldlenp, void *newp, uptr newlen) {
++  void *ctx;
++  int res;
++  COMMON_INTERCEPTOR_ENTER(ctx, sysctl, name, namelen, oldp, oldlenp, newp, newlen);
++  if (name) {
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, name, namelen * sizeof(*name));
++  }
++  if (newp) {
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, newp, newlen);
++  }
++  res = REAL(sysctl)(name, namelen, oldp, oldlenp, newp, newlen);
++  if (!res)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, oldp, *oldlenp);
++  return res;
++}
++
++INTERCEPTOR(int, sysctlbyname, char *sname, void *oldp, uptr *oldlenp, void *newp, uptr newlen) {
++  void *ctx;
++  int res;
++  COMMON_INTERCEPTOR_ENTER(ctx, sysctlbyname, sname, oldp, oldlenp, newp, newlen);
++  if (sname) {
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, sname, REAL(strlen)(sname) + 1);
++  }
++  res = REAL(sysctlbyname)(sname, oldp, oldlenp, newp, newlen);
++  if (!res)
++    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, oldp, *oldlenp);
++  return res;
++}
++
++#define INIT_SYSCTL \
++  COMMON_INTERCEPT_FUNCTION(sysctl); \
++  COMMON_INTERCEPT_FUNCTION(sysctlbyname)
++#else
++#define INIT_SYSCTL
++#endif
 +
  static void InitializeCommonInterceptors() {
    static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
    interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap();
-@@ -6663,6 +6963,8 @@ static void InitializeCommonInterceptors
+@@ -6663,6 +7000,9 @@ static void InitializeCommonInterceptors
    INIT_GETLOADAVG;
    INIT_WCSLEN;
    INIT_WCSCAT;
 +  INIT_KVM;
 +  INIT_DEVNAME;
++  INIT_SYSCTL;
  
  #if SANITIZER_NETBSD
    COMMON_INTERCEPT_FUNCTION(__libc_mutex_lock);
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
new file mode 100644
index 0000000000..cf8a72915c
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__linux.cc
@@ -0,0 +1,17 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_linux.cc.orig	2018-01-10 05:12:01.286320517 +0000
++++ lib/sanitizer_common/sanitizer_linux.cc
+@@ -89,6 +89,7 @@ extern char **environ;  // provided by c
+ 
+ #if SANITIZER_NETBSD
+ #include <limits.h>  // For NAME_MAX
++#define sysctl _sysctl
+ #include <sys/sysctl.h>
+ extern char **environ;  // provided by crt1
+ #include <sys/exec.h>
+@@ -1898,4 +1899,3 @@ bool GetRandom(void *buffer, uptr length
+ 
+ #endif  // SANITIZER_FREEBSD || SANITIZER_LINUX || SANITIZER_NETBSD ||
+         // SANITIZER_SOLARIS
+-
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
index ed12047af2..0d0307f4e5 100644
--- 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
@@ -2,11 +2,12 @@ $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,7 @@
+@@ -432,4 +432,8 @@
  #define SANITIZER_INTERCEPT_SIGNAL_AND_SIGACTION (!SI_WINDOWS && SI_NOT_FUCHSIA)
  #define SANITIZER_INTERCEPT_BSD_SIGNAL SI_ANDROID
  
 +#define SANITIZER_INTERCEPT_KVM SI_NETBSD
 +#define SANITIZER_INTERCEPT_DEVNAME SI_NETBSD
++#define SANITIZER_INTERCEPT_SYSCTL SI_NETBSD
 +
  #endif  // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H
diff --git a/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__freebsd.cc b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__freebsd.cc
new file mode 100644
index 0000000000..02b61bd570
--- /dev/null
+++ b/compiler-rt-netbsd/patches/patch-lib_sanitizer__common_sanitizer__procmaps__freebsd.cc
@@ -0,0 +1,14 @@
+$NetBSD$
+
+--- lib/sanitizer_common/sanitizer_procmaps_freebsd.cc.orig	2018-01-10 05:12:07.886871696 +0000
++++ lib/sanitizer_common/sanitizer_procmaps_freebsd.cc
+@@ -19,6 +19,9 @@
+ #include "sanitizer_procmaps.h"
+ 
+ #include <unistd.h>
++#if SANITIZER_NETBSD
++#define sysctl _sysctl // Use an internal symbol to omit the interceptor
++#endif
+ #include <sys/sysctl.h>
+ #if SANITIZER_FREEBSD
+ #include <sys/user.h>


Home | Main Index | Thread Index | Old Index