Re: [RESEND PATCH v2] params: Annotate struct module_param_attrs with __counted_by()

From: Luis Chamberlain
Date: Wed Sep 11 2024 - 13:59:48 EST


On Mon, Sep 09, 2024 at 06:27:26PM +0200, Thorsten Blum wrote:
> Add the __counted_by compiler attribute to the flexible array member
> attrs to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE.
>
> Increment num before adding a new param_attribute to the attrs array and
> adjust the array index accordingly. Increment num immediately after the
> first reallocation such that the reallocation for the NULL terminator
> only needs to add 1 (instead of 2) to mk->mp->num.
>
> Use struct_size() instead of manually calculating the size for the
> reallocation.
>
> Use krealloc_array() for the additional NULL terminator.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@xxxxxxxxxx>
> ---
> Changes in v2:
> - Use krealloc_array() as suggested by Andy Shevchenko
> - Link to v1: https://lore.kernel.org/linux-kernel/20240823123300.37574-1-thorsten.blum@xxxxxxxxxx/

Applied and pushed to modules-next, thanks!

Luis