Developers of the Grsecurity project
While testing the patch, the developers noticed that when building, the compiler displays a warning about mixing code and definitions (the structure was defined after the code, assigning a value to an existing variable):
int index = n;
if (n < HBP_NUM) { index = array_index_nospec(index, HBP_NUM); struct perf_event *bp = thread->ptrace_bps[index];
Linus accepted
if (n < HBP_NUM) { int index = array_index_nospec(n, HBP_NUM); struct perf_event *bp = thread->ptrace_bps[index];
In July, the fix was also ported to the stable kernel branches 4.4, 4.9, 4.14, 4.19 and 5.2. The maintainers of the stable branches also encountered the warning and, instead of checking to see if it had already been fixed in Linus's master branch, they made a fix themselves. The problem is that without really thinking about it, they just
int index = n;
if (n < HBP_NUM ){ struct perf_event *bp = thread->ptrace_bps[index];
index = array_index_nospec(index, HBP_NUM);
Source: opennet.ru