Google makes Linux more secure
Quoting: Google makes Linux more secure —
Google has taken a proactive step to bolster Linux security with the introduction of the counted_by attribute for flexible array members. This enhancement addresses a critical vulnerability in C programming related to buffer overflows, particularly those involving flexible array members whose sizes are determined at runtime.
Buffer overflows have long been a notorious source of security issues in software development. While sanitizers have mitigated some of these vulnerabilities by automatically inserting bounds checking, flexible array members have remained a challenging exception. The size of these arrays is typically opaque to the compiler, making it difficult to perform bounds checking outside the allocation function.
Google's solution, implemented in Clang and GCC, introduces the counted_by attribute. This attribute explicitly references the field that stores the number of elements in a flexible array member, enabling the array bounds sanitizer to verify operations on these arrays. This approach creates an implicit relationship between the flexible array member and the count field, enhancing the ability of sanitizers to catch potential overflows.