- Notifications
You must be signed in to change notification settings - Fork 15.3k
[compiler-rt] sched_getaffinity mask definition for Linux. #79903
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devnexen wants to merge 1 commit into llvm:main Choose a base branch from devnexen:sched_getaffinity_linux_upd
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Member
| @llvm/pr-subscribers-compiler-rt-sanitizer Author: David CARLIER (devnexen) ChangesFull diff: https://github.com/llvm/llvm-project/pull/79903.diff 5 Files Affected:
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; |
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.hView 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
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
No description provided.