pkgsrc-WIP-changes archive

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

compiler-rt-netbsd: Teach sanitizers about strlcpy(3)/strlcat(3)



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Wed Jan 10 06:46:43 2018 +0100
Changeset:	9ca80ad5ef646c42ed819117ffa7eb6083ad720e

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

Log Message:
compiler-rt-netbsd: Teach sanitizers about strlcpy(3)/strlcat(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=9ca80ad5ef646c42ed819117ffa7eb6083ad720e

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

diffstat:
 compiler-rt-netbsd/distinfo                        |  4 +--
 ...zer__common_sanitizer__common__interceptors.inc | 38 ++++++++++++++++++++--
 ...zer__common_sanitizer__platform__interceptors.h |  3 +-
 3 files changed, 40 insertions(+), 5 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index b34cc38536..6650edef19 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -10,13 +10,13 @@ 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) = b1b91d58b48c6709e653efd4ca0842ade3cde274
+SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = ca08a1f6bae8fa092afccee97eac22dc75c13f36
 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) = 6ad9d650ccd9cf4c7ea2afc22fa96bed4d10f249
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = 1706f836831956e690963178591c3f6737d495cc
 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
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 56f88b5331..aa9972e9d6 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,341 @@ INTERCEPTOR(wchar_t *, wcsncat, wchar_t 
+@@ -6452,6 +6454,374 @@ INTERCEPTOR(wchar_t *, wcsncat, wchar_t 
  #define INIT_WCSCAT
  #endif
  
@@ -356,17 +356,51 @@ $NetBSD$
 +#else
 +#define INIT_SYSCTL
 +#endif
++
++#if SANITIZER_INTERCEPT_STRLCPY
++INTERCEPTOR(uptr, strlcpy, char *dst, char *src, uptr size) {
++  void *ctx;
++  uptr res;
++  COMMON_INTERCEPTOR_ENTER(ctx, strlcpy, dst, src, size);
++  if (src) {
++    uptr len = REAL(strnlen)(src, size);
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, len >= size ? size : len + 1);
++  }
++  res = REAL(strlcpy)(dst, src, size);
++  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, REAL(strlen)(dst));
++  return res;
++}
++
++INTERCEPTOR(uptr, strlcat, char *dst, char *src, uptr size) {
++  void *ctx;
++  uptr res;
++  COMMON_INTERCEPTOR_ENTER(ctx, strlcat, dst, src, size);
++  if (src) {
++    uptr len = REAL(strnlen)(src, size);
++    COMMON_INTERCEPTOR_READ_RANGE(ctx, src, len >= size ? size : len + 1);
++  }
++  res = REAL(strlcat)(dst, src, size);
++  COMMON_INTERCEPTOR_WRITE_RANGE(ctx, dst, REAL(strlen)(dst));
++  return res;
++}
++#define INIT_STRLCPY \
++  COMMON_INTERCEPT_FUNCTION(strlcpy); \
++  COMMON_INTERCEPT_FUNCTION(strlcat)
++#else
++#define INIT_STRLCPY
++#endif
 +
  static void InitializeCommonInterceptors() {
    static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
    interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap();
-@@ -6663,6 +7000,9 @@ static void InitializeCommonInterceptors
+@@ -6663,6 +7033,10 @@ static void InitializeCommonInterceptors
    INIT_GETLOADAVG;
    INIT_WCSLEN;
    INIT_WCSCAT;
 +  INIT_KVM;
 +  INIT_DEVNAME;
 +  INIT_SYSCTL;
++  INIT_STRLCPY;
  
  #if SANITIZER_NETBSD
    COMMON_INTERCEPT_FUNCTION(__libc_mutex_lock);
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 0d0307f4e5..7c037078c0 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,12 +2,13 @@ $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,8 @@
+@@ -432,4 +432,9 @@
  #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
++#define SANITIZER_INTERCEPT_STRLCPY SI_NETBSD
 +
  #endif  // #ifndef SANITIZER_PLATFORM_INTERCEPTORS_H


Home | Main Index | Thread Index | Old Index