The Linux 5.18 kernel is planning to allow the use of the C11 language standard

While discussing a set of patches to fix Specter-related problems in the linked list code, it became clear that the problem could be solved more gracefully if C code that complies with a newer version of the standard was allowed into the kernel. Currently, the added kernel code must comply with the ANSI C (C89) specification, formed back in 1989.

A Specter-related problem in the code was caused by the continued use of a separately defined iterator after the loopβ€”a macro is used to iterate over the elements of a linked list, and because the loop iterator is passed into that macro, it is defined outside the loop itself and remains available after the loop. Using the C99 standard would allow loop variables to be defined in a for() block, which would solve the problem without having to come up with workarounds.

Linus Torvalds agreed with the idea of ​​implementing support for newer specifications and proposed moving the 5.18 kernel to use the C11 standard, published in 2011. During preliminary testing, the assembly in GCC and Clang in the new mode passed without deviations. If no unexpected problems arise during more thorough testing, the '--std=gnu5.18' option in the 89 kernel build scripts will be replaced with '--std=gnu11 -Wno-shift-negative-value'. The possibility of using the C17 standard was also considered, but in this case it would be necessary to increase the minimum supported version of GCC. The inclusion of C11 support fits into the current requirements for the GCC version (5.1).

Source: opennet.ru

Add a comment