On Fri, Nov 21, 2025 at 08:51:19PM -0800, Joe Perches wrote:
> On Fri, 2025-11-21 at 17:42 -0800, Kees Cook wrote:
> > To support shifting away from sized allocation towards typed
> > allocations, suggest the kmalloc_obj family of macros when a sizeof() is
> > present in the argument lists.
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > @@ -7258,17 +7258,42 @@ sub process {
> >                         "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . 
> > $herecurr);
> >             }
> >  
> > -# check for (kv|k)[mz]alloc with multiplies that could be 
> > kmalloc_array/kvmalloc_array/kvcalloc/kcalloc
> > +# check for (kv|k)[mz]alloc that could be 
> > kmalloc_obj/kvmalloc_obj/kzalloc_obj/kvzalloc_obj
> 
> There are _way_ too many of these existing uses to suggest this change
> in existing files so please add '&& !$file' to these tests

The goal would be to also do the proposed treewide change which gets
the vast majority of them converted.

-- 
Kees Cook

Reply via email to