From 6a29777453458c60110fcb0646f3b0f381eaf43b Mon Sep 17 00:00:00 2001 From: Lajos Deak Date: Tue, 22 Apr 2025 15:00:47 +0000 Subject: [PATCH 1/3] [compiler-rt][sanitizer] fix msghdr for musl --- .../sanitizer_platform_limits_posix.h | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) 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 348bb4f27aec3..899bd22bbd309 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -476,6 +476,39 @@ struct __sanitizer_cmsghdr { int cmsg_level; int cmsg_type; }; +#elif SANITIZER_MUSL +struct __sanitizer_msghdr { + void *msg_name; + unsigned msg_namelen; + struct __sanitizer_iovec *msg_iov; +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN + int __pad1; +# endif + int msg_iovlen; +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN + int __pad1; +# endif + void *msg_control; +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN + int __pad2; +# endif + unsigned msg_controllen; +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN + int __pad2; +# endif + int msg_flags; +}; +struct __sanitizer_cmsghdr { +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN + int __pad1; +# endif + unsigned cmsg_len; +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN + int __pad1; +# endif + int cmsg_level; + int cmsg_type; +}; #else // In POSIX, int msg_iovlen; socklen_t msg_controllen; socklen_t cmsg_len; but // many implementations don't conform to the standard. From c4ed51f9a6ca2add13c52957ed0e1f0471e6b1af Mon Sep 17 00:00:00 2001 From: Lajos Date: Sun, 27 Apr 2025 20:24:36 +0200 Subject: [PATCH 2/3] Fixed clang-format --- .../sanitizer_platform_limits_posix.h | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) 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 899bd22bbd309..9a35d7e50b6c8 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -476,40 +476,40 @@ struct __sanitizer_cmsghdr { int cmsg_level; int cmsg_type; }; -#elif SANITIZER_MUSL +# elif SANITIZER_MUSL struct __sanitizer_msghdr { void *msg_name; unsigned msg_namelen; struct __sanitizer_iovec *msg_iov; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN int __pad1; -# endif +# endif int msg_iovlen; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN int __pad1; -# endif +# endif void *msg_control; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN int __pad2; -# endif +# endif unsigned msg_controllen; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN int __pad2; -# endif +# endif int msg_flags; }; struct __sanitizer_cmsghdr { -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN int __pad1; -# endif +# endif unsigned cmsg_len; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN +# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN int __pad1; -# endif +# endif int cmsg_level; int cmsg_type; }; -#else +# else // In POSIX, int msg_iovlen; socklen_t msg_controllen; socklen_t cmsg_len; but // many implementations don't conform to the standard. struct __sanitizer_msghdr { @@ -526,9 +526,9 @@ struct __sanitizer_cmsghdr { int cmsg_level; int cmsg_type; }; -#endif +# endif -#if SANITIZER_LINUX +# if SANITIZER_LINUX struct __sanitizer_mmsghdr { __sanitizer_msghdr msg_hdr; unsigned int msg_len; From 33092651d27c61d26e3bfbf87fa2f00360d0bcca Mon Sep 17 00:00:00 2001 From: Lajos Deak Date: Fri, 16 May 2025 07:23:57 +0000 Subject: [PATCH 3/3] Removed big endian code + use SANITIZER_WORDSIZE instead of __LONG_MAX --- .../sanitizer_platform_limits_posix.h | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) 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 9a35d7e50b6c8..9c159d4fcfb4d 100644 --- a/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h +++ b/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_posix.h @@ -481,29 +481,20 @@ struct __sanitizer_msghdr { void *msg_name; unsigned msg_namelen; struct __sanitizer_iovec *msg_iov; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN - int __pad1; -# endif int msg_iovlen; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN +# if SANITIZER_WORDSIZE == 64 int __pad1; # endif void *msg_control; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN - int __pad2; -# endif unsigned msg_controllen; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN +# if SANITIZER_WORDSIZE == 64 int __pad2; # endif int msg_flags; }; struct __sanitizer_cmsghdr { -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN - int __pad1; -# endif unsigned cmsg_len; -# if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN +# if SANITIZER_WORDSIZE == 64 int __pad1; # endif int cmsg_level;