[compiler-rt] r192695 - tsan: move kernel struct definition from sanitizer_linux.h to sanitizer_platform_limits_posix.h

Alexey Samsonov samsonov at google.com
Tue Oct 15 06:19:48 PDT 2013


On Tue, Oct 15, 2013 at 4:57 PM, Dmitry Vyukov <dvyukov at google.com> wrote:

> Author: dvyukov
> Date: Tue Oct 15 07:57:59 2013
> New Revision: 192695
>
> URL: http://llvm.org/viewvc/llvm-project?rev=192695&view=rev
> Log:
> tsan: move kernel struct definition from sanitizer_linux.h to
> sanitizer_platform_limits_posix.h
>
>
> Modified:
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
>     compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h
>
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
>
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
>
> Modified:
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc?rev=192695&r1=192694&r2=192695&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc
> (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_common_syscalls.inc
> Tue Oct 15 07:57:59 2013
> @@ -37,7 +37,6 @@
>  #if SANITIZER_LINUX
>
>  #include "sanitizer_libc.h"
> -#include "sanitizer_linux.h"
>
>  #define PRE_SYSCALL(name)
>      \
>    SANITIZER_INTERFACE_ATTRIBUTE void __sanitizer_syscall_pre_impl_##name
> @@ -104,6 +103,10 @@ struct sanitizer_kernel_sockaddr {
>    char sa_data[14];
>  };
>
> +// Real sigset size is always passed as a syscall argument.
> +// Declare it "void" to catch sizeof(kernel_sigset_t).
> +typedef void kernel_sigset_t;
>

Do we still need this now?


> +
>  static void kernel_write_iovec(const __sanitizer_iovec *iovec,
>                          SIZE_T iovlen, SIZE_T maxlen) {
>    for (SIZE_T i = 0; i < iovlen && maxlen; ++i) {
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc?rev=192695&r1=192694&r2=192695&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.cc Tue Oct 15
> 07:57:59 2013
> @@ -602,23 +602,23 @@ uptr internal_sigaltstack(const struct s
>    return internal_syscall(__NR_sigaltstack, ss, oss);
>  }
>
> -uptr internal_sigaction(int signum, const kernel_sigaction_t *act,
> -    struct kernel_sigaction_t *oldact) {
> +uptr internal_sigaction(int signum, const __sanitizer_kernel_sigaction_t
> *act,
> +    __sanitizer_kernel_sigaction_t *oldact) {
>    return internal_syscall(__NR_rt_sigaction, signum, act, oldact,
> -      sizeof(kernel_sigset_t));
> +      sizeof(__sanitizer_kernel_sigset_t));
>  }
>
> -uptr internal_sigprocmask(int how, kernel_sigset_t *set,
> -    kernel_sigset_t *oldset) {
> +uptr internal_sigprocmask(int how, __sanitizer_kernel_sigset_t *set,
> +    __sanitizer_kernel_sigset_t *oldset) {
>    return internal_syscall(__NR_rt_sigprocmask, (uptr)how, &set->sig[0],
> -      &oldset->sig[0], sizeof(kernel_sigset_t));
> +      &oldset->sig[0], sizeof(__sanitizer_kernel_sigset_t));
>  }
>
> -void internal_sigfillset(kernel_sigset_t *set) {
> +void internal_sigfillset(__sanitizer_kernel_sigset_t *set) {
>    internal_memset(set, 0xff, sizeof(*set));
>  }
>
> -void internal_sigdelset(kernel_sigset_t *set, int signum) {
> +void internal_sigdelset(__sanitizer_kernel_sigset_t *set, int signum) {
>    signum -= 1;
>    CHECK_GE(signum, 0);
>    CHECK_LT(signum, sizeof(*set) * 8);
>
> Modified: compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h?rev=192695&r1=192694&r2=192695&view=diff
>
> ==============================================================================
> --- compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h (original)
> +++ compiler-rt/trunk/lib/sanitizer_common/sanitizer_linux.h Tue Oct 15
> 07:57:59 2013
> @@ -17,41 +17,27 @@
>  #if SANITIZER_LINUX
>  #include "sanitizer_common.h"
>  #include "sanitizer_internal_defs.h"
> +#include "sanitizer_platform_limits_posix.h"
>
>  struct link_map;  // Opaque type returned by dlopen().
>  struct sigaltstack;
> -typedef struct siginfo siginfo_t;
>
>  namespace __sanitizer {
>  // Dirent structure for getdents(). Note that this structure is different
> from
>  // the one in <dirent.h>, which is used by readdir().
>  struct linux_dirent;
>
> -struct kernel_sigset_t {
> -  u8 sig[FIRST_32_SECOND_64(16, 8)];
> -};
> -
> -struct kernel_sigaction_t {
> -  union {
> -    void (*sigaction)(int signo, siginfo_t *info, void *ctx);
> -    void (*handler)(int signo);
> -  };
> -  unsigned long sa_flags;
> -  void (*sa_restorer)(void);
> -  kernel_sigset_t sa_mask;
> -};
> -
>  // Syscall wrappers.
>  uptr internal_getdents(fd_t fd, struct linux_dirent *dirp, unsigned int
> count);
>  uptr internal_prctl(int option, uptr arg2, uptr arg3, uptr arg4, uptr
> arg5);
>  uptr internal_sigaltstack(const struct sigaltstack* ss,
>                            struct sigaltstack* oss);
> -uptr internal_sigaction(int signum, const kernel_sigaction_t *act,
> -    kernel_sigaction_t *oldact);
> -uptr internal_sigprocmask(int how, kernel_sigset_t *set,
> -    kernel_sigset_t *oldset);
> -void internal_sigfillset(kernel_sigset_t *set);
> -void internal_sigdelset(kernel_sigset_t *set, int signum);
> +uptr internal_sigaction(int signum, const __sanitizer_kernel_sigaction_t
> *act,
> +    __sanitizer_kernel_sigaction_t *oldact);
> +uptr internal_sigprocmask(int how, __sanitizer_kernel_sigset_t *set,
> +    __sanitizer_kernel_sigset_t *oldset);
> +void internal_sigfillset(__sanitizer_kernel_sigset_t *set);
> +void internal_sigdelset(__sanitizer_kernel_sigset_t *set, int signum);
>
>  #ifdef __x86_64__
>  uptr internal_clone(int (*fn)(void *), void *child_stack, int flags, void
> *arg,
>
> Modified:
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h?rev=192695&r1=192694&r2=192695&view=diff
>
> ==============================================================================
> ---
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
> (original)
> +++
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_platform_limits_posix.h
> Tue Oct 15 07:57:59 2013
> @@ -222,6 +222,20 @@ namespace __sanitizer {
>  #endif
>    };
>
> +  struct __sanitizer_kernel_sigset_t {
> +    u8 sig[8];
> +  };
> +
> +  struct __sanitizer_kernel_sigaction_t {
> +    union {
> +      void (*sigaction)(int signo, void *info, void *ctx);
> +      void (*handler)(int signo);
> +    };
> +    unsigned long sa_flags;
> +    void (*sa_restorer)(void);
> +    __sanitizer_kernel_sigset_t sa_mask;
> +  };
> +
>    extern uptr sig_ign;
>    extern uptr sig_dfl;
>    extern uptr sa_siginfo;
>
> Modified:
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
> URL:
> http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc?rev=192695&r1=192694&r2=192695&view=diff
>
> ==============================================================================
> ---
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
> (original)
> +++
> compiler-rt/trunk/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc
> Tue Oct 15 07:57:59 2013
> @@ -18,6 +18,8 @@
>
>  #include "sanitizer_stoptheworld.h"
>
> +#include "sanitizer_platform_limits_posix.h"
> +
>  #include <errno.h>
>  #include <sched.h> // for CLONE_* definitions
>  #include <stddef.h>
> @@ -31,6 +33,14 @@
>  #endif
>  #include <sys/wait.h> // for signal-related stuff
>
> +#ifdef sa_handler
> +# undef sa_handler
> +#endif
> +
> +#ifdef sa_sigaction
> +# undef sa_sigaction
> +#endif
> +
>  #include "sanitizer_common.h"
>  #include "sanitizer_libc.h"
>  #include "sanitizer_linux.h"
> @@ -178,7 +188,7 @@ struct TracerThreadArgument {
>  static DieCallbackType old_die_callback;
>
>  // Signal handler to wake up suspended threads when the tracer thread
> dies.
> -void TracerThreadSignalHandler(int signum, siginfo_t *siginfo, void *) {
> +void TracerThreadSignalHandler(int signum, void *siginfo, void *) {
>    if (thread_suspender_instance != NULL) {
>      if (signum == SIGABRT)
>        thread_suspender_instance->KillAllThreads();
> @@ -236,7 +246,7 @@ static int TracerThread(void* argument)
>    // the mask we inherited from the caller thread.
>    for (uptr signal_index = 0; signal_index <
> ARRAY_SIZE(kUnblockedSignals);
>         signal_index++) {
> -    kernel_sigaction_t new_sigaction;
> +    __sanitizer_kernel_sigaction_t new_sigaction;
>      internal_memset(&new_sigaction, 0, sizeof(new_sigaction));
>      new_sigaction.sigaction = TracerThreadSignalHandler;
>      new_sigaction.sa_flags = SA_ONSTACK | SA_SIGINFO;
> @@ -286,9 +296,10 @@ class ScopedStackSpaceWithGuard {
>
>  // We have a limitation on the stack frame size, so some stuff had to be
> moved
>  // into globals.
> -static kernel_sigset_t blocked_sigset;
> -static kernel_sigset_t old_sigset;
> -static kernel_sigaction_t old_sigactions[ARRAY_SIZE(kUnblockedSignals)];
> +static __sanitizer_kernel_sigset_t blocked_sigset;
> +static __sanitizer_kernel_sigset_t old_sigset;
> +static __sanitizer_kernel_sigaction_t old_sigactions
> +    [ARRAY_SIZE(kUnblockedSignals)];
>
>  class StopTheWorldScope {
>   public:
> @@ -304,7 +315,7 @@ class StopTheWorldScope {
>        // Remove the signal from the set of blocked signals.
>        internal_sigdelset(&blocked_sigset,
> kUnblockedSignals[signal_index]);
>        // Install the default handler.
> -      kernel_sigaction_t new_sigaction;
> +      __sanitizer_kernel_sigaction_t new_sigaction;
>        internal_memset(&new_sigaction, 0, sizeof(new_sigaction));
>        new_sigaction.handler = SIG_DFL;
>        internal_sigfillset(&new_sigaction.sa_mask);
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>



-- 
Alexey Samsonov, MSK
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131015/0bd0af8a/attachment.html>


More information about the llvm-commits mailing list