"the reduction function is called with num set to the bit size, where it should be number of BN_ULONG elements (which are always 8 bytes large, because that is the size of an unsigned long on x64 systems, which is the only architecture which can have AVX512 support). So with the input sizes being 1024 bits, 8192 bytes are accessed (read from or written to) instead of 128."
Really unfortunate that a performance optimization like this introduced RCE. Feels like something you would hope would be caught via the use of something like asan/msan or valgrind, at least it was caught relatively quickly after release via fuzzing.
A good bit of news is that since this requires AVX512 many CPUs won't hit it, including new Intel chips: https://www.pcgamer.com/intel-kills-alder-lake-avx-512-suppo...
a
b
m
r
carry
mask
num
tmp
Madness.
For example, the following SHA-256 code comes from OpenBSD - a Unix derivative known for its focus on security and correctness.
do {
/* Rounds 0 to 15 (unrolled): */
ROUND256_0_TO_15(a,b,c,d,e,f,g,h);
ROUND256_0_TO_15(h,a,b,c,d,e,f,g);
ROUND256_0_TO_15(g,h,a,b,c,d,e,f);
ROUND256_0_TO_15(f,g,h,a,b,c,d,e);
ROUND256_0_TO_15(e,f,g,h,a,b,c,d);
ROUND256_0_TO_15(d,e,f,g,h,a,b,c);
ROUND256_0_TO_15(c,d,e,f,g,h,a,b);
ROUND256_0_TO_15(b,c,d,e,f,g,h,a);
} while (j < 16);
In this particular case, the code is a direct translation of math, following the paper's notations is preferable. The state variables are named a, b, c, d, e, f, g because they're what the authors of SHA-256 chose to call them. When writing this particular fragment of code, renaming the state variables to something else is not constructive and increases the chance of mistakes.I haven't read the OpenSSL code in question so I cannot comment whether the uses of single-letter variables in your comment are appropriate. To make an educated guess, a, b, m, r are probably reasonable. The uses of carry, mask, num, tmp are potentially questionable, though.
One may argue whether a, b and m are as "commonly known" for modular exponentiation. Still: There are definitely valid cases to use single letter variable names if they are the most well known "names" of certain values.
emails = users.map u -> u.email
It’s perfectly reasonable when the context is brief and the usage is obvious.https://formulae.brew.sh/formula/openssl@3 https://docs.brew.sh/FAQ#why-does-brew-upgrade-formula-or-br...
I've heard some people moan that "it's not exactly a drop-in replacement" but I've yet to find in my own work a case where this is true.
The only off-putting thing to me is the fact that these OpenBSD projects love giving puffy lips for some reason.
[2] https://security-tracker.debian.org/tracker/CVE-2022-2068