Re: [PATCH v2] driver core: Add __alloc_size hint to devm allocators
From: Greg Kroah-Hartman
Date: Sat Oct 29 2022 - 03:53:27 EST
On Sat, Oct 29, 2022 at 12:47:34AM -0700, Kees Cook wrote:
> Mark the devm_*alloc()-family of allocations with appropriate
> __alloc_size()/__realloc_size() hints so the compiler can attempt to
> reason about buffer lengths from allocations.
>
> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
> Cc: Rasmus Villemoes <rasmus.villemoes@xxxxxxxxx>
> Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> Cc: Jason Gunthorpe <jgg@xxxxxxxx>
> Cc: Nishanth Menon <nm@xxxxxx>
> Cc: Michael Kelley <mikelley@xxxxxxxxxxxxx>
> Cc: Dan Williams <dan.j.williams@xxxxxxxxx>
> Cc: Won Chung <wonchung@xxxxxxxxxx>
> Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
> ---
> I'm hoping to carry this via the hardening tree so I can add a
> KUnit test that depends on it...
> v2: use __realloc_size instead of __alloc_size
> v1: https://lore.kernel.org/linux-hardening/20221018073430.never.551-kees@xxxxxxxxxx/
> ---
> include/linux/device.h | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
Reviewed-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>