public inbox for linux-hardening@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] overflow: Introduce wrapping helpers
@ 2024-01-30 22:06 Kees Cook
  2024-01-30 22:06 ` [PATCH v2 1/5] overflow: Adjust check_*_overflow() kern-doc to reflect results Kees Cook
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Kees Cook @ 2024-01-30 22:06 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Kees Cook, Gustavo A. R. Silva, Andrew Morton, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt, Mark Rutland,
	Miguel Ojeda, Marco Elver, Jakub Kicinski, Przemek Kitszel,
	Masahiro Yamada, linux-kernel, linux-hardening, llvm

Hi,

v2:
 - Define inc/dec_wrap() in terms of add/sub_wrap() and avoid side-effects (Rasmus)
 - Fix various typos (Rasmus)
 - Add selftests for all the new helpers
v1: https://lore.kernel.org/lkml/20240129182845.work.694-kees@kernel.org/

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 *_wrap()
helpers first argument being the output type makes the most sense (as
suggested by Rasmus).

-Kees

Link: https://github.com/KSPP/linux/issues/26 [1]
Link: https://github.com/KSPP/linux/issues/27 [2]
Link: https://github.com/KSPP/linux/issues/344 [3]
Link: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=devel/overflow/enable-unsigned-sanitizer [4]

Kees Cook (5):
  overflow: Adjust check_*_overflow() kern-doc to reflect results
  overflow: Expand check_add_overflow() for pointer addition
  overflow: Introduce add_would_overflow()
  overflow: Introduce add_wrap(), sub_wrap(), and mul_wrap()
  overflow: Introduce inc_wrap() and dec_wrap()

 include/linux/compiler_types.h |  10 +++
 include/linux/overflow.h       | 160 ++++++++++++++++++++++++++++++---
 lib/overflow_kunit.c           | 132 ++++++++++++++++++++++++---
 3 files changed, 277 insertions(+), 25 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-02-02  9:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-30 22:06 [PATCH v2 0/5] overflow: Introduce wrapping helpers Kees Cook
2024-01-30 22:06 ` [PATCH v2 1/5] overflow: Adjust check_*_overflow() kern-doc to reflect results Kees Cook
2024-01-30 22:06 ` [PATCH v2 2/5] overflow: Expand check_add_overflow() for pointer addition Kees Cook
2024-01-31  8:35   ` Rasmus Villemoes
2024-02-02  9:26     ` Kees Cook
2024-02-01  9:19   ` Przemek Kitszel
2024-02-02  9:04     ` Kees Cook
2024-01-30 22:06 ` [PATCH v2 3/5] overflow: Introduce add_would_overflow() Kees Cook
2024-01-30 22:06 ` [PATCH v2 4/5] overflow: Introduce add_wrap(), sub_wrap(), and mul_wrap() Kees Cook
2024-01-30 22:06 ` [PATCH v2 5/5] overflow: Introduce inc_wrap() and dec_wrap() Kees Cook

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox