The situation came to Torvald's attention when, in order to patch a potential security problem with the kernel's linked-list primitive speculative-execution functions, another problem was revealed in the patch. While fixing this, Torvalds realized that in C99 the iterator passed to the list-traversal macros must be declared in a scope outside of the loop itself.
Torvalds wrote to the Linux Kernel Mailing List (LKML) that "the whole reason this kind of non-speculative bug can happen is that we historically didn't have C99-style 'declare variables in loops." So list_for_each_entry() - and all the other ones - fundamentally always leaks the last HEAD entry out of the loop, simply because we couldn't declare the iterator variable in the loop itself."
The answer? Finally, move from C89 to a newer standard C that makes this kind of problem can't occur. So, "the time had come to look at moving to the C99 standard — it is still over 20 years old, but is at least recent enough to allow block-level variable declarations."
Linus Torvalds prepares to move the Linux kernel to modern C
The Linux kernel's foundation is the ancient C89 standard of C. Now, Torvalds has decided to upgrade to 2011's more modern C11 standard.
www.zdnet.com