mbox series

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

Message ID 20210920180853.1825195-1-keescook@chromium.org (mailing list archive)
Headers show
Series overflow: Implement size_t saturating arithmetic helpers | expand

Message

Kees Cook Sept. 20, 2021, 6:08 p.m. UTC
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(-)