Skip to content

Conversation

@devnexen
Copy link
Member

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Jan 29, 2024

@llvm/pr-subscribers-compiler-rt-sanitizer

Author: David CARLIER (devnexen)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/79903.diff

5 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc (+1-1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp (+1)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h (+2)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp (+8)
  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h (+7)
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index 3ecdb55cdbf72f..9d556ff73d15b4 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -3870,7 +3870,7 @@ INTERCEPTOR(SIZE_T, confstr, int name, char *buf, SIZE_T len) { #endif #if SANITIZER_INTERCEPT_SCHED_GETAFFINITY -INTERCEPTOR(int, sched_getaffinity, int pid, SIZE_T cpusetsize, void *mask) { +INTERCEPTOR(int, sched_getaffinity, int pid, SIZE_T cpusetsize, __sanitizer_cpu_set_t *mask) { void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, sched_getaffinity, pid, cpusetsize, mask); // FIXME: under ASan the call below may write to freed memory and corrupt diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp index 38f968d533b147..eedd642b34b755 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp @@ -105,6 +105,7 @@ void *__sanitizer_get_link_map_by_dlopen_handle(void *handle) { } unsigned struct_cpuset_sz = sizeof(cpuset_t); +unsigned struct_cpu_set_sz = sizeof(cpu_set_t); unsigned struct_cap_rights_sz = sizeof(cap_rights_t); unsigned struct_utsname_sz = sizeof(struct utsname); unsigned struct_stat_sz = sizeof(struct stat); diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h index 43b8a38f39be18..e45d3efaa15ea6 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h @@ -725,7 +725,9 @@ struct __sanitizer_cpuset { }; typedef struct __sanitizer_cpuset __sanitizer_cpuset_t; +typedef struct __sanitizer_cpuset __sanitizer_cpu_set_t; extern unsigned struct_cpuset_sz; +extern unsigned struct_cpu_set_sz; typedef unsigned long long __sanitizer_eventfd_t; } // namespace __sanitizer diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp index 6d61d276d77e35..22449a0c316f3c 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp @@ -85,6 +85,9 @@ #include <linux/utsname.h> #include <linux/posix_types.h> #include <net/if_arp.h> +#if !SANITIZER_ANDROID +#include <sched.h> +#endif #endif #if SANITIZER_IOS @@ -301,6 +304,7 @@ namespace __sanitizer { unsigned struct_msqid_ds_sz = sizeof(struct msqid_ds); unsigned struct_mq_attr_sz = sizeof(struct mq_attr); unsigned struct_statvfs_sz = sizeof(struct statvfs); + unsigned struct_cpu_set_sz = sizeof(cpu_set_t); #endif // SANITIZER_LINUX && !SANITIZER_ANDROID const uptr sig_ign = (uptr)SIG_IGN; @@ -1351,4 +1355,8 @@ CHECK_TYPE_SIZE(sem_t); COMPILER_CHECK(ARM_VFPREGS_SIZE == ARM_VFPREGS_SIZE_ASAN); #endif +#if SANITIZER_LINUX && !SANITIZER_ANDROID +COMPILER_CHECK(sizeof(__sanitizer_cpu_set_t) == sizeof(cpu_set_t)); +#endif + #endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_APPLE diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h index 34bfef1f7ef456..db7d4bea30f5d1 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -209,6 +209,13 @@ struct __sanitizer_sem_t { extern unsigned struct_ustat_sz; extern unsigned struct_rlimit64_sz; extern unsigned struct_statvfs64_sz; +extern unsigned struct_cpu_set_sz; + +struct __sanitizer_cpu_set { + unsigned long __bits[1024 / (8 * sizeof(unsigned long))]; +}; + +typedef struct __sanitizer_cpu_set __sanitizer_cpu_set_t; struct __sanitizer_ipc_perm { int __key; 
@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff e633807a1fccbed91dbfe1fdc2c78adcaf21d99c 4365891cd134b0c7a771c81c944b8faaab64c419 -- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_freebsd.h compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
View the diff from clang-format here.
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc index 9d556ff73d..3c8bf8c720 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc +++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc @@ -3870,7 +3870,8 @@ INTERCEPTOR(SIZE_T, confstr, int name, char *buf, SIZE_T len) { #endif #if SANITIZER_INTERCEPT_SCHED_GETAFFINITY -INTERCEPTOR(int, sched_getaffinity, int pid, SIZE_T cpusetsize, __sanitizer_cpu_set_t *mask) { +INTERCEPTOR(int, sched_getaffinity, int pid, SIZE_T cpusetsize, + __sanitizer_cpu_set_t *mask) { void *ctx; COMMON_INTERCEPTOR_ENTER(ctx, sched_getaffinity, pid, cpusetsize, mask); // FIXME: under ASan the call below may write to freed memory and corrupt @@ -3880,7 +3881,7 @@ INTERCEPTOR(int, sched_getaffinity, int pid, SIZE_T cpusetsize, __sanitizer_cpu_ if (mask && !res) COMMON_INTERCEPTOR_WRITE_RANGE(ctx, mask, cpusetsize); return res; } -#define INIT_SCHED_GETAFFINITY COMMON_INTERCEPT_FUNCTION(sched_getaffinity); +# define INIT_SCHED_GETAFFINITY COMMON_INTERCEPT_FUNCTION(sched_getaffinity); #else #define INIT_SCHED_GETAFFINITY #endif diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp index 22449a0c31..88b4c0c95d 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp @@ -85,9 +85,9 @@ #include <linux/utsname.h> #include <linux/posix_types.h> #include <net/if_arp.h> -#if !SANITIZER_ANDROID -#include <sched.h> -#endif +# if !SANITIZER_ANDROID +# include <sched.h> +# endif #endif #if SANITIZER_IOS @@ -305,7 +305,7 @@ namespace __sanitizer { unsigned struct_mq_attr_sz = sizeof(struct mq_attr); unsigned struct_statvfs_sz = sizeof(struct statvfs); unsigned struct_cpu_set_sz = sizeof(cpu_set_t); -#endif // SANITIZER_LINUX && !SANITIZER_ANDROID +# endif // SANITIZER_LINUX && !SANITIZER_ANDROID const uptr sig_ign = (uptr)SIG_IGN; const uptr sig_dfl = (uptr)SIG_DFL; @@ -1355,8 +1355,8 @@ CHECK_TYPE_SIZE(sem_t); COMPILER_CHECK(ARM_VFPREGS_SIZE == ARM_VFPREGS_SIZE_ASAN); #endif -#if SANITIZER_LINUX && !SANITIZER_ANDROID +# if SANITIZER_LINUX && !SANITIZER_ANDROID COMPILER_CHECK(sizeof(__sanitizer_cpu_set_t) == sizeof(cpu_set_t)); -#endif +# endif #endif // SANITIZER_LINUX || SANITIZER_FREEBSD || SANITIZER_APPLE 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment