Google Enhances Security of Linux Through Implementation of New Measures

94 views 10:01 am 0 Comments July 16, 2024

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. To effectively use the counted_by attribute, developers must adhere to specific rules:
– The count field must be within the same non-anonymous, enclosing struct as the flexible array member.

– The count field must be set before any array access. – The array field must have at least the count number of elements available at all times.

– The count field may change but must never exceed the number of elements originally allocated. Fortification relies on built-in functions like __builtin_object_size() and __builtin_dynamic_object_size() to validate input sizes.

With the counted_by attribute, these functions can now accurately determine the size of flexible array members, further enhancing security. Already in use within the Linux kernel, the counted_by attribute is proving instrumental in catching issues such as integer overflows that lead to heap buffer overflows.

Google plans to expand its use to more flexible array members and enforce its application in future developments.

Leave a Reply

Your email address will not be published. Required fields are marked *