details of crash:
interface::bls_fp_mod intrinsic calls bls12_381::fp::modPrime<8> and later calls bn_divn_low.
here is the code part that corrupts the stack:
carry = bn_lshb_low(a, a, sa, norm);
if(carry)
{
a[sa++] = carry;
}
sa here have a size of a and hence a[sa++] = carry changes memory beyond variable boundaries and corrupts a stack.
here is how call to it looks in bls12_381::fp::modPrime<8>:
std::array<uint64_t, N> k;
//...
bn_divn_low(quotient.data(), remainder.data(), k.data(), N, modulus.data(), 6); // N is sa and k.data() is a
this is reproduced on bls_integration branch. input data is from sig_verify_test
details of crash:
interface::bls_fp_mod
intrinsic callsbls12_381::fp::modPrime<8>
and later callsbn_divn_low
. here is the code part that corrupts the stack:sa
here have a size ofa
and hencea[sa++] = carry
changes memory beyond variable boundaries and corrupts a stack. here is how call to it looks inbls12_381::fp::modPrime<8>
: