public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] overflow: Introduce wrapping helpers
@ 2024-02-06 10:31 Kees Cook
  2024-02-06 10:31 ` [PATCH v4 1/3] overflow: Adjust check_*_overflow() kern-doc to reflect results Kees Cook
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Kees Cook @ 2024-02-06 10:31 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Kees Cook, Gustavo A. R. Silva, Marco Elver, Eric Biggers,
	Mark Rutland, Andrew Morton, linux-kernel, linux-hardening

v4:
 - use __builtin directly (marco)
 - rename to wrapping_* (eric)
 - update kern-doc (rasmus)
v3: https://lore.kernel.org/all/20240205090854.make.507-kees@kernel.org/
v2: https://lore.kernel.org/all/20240130220218.it.154-kees@kernel.org/
v1: https://lore.kernel.org/lkml/20240129182845.work.694-kees@kernel.org/

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

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 (3):
  overflow: Adjust check_*_overflow() kern-doc to reflect results
  overflow: Introduce wrapping_add(), wrapping_sub(), and wrapping_mul()
  overflow: Introduce wrapping_inc() and wrapping_dec()

 include/linux/overflow.h | 104 ++++++++++++++++++++++++++++++++++-----
 lib/overflow_kunit.c     |  67 +++++++++++++++++++++++--
 2 files changed, 155 insertions(+), 16 deletions(-)

-- 
2.34.1


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

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

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 10:31 [PATCH v4 0/3] overflow: Introduce wrapping helpers Kees Cook
2024-02-06 10:31 ` [PATCH v4 1/3] overflow: Adjust check_*_overflow() kern-doc to reflect results Kees Cook
2024-02-06 16:36   ` Gustavo A. R. Silva
2024-02-06 10:31 ` [PATCH v4 2/3] overflow: Introduce wrapping_add(), wrapping_sub(), and wrapping_mul() Kees Cook
2024-02-06 16:54   ` Gustavo A. R. Silva
2024-02-07  9:35     ` Kees Cook
2024-02-06 10:31 ` [PATCH v4 3/3] overflow: Introduce wrapping_inc() and wrapping_dec() Kees Cook

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