diff --git a/ChangeLog.d/muladdc-aarch64-memory.txt b/ChangeLog.d/muladdc-aarch64-memory.txt new file mode 100644 index 000000000000..70addd253c21 --- /dev/null +++ b/ChangeLog.d/muladdc-aarch64-memory.txt @@ -0,0 +1,4 @@ +Bugfix + * Add missing memory constraints in aarch64 inline assembly for + bignum multiplication. + Fixes #4962. diff --git a/include/mbedtls/bn_mul.h b/include/mbedtls/bn_mul.h index 716bd3b8190d..31137cd4c231 100644 --- a/include/mbedtls/bn_mul.h +++ b/include/mbedtls/bn_mul.h @@ -244,18 +244,18 @@ #define MULADDC_CORE \ "ldr x4, [%2], #8 \n\t" \ "ldr x5, [%1] \n\t" \ - "mul x6, x4, %3 \n\t" \ - "umulh x7, x4, %3 \n\t" \ + "mul x6, x4, %4 \n\t" \ + "umulh x7, x4, %4 \n\t" \ "adds x5, x5, x6 \n\t" \ "adc x7, x7, xzr \n\t" \ "adds x5, x5, %0 \n\t" \ "adc %0, x7, xzr \n\t" \ "str x5, [%1], #8 \n\t" -#define MULADDC_STOP \ - : "+r" (c), "+r" (d), "+r" (s) \ - : "r" (b) \ - : "x4", "x5", "x6", "x7", "cc" \ +#define MULADDC_STOP \ + : "+r" (c), "+r" (d), "+r" (s), "+m" (*(uint64_t (*)[16]) d) \ + : "r" (b), "m" (*(const uint64_t (*)[16]) s) \ + : "x4", "x5", "x6", "x7", "cc" \ ); #endif /* Aarch64 */