In the Linux 5.18 kernel, the use of the C11 standard is planned to be permitted.

During the discussion of the patch set addressing issues related to vulnerabilities of the Spectre class in the code for handling linked lists, it became clear that the problem could be resolved more elegantly if the kernel allowed C code conformed to a newer version of the standard. Currently, the code added to the kernel must comply with the ANSI C (C89) specification, which was established back in 1989.

The issue related to Spectre in the code was caused by the ongoing use of a separately defined iterator after the loop — a macro is used to iterate over the elements of the linked list, and since the loop iterator is passed into this macro, it is defined outside the loop itself and remains available after the loop. Using the C99 standard would allow variables for the loop to be defined in the for() block, which would solve the problem without resorting to workarounds.

Linus Torvalds agreed with the idea of implementing support for newer specifications and proposed transitioning the kernel to use the C11 standard, published in 2011, in version 5.18. Preliminary checks showed that the build in GCC and Clang passed without issues in the new mode. If no unforeseen problems arise during more thorough testing, the ‘—std=gnu89’ option in the kernel 5.18 build scripts will be replaced with ‘—std=gnu11 -Wno-shift-negative-value’. The possibility of using the C17 standard was also considered, but this would require raising the minimum supported version of GCC. Including support for C11 fits within the current GCC version requirements (5.1).

Source: opennet.ru

Buy reliable website hosting with DDoS protection, VPS VDS servers 🔥 Buy reliable website hosting with DDoS protection, VPS VDS servers | ProHoster