On Sat, Nov 22, 2025 at 02:16:14PM -0800, Andrew Morton wrote: > On Fri, 21 Nov 2025 16:30:43 -0800 Kees Cook <[email protected]> wrote: > > > On Fri, Nov 21, 2025 at 07:39:44PM +0000, Bill Wendling wrote: > > > Add the '__counted_by_ptr' attribute to the 'regions' field of 'struct > > > memblock_type'. The 'regions' field is an array of 'struct > > > memblock_region' and its size is tracked by the 'max' field, which > > > represents the total number of allocated regions. > > > > As part of any counted_by annotation patch, there needs to be discussion > > in the commit log about how it's been shown to be a safe annotation > > to make. e.g. in this case, if all allocations of "regions" have a > > corresponding "max" assignment, etc. If just "git grep" can't find them > > all, using something like Coccinelle or CodeQL to search for struct > > memblock_type::regions assignments can work. > > How is anyone to know these things? I can't find anything about this > in include/ or Documentation/ or in the relevant commits. > > There should be a comment at the __counted_by() definition site, please. > > And possibly write a Documentation/ file then change checkpatch to > direct people to that file if they add a counted_by?
This is a fair point, yes. The documentation and discussions around counted_by are very big in my mind (and for Bill), so it was mostly a consolidation/reminder and some extra detail on prior solutions, but for anyone new to that annotation, we should have collected common guidance. I will write something up. -- Kees Cook
