Re: [PATCH v2] slab: fix the kernel-doc of kmalloc_flex() on counter overflow
From: Manuel Ebner
Date: Sun Nov 29 2026 - 02:41:12 EST
Hi Arina,
On Sun, 2026-11-29 at 10:04 +0400, Arina Kharlamova via B4 Relay wrote:
> From: Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>
>
> Commit fa5c82f4d2bb ("slab.h: disable completely broken overflow handling
> in flex allocations") removed the counter overflow check from
> __alloc_flex(), but the kernel-doc and deprecated.rst still say that the
> allocation fails if COUNT does not fit in the __counted_by() counter.
>
> Update them to match the code. While at it, fix the Returns: line of
> overflows_flex_counter_type(), where true and false are swapped.
>
> Fixes: fa5c82f4d2bb ("slab.h: disable completely broken overflow handling in flex allocations")
> Signed-off-by: Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>
> ---
> Found by checks derived from the spec2patch kernel API specifications,
> with the help of an AI coding assistant (Claude); I reviewed the
> analysis and the fix.
> ---
> Changes in v2:
> - Shorten the changelog and the comments (Harry Yoo)
> - Rebase on slab/for-next
> - Link to v1: https://patch.msgid.link/20261124-slab-doc-v1-1-9f14dfce47c8@xxxxxxxxxxxx
> ---
> Documentation/process/deprecated.rst | 7 +++----
> include/linux/overflow.h | 5 +++--
> include/linux/slab.h | 10 ++++------
> 3 files changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/Documentation/process/deprecated.rst b/Documentation/process/deprecated.rst
> index 22a5e62c92ea..ea392cf36fb8 100644
> --- a/Documentation/process/deprecated.rst
> +++ b/Documentation/process/deprecated.rst
> @@ -405,7 +405,6 @@ become, respectively::
> __auto_type ptr = kmalloc_obj(struct foo [, gfp] );
>
> The argument gfp is optional, the default value is GFP_KERNEL.
could you add this diff in you patch?
https://lore.kernel.org/all/20260909141255.1367539-2-manuelebnerli@xxxxxxxxxxx/
Else looks good to me.
Reviewed-by: Manuel Ebner <manuelebnerli@xxxxxxxxxxx>
Thanks
Manuel
> -If `ptr->flex_member` is annotated with __counted_by(), the allocation
> -will automatically fail if `count` is larger than the maximum
> -representable value that can be stored in the counter member associated
> -with `flex_member`.
> +If `ptr->flex_member` is annotated with __counted_by(), the caller must
> +make sure that `count` fits in the counter member associated with
> +`flex_member`.
> diff --git a/include/linux/overflow.h b/include/linux/overflow.h
>
> [...]
>
> Best regards,
> --
> Arina Kharlamova <arina.kharlamova@xxxxxxxxxxxx>
>