[PATCH 0/2] overflow: Implement size_t saturating arithmetic helpers

From: Kees Cook
Date: Mon Sep 20 2021 - 21:33:09 EST


Hi,

While doing more array_size() scans on the kernel, and reviewing recent
struct_size() work[1], it became clear we needed helpers to perform
composed saturating add and multiplies. This creates those helpers and
updates the self tests to check them.

Thanks,

-Kees

[1] https://lore.kernel.org/lkml/?q=%22open-coded+arithmetic%22

Kees Cook (2):
overflow: Implement size_t saturating arithmetic helpers
test_overflow: Regularize test reporting output

include/linux/overflow.h | 140 ++++++++++++++++++++++++---------------
lib/test_overflow.c | 111 ++++++++++++++++++++++++-------
2 files changed, 175 insertions(+), 76 deletions(-)

--
2.30.2