pkgsrc-WIP-changes archive

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

compiler-rt-netbsd: A draft patch for getpeername(2)



Module Name:	pkgsrc-wip
Committed By:	Kamil Rytarowski <n54%gmx.com@localhost>
Pushed By:	kamil
Date:		Sun Jun 17 16:46:43 2018 +0200
Changeset:	898518603103387f0cdf0cb5a95ae80bc890342a

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__limits__netbsd.h

Log Message:
compiler-rt-netbsd: A draft patch for getpeername(2)

Based on a patch from Christos.

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

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 | 46 ++++++++++++++++++++--
 ...r__common_sanitizer__platform__limits__netbsd.h | 11 +++++-
 3 files changed, 54 insertions(+), 7 deletions(-)

diffs:
diff --git a/compiler-rt-netbsd/distinfo b/compiler-rt-netbsd/distinfo
index d83a66c04b..bdac77f2ce 100644
--- a/compiler-rt-netbsd/distinfo
+++ b/compiler-rt-netbsd/distinfo
@@ -10,13 +10,13 @@ SHA1 (patch-lib_fuzzer_tests_CMakeLists.txt) = e2e0e397eaf148df329f2c25ca9185f57
 SHA1 (patch-lib_interception_interception.h) = a7f97b191769c846be27e17430bbe39435976642
 SHA1 (patch-lib_msan_msan__interceptors.cc) = bfb0d6ba97382a26d54141c3e4cc0c0f584178a1
 SHA1 (patch-lib_msan_msan__linux.cc) = dc3431b7606f3e1c106ffd2568ab4a6c77321731
-SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = 936726187211482b05426455cd8d500e2efcbedc
+SHA1 (patch-lib_sanitizer__common_sanitizer__common__interceptors.inc) = f9dce4a714af9644b862c3d705646c4e52923825
 SHA1 (patch-lib_sanitizer__common_sanitizer__internal__defs.h) = 9ffcb3ae5ccfcb99d842efe55f6d698cd2e02846
 SHA1 (patch-lib_sanitizer__common_sanitizer__linux.cc) = 83636321cef6a17281a27e2ed3dd1b71e5429a6a
 SHA1 (patch-lib_sanitizer__common_sanitizer__linux__libcdep.cc) = ac04d9b155c7281dde98741b7f79714e98c2bbc3
 SHA1 (patch-lib_sanitizer__common_sanitizer__platform__interceptors.h) = cdf1461c641ca6f9e13f3d3319170e4aad76e367
 SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.cc) = b15685e72af975a7e6ca300034193475fc02fa88
-SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h) = a97a6f9405c5c69510a7562d875ee892bea4f4a8
+SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__netbsd.h) = b818a42be1119ef41c45eb448749fd95b6ff7fd3
 SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__posix.cc) = 95fef4690641063603db1b1dcb00c610948142f1
 SHA1 (patch-lib_sanitizer__common_sanitizer__platform__limits__posix.h) = b2c0149501713bc16b657344b8b9a3a0ce48b107
 SHA1 (patch-lib_sanitizer__common_sanitizer__procmaps__bsd.cc) = 8b629840ff7f56c670d322a9dbbdf7e33ce90cb5
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 60777d4e02..b4c578448a 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
@@ -23,7 +23,45 @@ $NetBSD$
  extern const unsigned short *_ctype_tab_;
  extern const short *_toupper_tab_;
  extern const short *_tolower_tab_;
