Jacob Keller e754948125 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 <jacob.e.keller@intel.com>
Link: https://lore.kernel.org/r/20230227202428.3657443-1-jacob.e.keller@intel.com
Signed-off-by: Kees Cook <keescook@chromium.org>
2024-02-29 13:38:01 -08:00
..
2024-01-18 17:57:07 -08:00
2024-01-19 13:30:49 -08:00
2023-04-30 11:32:53 -07:00
2023-07-01 09:24:31 -07:00
2023-07-01 09:24:31 -07:00
2022-10-03 14:03:19 -07:00
2024-01-19 13:30:49 -08:00
2023-12-03 18:51:48 +09:00
2023-12-03 18:51:48 +09:00
2024-01-04 17:01:15 +01:00
2021-05-03 17:23:06 -06:00
2023-12-03 18:51:48 +09:00