pespin has submitted this change. ( https://gerrit.osmocom.org/c/libasn1c/+/32612 )
Change subject: Disable _ASN_STACK_OVERFLOW_CHECK if building with Asan enabled ...................................................................... Disable _ASN_STACK_OVERFLOW_CHECK if building with Asan enabled Related: OS#6025 Change-Id: I2dda4720f3ea5a023d340863db177e6334beeaa3 --- M include/asn1c/asn_internal.h 1 file changed, 36 insertions(+), 0 deletions(-) Approvals: Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved diff --git a/include/asn1c/asn_internal.h b/include/asn1c/asn_internal.h index 580c2e7..0af6bd9 100644 --- a/include/asn1c/asn_internal.h +++ b/include/asn1c/asn_internal.h @@ -108,9 +108,34 @@ /* * Check stack against overflow, if limit is set. */ + +/* Since GCC 13, AddressSanitizer started defaulting to +* ASAN_OPTIONS="detect_stack_use_after_return=1", which makes this check +* fail due to apparently jumping stack pointers. +* Hence, disable this check if building with ASan, as documented in: +* GCC: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html +* Clang: https://clang.llvm.org/docs/AddressSanitizer.html#conditional-compilation-with-has-feature-address-sanitizer +*/ +#if defined(__SANITIZE_ADDRESS__) + #define _ASN_SANITIZE_ENABLED 1 +#elif defined(__has_feature) +#if __has_feature(address_sanitizer) + #define _ASN_SANITIZE_ENABLED 1 +#endif +#endif + #define _ASN_DEFAULT_STACK_MAX (30000) + +#if defined(_ASN_SANITIZE_ENABLED) static inline int _ASN_STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx) { + (void)ctx; + return 0; +} +#else +static inline int +_ASN_STACK_OVERFLOW_CHECK(asn_codec_ctx_t *ctx) { + if(ctx && ctx->max_stack_size) { /* ctx MUST be allocated on the stack */ @@ -126,6 +151,7 @@ } return 0; } +#endif #ifdef __cplusplus } -- To view, visit https://gerrit.osmocom.org/c/libasn1c/+/32612 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: libasn1c Gerrit-Branch: master Gerrit-Change-Id: I2dda4720f3ea5a023d340863db177e6334beeaa3 Gerrit-Change-Number: 32612 Gerrit-PatchSet: 3 Gerrit-Owner: pespin <[email protected]> Gerrit-Reviewer: Hoernchen <[email protected]> Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: daniel <[email protected]> Gerrit-Reviewer: fixeria <[email protected]> Gerrit-Reviewer: laforge <[email protected]> Gerrit-Reviewer: pespin <[email protected]> Gerrit-MessageType: merged
