aboutsummaryrefslogtreecommitdiffstats
path: root/lib/string_helpers.c
diff options
context:
space:
mode:
authorJacob Keller <[email protected]>2023-02-27 20:24:28 +0000
committerKees Cook <[email protected]>2024-02-29 21:38:01 +0000
commite7549481255167dcdab355c539562c7ace17e111 (patch)
treeabc01d0800b8e65bc2bccad2be0aeda1981535ca /lib/string_helpers.c
parentcoccinelle: Add rules to find str_plural() replacements (diff)
downloadkernel-e7549481255167dcdab355c539562c7ace17e111.tar.gz
kernel-e7549481255167dcdab355c539562c7ace17e111.zip
coccinelle: semantic patch to check for potential struct_size calls
include/linux/overflow.h includes helper macros intended for calculating sizes of allocations. These macros prevent accidental overflow by saturating at SIZE_MAX. In general when calculating such sizes use of the macros is preferred. Add a semantic patch which can detect code patterns which can be replaced by struct_size. Note that I set the confidence to medium because this patch doesn't make an attempt to ensure that the relevant array is actually a flexible array. The struct_size macro does specifically require a flexible array. In many cases the detected code could be refactored to a flexible array, but this is not always possible (such as if there are multiple over-allocations). Signed-off-by: Jacob Keller <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Kees Cook <[email protected]>
Diffstat (limited to 'lib/string_helpers.c')
0 files changed, 0 insertions, 0 deletions