-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[sanitizer] Fix few size types in memprof #119114
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
Merged
vitalybuka
merged 1 commit into
main
from
users/vitalybuka/spr/sanitizer-fix-few-size-types-in-memprof
Dec 8, 2024
Merged
[sanitizer] Fix few size types in memprof #119114
vitalybuka
merged 1 commit into
main
from
users/vitalybuka/spr/sanitizer-fix-few-size-types-in-memprof
Dec 8, 2024
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
Created using spr 1.3.4
@llvm/pr-subscribers-pgo Author: Vitaly Buka (vitalybuka) ChangesAnd a few related Min() calls. Follow up to #116957. Full diff: https://github.com/llvm/llvm-project/pull/119114.diff 3 Files Affected:
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index be214f3ebeb6db..e6c95dfb82c320 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -535,7 +535,7 @@ INTERCEPTOR(char*, strncat, char *to, const char *from, usize size) {
AsanInitFromRtl();
if (flags()->replace_str) {
uptr from_length = MaybeRealStrnlen(from, size);
- uptr copy_length = Min(size, from_length + 1);
+ uptr copy_length = Min<uptr>(size, from_length + 1);
ASAN_READ_RANGE(ctx, from, copy_length);
uptr to_length = internal_strlen(to);
ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length);
@@ -622,7 +622,7 @@ INTERCEPTOR(char*, strncpy, char *to, const char *from, usize size) {
ASAN_INTERCEPTOR_ENTER(ctx, strncpy);
AsanInitFromRtl();
if (flags()->replace_str) {
- uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
+ uptr from_size = Min<uptr>(size, MaybeRealStrnlen(from, size) + 1);
CHECK_RANGES_OVERLAP("strncpy", to, from_size, from, from_size);
ASAN_READ_RANGE(ctx, from, from_size);
ASAN_WRITE_RANGE(ctx, to, size);
diff --git a/compiler-rt/lib/memprof/memprof_interceptors.cpp b/compiler-rt/lib/memprof/memprof_interceptors.cpp
index 49d8c2a6218345..f4d7fd46e61983 100644
--- a/compiler-rt/lib/memprof/memprof_interceptors.cpp
+++ b/compiler-rt/lib/memprof/memprof_interceptors.cpp
@@ -185,12 +185,12 @@ INTERCEPTOR(char *, strcat, char *to, const char *from) {
return REAL(strcat)(to, from);
}
-INTERCEPTOR(char *, strncat, char *to, const char *from, uptr size) {
+INTERCEPTOR(char *, strncat, char *to, const char *from, usize size) {
void *ctx;
MEMPROF_INTERCEPTOR_ENTER(ctx, strncat);
ENSURE_MEMPROF_INITED();
uptr from_length = MaybeRealStrnlen(from, size);
- uptr copy_length = Min(size, from_length + 1);
+ uptr copy_length = Min<uptr>(size, from_length + 1);
MEMPROF_READ_RANGE(from, copy_length);
uptr to_length = internal_strlen(to);
MEMPROF_READ_STRING(to, to_length);
@@ -239,11 +239,11 @@ INTERCEPTOR(char *, __strdup, const char *s) {
return reinterpret_cast<char *>(new_mem);
}
-INTERCEPTOR(char *, strncpy, char *to, const char *from, uptr size) {
+INTERCEPTOR(char *, strncpy, char *to, const char *from, usize size) {
void *ctx;
MEMPROF_INTERCEPTOR_ENTER(ctx, strncpy);
ENSURE_MEMPROF_INITED();
- uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
+ uptr from_size = Min<uptr>(size, MaybeRealStrnlen(from, size) + 1);
MEMPROF_READ_RANGE(from, from_size);
MEMPROF_WRITE_RANGE(to, size);
return REAL(strncpy)(to, from, size);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index f6b695defce414..99ad3b244d4e2c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -347,7 +347,7 @@ extern const short *_tolower_tab_;
uptr copy_length = internal_strnlen(s, size); \
char *new_mem = (char *)WRAP(malloc)(copy_length + 1); \
if (common_flags()->intercept_strndup) { \
- COMMON_INTERCEPTOR_READ_STRING(ctx, s, Min(size, copy_length + 1)); \
+ COMMON_INTERCEPTOR_READ_STRING(ctx, s, Min<uptr>(size, copy_length + 1)); \
} \
if (new_mem) { \
COMMON_INTERCEPTOR_COPY_STRING(ctx, new_mem, s, copy_length); \
|
@llvm/pr-subscribers-compiler-rt-sanitizer Author: Vitaly Buka (vitalybuka) ChangesAnd a few related Min() calls. Follow up to #116957. Full diff: https://github.com/llvm/llvm-project/pull/119114.diff 3 Files Affected:
diff --git a/compiler-rt/lib/asan/asan_interceptors.cpp b/compiler-rt/lib/asan/asan_interceptors.cpp
index be214f3ebeb6db..e6c95dfb82c320 100644
--- a/compiler-rt/lib/asan/asan_interceptors.cpp
+++ b/compiler-rt/lib/asan/asan_interceptors.cpp
@@ -535,7 +535,7 @@ INTERCEPTOR(char*, strncat, char *to, const char *from, usize size) {
AsanInitFromRtl();
if (flags()->replace_str) {
uptr from_length = MaybeRealStrnlen(from, size);
- uptr copy_length = Min(size, from_length + 1);
+ uptr copy_length = Min<uptr>(size, from_length + 1);
ASAN_READ_RANGE(ctx, from, copy_length);
uptr to_length = internal_strlen(to);
ASAN_READ_STRING_OF_LEN(ctx, to, to_length, to_length);
@@ -622,7 +622,7 @@ INTERCEPTOR(char*, strncpy, char *to, const char *from, usize size) {
ASAN_INTERCEPTOR_ENTER(ctx, strncpy);
AsanInitFromRtl();
if (flags()->replace_str) {
- uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
+ uptr from_size = Min<uptr>(size, MaybeRealStrnlen(from, size) + 1);
CHECK_RANGES_OVERLAP("strncpy", to, from_size, from, from_size);
ASAN_READ_RANGE(ctx, from, from_size);
ASAN_WRITE_RANGE(ctx, to, size);
diff --git a/compiler-rt/lib/memprof/memprof_interceptors.cpp b/compiler-rt/lib/memprof/memprof_interceptors.cpp
index 49d8c2a6218345..f4d7fd46e61983 100644
--- a/compiler-rt/lib/memprof/memprof_interceptors.cpp
+++ b/compiler-rt/lib/memprof/memprof_interceptors.cpp
@@ -185,12 +185,12 @@ INTERCEPTOR(char *, strcat, char *to, const char *from) {
return REAL(strcat)(to, from);
}
-INTERCEPTOR(char *, strncat, char *to, const char *from, uptr size) {
+INTERCEPTOR(char *, strncat, char *to, const char *from, usize size) {
void *ctx;
MEMPROF_INTERCEPTOR_ENTER(ctx, strncat);
ENSURE_MEMPROF_INITED();
uptr from_length = MaybeRealStrnlen(from, size);
- uptr copy_length = Min(size, from_length + 1);
+ uptr copy_length = Min<uptr>(size, from_length + 1);
MEMPROF_READ_RANGE(from, copy_length);
uptr to_length = internal_strlen(to);
MEMPROF_READ_STRING(to, to_length);
@@ -239,11 +239,11 @@ INTERCEPTOR(char *, __strdup, const char *s) {
return reinterpret_cast<char *>(new_mem);
}
-INTERCEPTOR(char *, strncpy, char *to, const char *from, uptr size) {
+INTERCEPTOR(char *, strncpy, char *to, const char *from, usize size) {
void *ctx;
MEMPROF_INTERCEPTOR_ENTER(ctx, strncpy);
ENSURE_MEMPROF_INITED();
- uptr from_size = Min(size, MaybeRealStrnlen(from, size) + 1);
+ uptr from_size = Min<uptr>(size, MaybeRealStrnlen(from, size) + 1);
MEMPROF_READ_RANGE(from, from_size);
MEMPROF_WRITE_RANGE(to, size);
return REAL(strncpy)(to, from, size);
diff --git a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
index f6b695defce414..99ad3b244d4e2c 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc
@@ -347,7 +347,7 @@ extern const short *_tolower_tab_;
uptr copy_length = internal_strnlen(s, size); \
char *new_mem = (char *)WRAP(malloc)(copy_length + 1); \
if (common_flags()->intercept_strndup) { \
- COMMON_INTERCEPTOR_READ_STRING(ctx, s, Min(size, copy_length + 1)); \
+ COMMON_INTERCEPTOR_READ_STRING(ctx, s, Min<uptr>(size, copy_length + 1)); \
} \
if (new_mem) { \
COMMON_INTERCEPTOR_COPY_STRING(ctx, new_mem, s, copy_length); \
|
stefan-sf-ibm
added a commit
to stefan-sf-ibm/llvm-project
that referenced
this pull request
Dec 9, 2024
This is a follow-up to 6dec338 and llvm#116957 and llvm#119114.
stefan-sf-ibm
added a commit
to stefan-sf-ibm/llvm-project
that referenced
this pull request
Dec 30, 2024
This is a follow-up to 6dec338 and llvm#116957 and llvm#119114.
vitalybuka
pushed a commit
that referenced
this pull request
Dec 30, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
compiler-rt:asan
Address sanitizer
compiler-rt:sanitizer
compiler-rt
PGO
Profile Guided Optimizations
skip-precommit-approval
PR for CI feedback, not intended for review
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.
And a few related Min() calls.
Follow up to #116957.