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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

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

v1: https://lore.kernel.org/lkml/20210920180853.1825195-1-keescook@xxxxxxxxxxxx/
v2:
 - use static inlines instead of macros (Rasmus)
 - undef local helpers defs in selftest (Rasmus)
 - Make sure to keep saturation for size_sub() arguments
 - update selftests for size_sub() behavior
 - Add reviews

Thanks,

-Kees

[1] https://lore.kernel.org/linux-hardening/202201241213.82E7D9F598@keescook/
[2] https://lore.kernel.org/lkml/?q=%22open-coded+arithmetic%22

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

 Documentation/process/deprecated.rst |  20 +++-
 include/linux/overflow.h             | 110 +++++++++++--------
 lib/test_overflow.c                  | 152 ++++++++++++++++++++++-----
 3 files changed, 214 insertions(+), 68 deletions(-)

-- 
2.30.2




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux