]> Gentwo Git Trees - linux/.git/commit
params: Annotate struct module_param_attrs with __counted_by()
authorThorsten Blum <thorsten.blum@linux.dev>
Thu, 13 Feb 2025 22:13:52 +0000 (23:13 +0100)
committerPetr Pavlu <petr.pavlu@suse.com>
Mon, 17 Feb 2025 09:44:55 +0000 (10:44 +0100)
commitafa92869776a1aff196d8a55b200da52a58f9d76
tree48f67840dd4799412738e7843747269eb53a3076
parent3a2ef092de782d4165caa937fd703d3e05387c93
params: Annotate struct module_param_attrs with __counted_by()

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.

Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Luis Chamberlain <mcgrof@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20250213221352.2625-3-thorsten.blum@linux.dev
Signed-off-by: Petr Pavlu <petr.pavlu@suse.com>
kernel/params.c