Get the latest tech news
How to use the new counted_by attribute in C (and Linux)
The counted\by attribute The countedby attribute was introduced in Clang-18 and will soon be available in GCC-15. Its purpose is to as...
In the Linux kernel, this attribute facilitates bounds-checking coverage through fortified APIs such as the memcpy() family of functions, which internally use__builtin_dynamic_object_size()(CONFIG_FORTIFY_SOURCE). We should audit all instances of code that reference both the counter and the flexible array and ensure they meet the proper requirements. Inside the for loop, the original code used this variable as an index to access the flexible array, then updated it via a post-increment, all in one line: cmd.cmd.channel_list[cmd.cmd.num_channels++].
Or read this on Hacker News