From: Kees Cook <kees@kernel.org>
To: Justin Stitt <justinstitt@google.com>
Cc: Kees Cook <kees@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
Masahiro Yamada <masahiroy@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nicolas Schier <nicolas@fjasle.eu>,
Marco Elver <elver@google.com>,
Andrey Konovalov <andreyknvl@gmail.com>,
Andrey Ryabinin <ryabinin.a.a@gmail.com>,
linux-kbuild@vger.kernel.org, kasan-dev@googlegroups.com,
linux-hardening@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Miguel Ojeda <ojeda@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Hao Luo <haoluo@google.com>,
Przemek Kitszel <przemyslaw.kitszel@intel.com>,
Bill Wendling <morbo@google.com>,
Jakub Kicinski <kuba@kernel.org>,
Tony Ambardar <tony.ambardar@gmail.com>,
Alexander Potapenko <glider@google.com>,
Jan Hendrik Farr <kernel@jfarr.cc>,
Alexander Lobakin <aleksander.lobakin@intel.com>,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev
Subject: [PATCH 2/3] ubsan/overflow: Enable pattern exclusions
Date: Thu, 6 Mar 2025 20:19:10 -0800 [thread overview]
Message-ID: <20250307041914.937329-2-kees@kernel.org> (raw)
In-Reply-To: <20250307040948.work.791-kees@kernel.org>
To make integer wrap-around mitigation actually useful, the associated
sanitizers must not instrument cases where the wrap-around is explicitly
defined (e.g. "-2UL"), being tested for (e.g. "if (a + b < a)"), or
where it has no impact on code flow (e.g. "while (var--)"). Enable
pattern exclusions for the integer wrap sanitizers.
Signed-off-by: Kees Cook <kees@kernel.org>
---
Cc: Justin Stitt <justinstitt@google.com>
Cc: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Masahiro Yamada <masahiroy@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nicolas Schier <nicolas@fjasle.eu>
Cc: Marco Elver <elver@google.com>
Cc: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: linux-kbuild@vger.kernel.org
Cc: kasan-dev@googlegroups.com
Cc: linux-hardening@vger.kernel.org
---
lib/Kconfig.ubsan | 1 +
scripts/Makefile.ubsan | 1 +
2 files changed, 2 insertions(+)
diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan
index 63e5622010e0..888c2e72c586 100644
--- a/lib/Kconfig.ubsan
+++ b/lib/Kconfig.ubsan
@@ -120,6 +120,7 @@ config UBSAN_INTEGER_WRAP
bool "Perform checking for integer arithmetic wrap-around"
default UBSAN
depends on !COMPILE_TEST
+ depends on $(cc-option,-fsanitize-undefined-ignore-overflow-pattern=all)
depends on $(cc-option,-fsanitize=signed-integer-overflow)
depends on $(cc-option,-fsanitize=unsigned-integer-overflow)
depends on $(cc-option,-fsanitize=implicit-signed-integer-truncation)
diff --git a/scripts/Makefile.ubsan b/scripts/Makefile.ubsan
index 4fad9afed24c..233379c193a7 100644
--- a/scripts/Makefile.ubsan
+++ b/scripts/Makefile.ubsan
@@ -15,6 +15,7 @@ ubsan-cflags-$(CONFIG_UBSAN_TRAP) += $(call cc-option,-fsanitize-trap=undefined
export CFLAGS_UBSAN := $(ubsan-cflags-y)
ubsan-integer-wrap-cflags-$(CONFIG_UBSAN_INTEGER_WRAP) += \
+ -fsanitize-undefined-ignore-overflow-pattern=all \
-fsanitize=signed-integer-overflow \
-fsanitize=unsigned-integer-overflow \
-fsanitize=implicit-signed-integer-truncation \
--
2.34.1
next prev parent reply other threads:[~2025-03-07 4:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-07 4:19 [PATCH 0/3] ubsan/overflow: Enable pattern exclusions Kees Cook
2025-03-07 4:19 ` [PATCH 1/3] ubsan/overflow: Rework integer overflow sanitizer option to turn on everything Kees Cook
2025-03-13 15:29 ` Marco Elver
2025-03-14 0:04 ` Kees Cook
2025-03-07 4:19 ` Kees Cook [this message]
2025-03-07 23:12 ` [PATCH 2/3] ubsan/overflow: Enable pattern exclusions Justin Stitt
2025-03-07 4:19 ` [PATCH 3/3] ubsan/overflow: Enable ignorelist parsing and add type filter Kees Cook
2025-03-07 23:33 ` Justin Stitt
2025-03-07 23:39 ` Justin Stitt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250307041914.937329-2-kees@kernel.org \
--to=kees@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=aleksander.lobakin@intel.com \
--cc=andreyknvl@gmail.com \
--cc=elver@google.com \
--cc=glider@google.com \
--cc=gustavoars@kernel.org \
--cc=haoluo@google.com \
--cc=justinstitt@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=kernel@jfarr.cc \
--cc=kuba@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=masahiroy@kernel.org \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nicolas@fjasle.eu \
--cc=ojeda@kernel.org \
--cc=przemyslaw.kitszel@intel.com \
--cc=ryabinin.a.a@gmail.com \
--cc=tony.ambardar@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox