Skip to content

[compiler-rt] fix __sanitizer::struct_sock_fprog_sz availability #118762

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
merged 1 commit into from
Dec 9, 2024

Conversation

devnexen
Copy link
Member

@devnexen devnexen commented Dec 5, 2024

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Dec 5, 2024

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

Author: David CARLIER (devnexen)

Changes

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

1 Files Affected:

  • (modified) compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp (+1-1)
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 c87d5ef42c9242..e0da2ac4fd303e 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp
@@ -491,6 +491,7 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
   unsigned struct_vt_consize_sz = sizeof(struct vt_consize);
   unsigned struct_vt_sizes_sz = sizeof(struct vt_sizes);
   unsigned struct_vt_stat_sz = sizeof(struct vt_stat);
+  unsigned struct_sock_fprog_sz = sizeof(struct sock_fprog);
 #endif // SANITIZER_LINUX
 
 #if SANITIZER_LINUX
@@ -537,7 +538,6 @@ unsigned struct_ElfW_Phdr_sz = sizeof(Elf_Phdr);
 
   unsigned struct_audio_buf_info_sz = sizeof(struct audio_buf_info);
   unsigned struct_ppp_stats_sz = sizeof(struct ppp_stats);
-  unsigned struct_sock_fprog_sz = sizeof(struct sock_fprog);
 #  endif  // SANITIZER_GLIBC
 
 #  if !SANITIZER_ANDROID && !SANITIZER_APPLE

@devnexen
Copy link
Member Author

devnexen commented Dec 5, 2024

@Zentrik would you be able to test this branch ?

Copy link

github-actions bot commented Dec 5, 2024

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

You can test this locally with the following command:
git-clang-format --diff 41cde465acfddb44d400b0a53bb57960762312a2 14226a18399fd925fb9f8f8910fa8e30a6433178 --extensions h,inc -- compiler-rt/lib/sanitizer_common/sanitizer_common_interceptors.inc 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_platform_limits_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
index aaaff56119..85219ad552 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h
@@ -524,9 +524,9 @@ struct __sanitizer_dirent64 {
   // more fields that we don't care about
 };
 extern unsigned struct_sock_fprog_sz;
-#endif
+#  endif
 
-#if defined(__x86_64__) && !defined(_LP64)
+#  if defined(__x86_64__) && !defined(_LP64)
 typedef long long __sanitizer_clock_t;
 #else
 typedef long __sanitizer_clock_t;

@Zentrik
Copy link
Contributor

Zentrik commented Dec 5, 2024

I'm getting an error

[09:12:16] /workspace/srcdir/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:493:35: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::sock_fprog’
[09:12:16]   493 |   unsigned struct_sock_fprog_sz = sizeof(struct sock_fprog);
[09:12:16]       |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~
[09:12:16] In file included from /workspace/srcdir/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_posix.h:20,
[09:12:16]                  from /workspace/srcdir/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cpp:16:

@devnexen
Copy link
Member Author

devnexen commented Dec 5, 2024

nvm, just checked it s not available on musl, fixing ...

@devnexen devnexen force-pushed the prctl_build_musl_fix branch from c334462 to 78733ad Compare December 5, 2024 09:35
@devnexen
Copy link
Member Author

devnexen commented Dec 5, 2024

I'm getting an error

[09:12:16] /workspace/srcdir/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.cpp:493:35: error: invalid application of ‘sizeof’ to incomplete type ‘__sanitizer::sock_fprog’
[09:12:16]   493 |   unsigned struct_sock_fprog_sz = sizeof(struct sock_fprog);
[09:12:16]       |                                   ^~~~~~~~~~~~~~~~~~~~~~~~~
[09:12:16] In file included from /workspace/srcdir/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_posix.h:20,
[09:12:16]                  from /workspace/srcdir/llvm-project/compiler-rt/lib/sanitizer_common/sanitizer_libignore.cpp:16:

Can you give it a try when you get the chance ? thx.

@Zentrik
Copy link
Contributor

Zentrik commented Dec 5, 2024

Great that worked thanks.

@devnexen devnexen requested a review from vitalybuka December 5, 2024 14:57
@@ -1313,7 +1313,7 @@ INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3,
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, (u64 *)(arg5), sizeof(u64));
} else if (res != -1 && option == PR_GET_PDEATHSIG) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, (u64 *)(arg2), sizeof(int));
# if !SANITIZER_ANDROID
# if !SANITIZER_ANDROID && !SANITIZER_MUSL
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just #if SANITIZER_GLIBC ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

android can't be GLIBC

@devnexen devnexen force-pushed the prctl_build_musl_fix branch from 78733ad to 5f69085 Compare December 9, 2024 06:14
@@ -1313,7 +1313,7 @@ INTERCEPTOR(int, prctl, int option, unsigned long arg2, unsigned long arg3,
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, (u64 *)(arg5), sizeof(u64));
} else if (res != -1 && option == PR_GET_PDEATHSIG) {
COMMON_INTERCEPTOR_WRITE_RANGE(ctx, (u64 *)(arg2), sizeof(int));
# if !SANITIZER_ANDROID
# if !SANITIZER_ANDROID && SANITIZER_GLIBC
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# if !SANITIZER_ANDROID && SANITIZER_GLIBC
# if SANITIZER_GLIBC

Copy link
Collaborator

@vitalybuka vitalybuka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With suggestion

@devnexen devnexen force-pushed the prctl_build_musl_fix branch from 5f69085 to 14226a1 Compare December 9, 2024 06:25
@devnexen devnexen merged commit 6b93a1f into llvm:main Dec 9, 2024
6 of 7 checks passed
@devnexen devnexen deleted the prctl_build_musl_fix branch December 9, 2024 06:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants