Source-Changes-D archive

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

Re: CVS commit: src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common



On 2016/06/09 23:37, Christos Zoulas wrote:
Module Name:	src
Committed By:	christos
Date:		Thu Jun  9 14:37:06 UTC 2016

Modified Files:
	src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common:
	    sanitizer_linux.cc sanitizer_syscall_generic.inc

Log Message:
Fix syscall argument passing from Ryn Okuyama (with minor changes; hope I did
not make it worse :-)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 \
    src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc
cvs rdiff -u -r1.2 -r1.3 \
    src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc

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

Thank you very much for refinement and commit my patch. Let me add
few comments:

* internal_ptrace()

   As usage of ptrace(2) is quite different for Linux and us, we need
   additional work to get it working. At this moment, this function is
   used only within "#if SANITIZER_LINUX && defined(__x86_64__)" block
   in sanitizer_stoptheworld_linux_libcdep.cc. This is why I disabled
   it in my previous patch. I've added a brief comment.

* internal_wait4()

   The last argument of wait4(2) should be NULL, not 0. This may
   cause troubles for LP64.

* internal_getdents()

   Sorry, my previous patch for this function was completely wrong.
   But your version is also incomplete:

     - structure dirent is different for Linux and us; we need to
       declare linux_dirent in the same way as our native dirent.

     - The last argument of getdents(2) should be size_t (aka uptr),
       not u_int.

* sanitizer_syscall_generic.inc

   Sorry, this is also my careless mistake. Two #if blocks should
   be combined to avoid possible redefinition of internal_syscall.

Thanks,
Rin
====
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc.orig	2016-06-10 06:14:51.159752456 +0900
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_linux.cc	2016-06-10 09:16:19.561985484 +0900
@@ -56,6 +56,7 @@
  extern char **environ;  // provided by crt1
  #endif  // SANITIZER_FREEBSD
  #if SANITIZER_NETBSD
+#include <limits.h>     // for NAME_MAX
  #include <sys/sysctl.h>
  extern char **environ;  // provided by crt1
  #endif  // SANITIZER_NETBSD
@@ -491,6 +492,17 @@
  }
// ----------------- sanitizer_linux.h
+#if SANITIZER_NETBSD
+// struct dirent is different for Linux and us. At this moment, we use only
+// d_fileno (Linux call this d_ino), d_reclen, and d_name.
+struct linux_dirent {
+  u64  d_ino;     // d_fileno
+  u16  d_reclen;
+  u16  d_namlen;  // not used
+  u8   d_type;    // not used
+  char d_name[NAME_MAX + 1];
+};
+#else
  // The actual size of this structure is specified by d_reclen.
  // Note that getdents64 uses a different structure format. We only provide the
  // 32-bit syscall here.
@@ -505,10 +517,18 @@
    unsigned short     d_reclen;
    char               d_name[256];
  };
+#endif
// Syscall wrappers.
  uptr internal_ptrace(int request, int pid, void *addr, void *data) {
  #if SANITIZER_NETBSD
+// XXX We need additional work for ptrace:
+//   - for request, we use PT_FOO whereas Linux uses PTRACE_FOO
+//   - data is int for us, but void * for Linux
+//   - Linux sometimes uses data in the case where we use addr instead
+// At this moment, this function is used only within
+// "#if SANITIZER_LINUX && defined(__x86_64__)" block in
+// sanitizer_stoptheworld_linux_libcdep.cc.
    return internal_syscall_ptr(SYSCALL(ptrace), request, pid, (uptr)addr,
                            (uptr)data);
  #else
@@ -518,8 +538,13 @@
  }
uptr internal_waitpid(int pid, int *status, int options) {
+#if SANITIZER_NETBSD
+  return internal_syscall(SYSCALL(wait4), pid, status, options,
+                          NULL /* rusage */);
+#else
    return internal_syscall(SYSCALL(wait4), pid, (uptr)status, options,
                            0 /* rusage */);
+#endif
  }
uptr internal_getpid() {
@@ -531,7 +556,9 @@
  }
uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int count) {
-#if SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
+#if SANITIZER_NETBSD
+  return internal_syscall(SYSCALL(getdents), fd, dirp, (uptr)count);
+#elif SANITIZER_USES_CANONICAL_LINUX_SYSCALLS
    return internal_syscall(SYSCALL(getdents64), fd, (uptr)dirp, count);
  #else
    return internal_syscall(SYSCALL(getdents), fd, (uptr)dirp, count);
--- src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc.orig	2016-06-10 07:09:34.310819833 +0900
+++ src/external/gpl3/gcc/dist/libsanitizer/sanitizer_common/sanitizer_syscall_generic.inc	2016-06-10 07:09:51.201896163 +0900
@@ -38,9 +38,7 @@
  # else
  #  define internal_syscall_ptr	syscall
  # endif
-#endif
-
-#if (SANITIZER_FREEBSD && defined(__x86_64__))
+#elif (SANITIZER_FREEBSD && defined(__x86_64__))
  # define internal_syscall __syscall
  # else
  # define internal_syscall syscall


Home | Main Index | Thread Index | Old Index