From: Willy Tarreau Date: Tue, 25 Apr 2023 17:01:48 +0000 (+0200) Subject: DEBUG: crash using an invalid opcode on aarch64 instead of an invalid access X-Git-Tag: v2.8-dev9~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=543e2544cabf9900af92d45658b122bc25011c3d;p=thirdparty%2Fhaproxy.git DEBUG: crash using an invalid opcode on aarch64 instead of an invalid access On aarch64 there's also a guaranted invalid instruction, called UDF, and which even supports an optional 16-bit immediate operand: https://developer.arm.com/documentation/ddi0596/2021-12/Base-Instructions/UDF--Permanently-Undefined-?lang=en It's conveniently encoded as 4 zeroes (when the operand is zero). It's unclear when support for it was added into GAS, if at all; even a not-so-old 2.27 doesn't know about it. Let's byte-encode it. Tested on an A72 and works as expected. --- diff --git a/include/haproxy/bug.h b/include/haproxy/bug.h index a07a6c3a35..6ce2066d59 100644 --- a/include/haproxy/bug.h +++ b/include/haproxy/bug.h @@ -54,6 +54,13 @@ my_unreachable(); \ } while (0) +#elif defined(__aarch64__) +#define ha_crash_now() do { \ + /* udf#imm16: 4 bytes (), raises illegal instruction */ \ + __asm__ volatile(".byte 0x00,0x00,0x00,0x00\n"); \ + my_unreachable(); \ + } while (0) + #else // not x86 /* generic implementation, causes a segfault */