On Tue, Oct 18, 2022 at 09:29:07AM -0700, Alexei Starovoitov wrote: > On Tue, Oct 18, 2022 at 2:02 AM Kees Cook <keescook@xxxxxxxxxxxx> wrote: > > + alloc->len = kmalloc_size_roundup(size + headroom + tailroom); > > + alloc->data = kzalloc(alloc->len, GFP_USER); > > Don't you need to do this generalically in many places in the kernel? The size tracking or the rounding up? The need for rounding up is surprisingly rare[1] -- very few things actually used ksize(), and almost all of them are due to following some variation of a realloc idiom. I've sent patches for all of them now, so that should be a short road to solving the problems ksize() created. The need for missed size tracking is also pretty uncommon (most dynamically sized things already track their size in some form or another). Finding a truly generalizable solution is an ongoing experiment[2]. -Kees [1] https://lore.kernel.org/lkml/20220923202822.2667581-1-keescook@xxxxxxxxxxxx/ [2] https://lore.kernel.org/llvm/20220504014440.3697851-1-keescook@xxxxxxxxxxxx/ -- Kees Cook