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++].

Get the Android app

Or read this on Hacker News

Read more on:

Photo of Linux

Linux

Related news:

News photo

The Luckfox Pico Mini B – Linux in a Thumbnail

News photo

A Linux kernel syscall implementation tracker

News photo

USB & Thunderbolt Improvements Land In Linux 6.11