Skip to content

overflow: Introduce wrapping helpers

Kees Cook linux-hardening lkml 7 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v7 Latest3 patches 3 repliesIn review
  2. v63 patches 3 repliesSuperseded
  3. v53 patches 4 repliesSuperseded
Earlier versions · 4
VersionPostedPatchesRepliesStatus
v43 patches3 repliesSuperseded
v33 patches10 repliesSuperseded
v25 patches4 repliesSuperseded
v15 patches4 repliesSuperseded

Patches in v7 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3overflow: Adjust check_*_overflow() kern-doc to reflect resultsinclude/linux/overflow.h+9 -121 reply
2/3overflow: Introduce wrapping_add(), wrapping_sub(), and wrapping_mul()include/linux/overflow.h lib/overflow_kunit.c+68 -40 replies
3/3overflow: Introduce wrapping_assign_add() and wrapping_assign_sub()include/linux/overflow.h lib/overflow_kunit.c+75 -02 replies

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchGustavo A. R. SilvaMarco ElverMark Rutland
1/3R-b A-b
2/3R-b R-b A-b
3/3R-b A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v7 thread

Cover letter [PATCH v7 0/3] overflow: Introduce wrapping helpers

v7: - further kern-doc cleanups (Mark)
v6: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

Hi,

In preparation for gaining instrumentation for signed[1], unsigned[2], and pointer[3] wrap-around, expand the overflow header to include wrap-around helpers that can be used to annotate arithmetic where wrapped calculations are expected (e.g. atomics).

After spending time getting the unsigned integer wrap-around sanitizer running warning-free on a basic x86_64 boot[4], I think the add/sub/mul helpers first argument being the output type makes the most sense (as suggested by Rasmus).

-Kees

Kees Cook (3):
overflow: Adjust check_*_overflow() kern-doc to reflect results
overflow: Introduce wrapping_add(), wrapping_sub(), and wrapping_mul()
overflow: Introduce wrapping_assign_add() and wrapping_assign_sub()

 include/linux/overflow.h | 101 ++++++++++++++++++++++++++++++++++-----
 lib/overflow_kunit.c     |  67 ++++++++++++++++++++++++--
 2 files changed, 152 insertions(+), 16 deletions(-)
Signature · 1 line
2.34.1