-@@ -3345,14 +3352,14 @@ INTERCEPTOR(INTMAX_T, strtoimax, const c
+@@ -3060,17 +3067,28 @@ INTERCEPTOR(int, sendmmsg, int fd, struc
+ #endif
+ 
+ #if SANITIZER_INTERCEPT_GETPEERNAME
+-INTERCEPTOR(int, getpeername, int sockfd, void *addr, unsigned *addrlen) {
++INTERCEPTOR(int, getpeername, int sockfd, void *addr,
++  __sanitizer_socklen_t *addrlen) {
+   void *ctx;
+   COMMON_INTERCEPTOR_ENTER(ctx, getpeername, sockfd, addr, addrlen);
+-  unsigned addr_sz;
+-  if (addrlen) addr_sz = *addrlen;
+-  // FIXME: under ASan the call below may write to freed memory and corrupt
+-  // its metadata. See
+-  // https://github.com/google/sanitizers/issues/321.
+-  int res = REAL(getpeername)(sockfd, addr, addrlen);
+-  if (!res && addr && addrlen)
+-    COMMON_INTERCEPTOR_WRITE_RANGE(ctx, addr, Min(addr_sz, *addrlen));
++  __sanitizer_socklen_t taddrlen;
++  if (addrlen)
++    taddrlen = *addrlen;
++  else
++    taddrlen = 0;
++  __sanitizer_sockaddr_storage taddr;
++  int res = REAL(getpeername)(sockfd, addr ? &taddr : 0,
++                              addrlen ? &taddrlen : 0);
++  if (!res) {
++    if (addr && addrlen)
++      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, addr, taddrlen);
++    if (addrlen)
++      COMMON_INTERCEPTOR_WRITE_RANGE(ctx, addrlen, sizeof(*addrlen));
++  }
++  if (addr && addrlen)
++    memcpy(addr, &taddr, taddrlen);
++  if (addrlen)
++    *addrlen = taddrlen;
+   return res;
+ }
+ #define INIT_GETPEERNAME COMMON_INTERCEPT_FUNCTION(getpeername);
+@@ -3345,14 +3363,14 @@ INTERCEPTOR(INTMAX_T, strtoimax, const c
    return res;
  }
  
@@ -40,7 +78,7 @@ $NetBSD$
    StrtolFixAndCheck(ctx, nptr, endptr, real_endptr, base);
    return res;
  }
-@@ -4240,7 +4247,7 @@ INTERCEPTOR(int, fstatfs64, int fd, void
+@@ -4240,7 +4258,7 @@ INTERCEPTOR(int, fstatfs64, int fd, void
  #endif
  
  #if SANITIZER_INTERCEPT_STATVFS
@@ -49,7 +87,7 @@ $NetBSD$
    void *ctx;
    COMMON_INTERCEPTOR_ENTER(ctx, statvfs, path, buf);
    if (path) COMMON_INTERCEPTOR_READ_RANGE(ctx, path, REAL(strlen)(path) + 1);
-@@ -7234,6 +7241,1606 @@ INTERCEPTOR(struct __sanitizer_netent *,
+@@ -7234,6 +7252,1606 @@ INTERCEPTOR(struct __sanitizer_netent *,
  #define INIT_NETENT
  #endif
  
@@ -1656,7 +1694,7 @@ $NetBSD$
  static void InitializeCommonInterceptors() {
    static u64 metadata_mem[sizeof(MetadataHashMap) / sizeof(u64) + 1];
    interceptor_metadata_map = new((void *)&metadata_mem) MetadataHashMap();
-@@ -7483,6 +9090,30 @@ static void InitializeCommonInterceptors
+@@ -7483,6 +9101,30 @@ static void InitializeCommonInterceptors
    INIT_TTYENT;
    INIT_PROTOENT;
    INIT_NETENT;
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 a398ac8f69..cb3c949af6 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
@@ -26,7 +26,7 @@ $NetBSD$
  struct __sanitizer_ptrace_io_desc {
    int piod_op;
    void *piod_offs;
-@@ -2194,6 +2204,71 @@ extern unsigned IOCTL_SNDCTL_DSP_SILENCE
+@@ -2194,6 +2204,80 @@ extern unsigned IOCTL_SNDCTL_DSP_SILENCE
  
  extern const int si_SEGV_MAPERR;
  extern const int si_SEGV_ACCERR;
@@ -95,6 +95,15 @@ $NetBSD$
 +};
 +
 +extern const int setvbuf_bufsiz;
++
++struct __sanitizer_sockaddr_storage {
++  u8 ss_len;
++  u8 ss_family;
++  char *__ss_pad1[sizeof(u64) - 2];
++  u64 __ss_align;
++  char __ss_pad2[128 - 2 - (sizeof(u64) - 2) - sizeof(u64)];
++};
++
  }  // namespace __sanitizer
  
  #define CHECK_TYPE_SIZE(TYPE) \


Home | Main Index | Thread Index | Old Index