]> git.ipfire.org Git - thirdparty/kernel/stable.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, 10 Mar 2025 10:54:46 +0000 (11:54 +0100)
commit3690f4a86005b4b15fabc606d2bbf39bb6290aff
tree8f689ee55a365a7ddad1738aeb7d0e056db2bdc3
parentf47d2a3f7542a5507b4072fb768a2258071ff519
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