From: Arnd Bergmann <arnd@kernel.org> To: kasan-dev@googlegroups.com, ryabinin.a.a@gmail.com Cc: glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, vincenzo.frascino@arm.com, elver@google.com, linux-media@vger.kernel.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, ardb@kernel.org, mchehab@kernel.org, Arnd Bergmann <arnd@arndb.de>, Dan Carpenter <dan.carpenter@linaro.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Kees Cook <keescook@chromium.org>, Josh Poimboeuf <jpoimboe@kernel.org>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, llvm@lists.linux.dev Subject: [PATCH] [RFC] ubsan: disallow bounds checking with gcov on broken gcc Date: Thu, 1 Jun 2023 17:18:11 +0200 [thread overview] Message-ID: <20230601151832.3632525-1-arnd@kernel.org> (raw) From: Arnd Bergmann <arnd@arndb.de> Combining UBSAN and GCOV in randconfig builds results in a number of stack frame size warnings, such as: crypto/twofish_common.c:683:1: error: the frame size of 2040 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c:1589:1: error: the frame size of 1696 bytes is larger than 1400 bytes [-Werror=frame-larger-than=] drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c:754:1: error: the frame size of 1260 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] drivers/staging/media/ipu3/ipu3-css-params.c:1206:1: error: the frame size of 1080 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] drivers/staging/media/rkvdec/rkvdec-vp9.c:1042:1: error: the frame size of 2176 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] drivers/staging/media/rkvdec/rkvdec-vp9.c:995:1: error: the frame size of 1656 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] I managed to track this down to the -fsanitize=bounds option clashing with the -fprofile-arcs option, which leads a lot of spilled temporary variables in generated instrumentation code. Hopefully this can be addressed in future gcc releases the same way that clang handles the combination, but for existing compiler releases, it seems best to disable one of the two flags. This can be done either globally by just not passing both at the same time, or locally using the no_sanitize or no_instrument_function attributes in the affected functions. Try the simplest approach here, and turn off -fsanitize=bounds on gcc when GCOV is enabled, leaving the rest of UBSAN working. Doing this globally also helps avoid inefficient code from the same problem that did not push the build over the warning limit. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/stable/6b1a0ee6-c78b-4873-bfd5-89798fce9899@kili.mountain/ Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110074 Link: https://godbolt.org/z/zvf7YqK5K Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- lib/Kconfig.ubsan | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan index f7cbbad2bb2f4..8f71ff8f27576 100644 --- a/lib/Kconfig.ubsan +++ b/lib/Kconfig.ubsan @@ -29,6 +29,8 @@ config UBSAN_TRAP config CC_HAS_UBSAN_BOUNDS_STRICT def_bool $(cc-option,-fsanitize=bounds-strict) + # work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110074 + depends on GCC_VERSION > 140000 || !GCOV_PROFILE_ALL help The -fsanitize=bounds-strict option is only available on GCC, but uses the more strict handling of arrays that includes knowledge -- 2.39.2
WARNING: multiple messages have this Message-ID (diff)
From: Arnd Bergmann <arnd@kernel.org> To: kasan-dev@googlegroups.com, ryabinin.a.a@gmail.com Cc: glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, vincenzo.frascino@arm.com, elver@google.com, linux-media@vger.kernel.org, linux-crypto@vger.kernel.org, herbert@gondor.apana.org.au, ardb@kernel.org, mchehab@kernel.org, Arnd Bergmann <arnd@arndb.de>, Dan Carpenter <dan.carpenter@linaro.org>, Matthias Brugger <matthias.bgg@gmail.com>, AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>, Nathan Chancellor <nathan@kernel.org>, Nick Desaulniers <ndesaulniers@google.com>, Tom Rix <trix@redhat.com>, Kees Cook <keescook@chromium.org>, Josh Poimboeuf <jpoimboe@kernel.org>, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, llvm@lists.linux.dev Subject: [PATCH] [RFC] ubsan: disallow bounds checking with gcov on broken gcc Date: Thu, 1 Jun 2023 17:18:11 +0200 [thread overview] Message-ID: <20230601151832.3632525-1-arnd@kernel.org> (raw) From: Arnd Bergmann <arnd@arndb.de> Combining UBSAN and GCOV in randconfig builds results in a number of stack frame size warnings, such as: crypto/twofish_common.c:683:1: error: the frame size of 2040 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] drivers/media/platform/mediatek/vcodec/vdec/vdec_vp9_req_lat_if.c:1589:1: error: the frame size of 1696 bytes is larger than 1400 bytes [-Werror=frame-larger-than=] drivers/media/platform/verisilicon/hantro_g2_vp9_dec.c:754:1: error: the frame size of 1260 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] drivers/staging/media/ipu3/ipu3-css-params.c:1206:1: error: the frame size of 1080 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] drivers/staging/media/rkvdec/rkvdec-vp9.c:1042:1: error: the frame size of 2176 bytes is larger than 2048 bytes [-Werror=frame-larger-than=] drivers/staging/media/rkvdec/rkvdec-vp9.c:995:1: error: the frame size of 1656 bytes is larger than 1024 bytes [-Werror=frame-larger-than=] I managed to track this down to the -fsanitize=bounds option clashing with the -fprofile-arcs option, which leads a lot of spilled temporary variables in generated instrumentation code. Hopefully this can be addressed in future gcc releases the same way that clang handles the combination, but for existing compiler releases, it seems best to disable one of the two flags. This can be done either globally by just not passing both at the same time, or locally using the no_sanitize or no_instrument_function attributes in the affected functions. Try the simplest approach here, and turn off -fsanitize=bounds on gcc when GCOV is enabled, leaving the rest of UBSAN working. Doing this globally also helps avoid inefficient code from the same problem that did not push the build over the warning limit. Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Link: https://lore.kernel.org/stable/6b1a0ee6-c78b-4873-bfd5-89798fce9899@kili.mountain/ Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110074 Link: https://godbolt.org/z/zvf7YqK5K Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- lib/Kconfig.ubsan | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Kconfig.ubsan b/lib/Kconfig.ubsan index f7cbbad2bb2f4..8f71ff8f27576 100644 --- a/lib/Kconfig.ubsan +++ b/lib/Kconfig.ubsan @@ -29,6 +29,8 @@ config UBSAN_TRAP config CC_HAS_UBSAN_BOUNDS_STRICT def_bool $(cc-option,-fsanitize=bounds-strict) + # work around https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110074 + depends on GCC_VERSION > 140000 || !GCOV_PROFILE_ALL help The -fsanitize=bounds-strict option is only available on GCC, but uses the more strict handling of arrays that includes knowledge -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2023-06-01 15:18 UTC|newest] Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-06-01 15:18 Arnd Bergmann [this message] 2023-06-01 15:18 ` [PATCH] [RFC] ubsan: disallow bounds checking with gcov on broken gcc Arnd Bergmann 2023-06-01 16:14 ` Kees Cook 2023-06-01 16:14 ` Kees Cook 2023-06-01 17:50 ` Arnd Bergmann 2023-06-01 17:50 ` Arnd Bergmann 2023-06-01 18:28 ` Kees Cook 2023-06-01 18:28 ` Kees Cook 2023-06-01 19:03 ` Arnd Bergmann 2023-06-01 19:03 ` Arnd Bergmann
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=20230601151832.3632525-1-arnd@kernel.org \ --to=arnd@kernel.org \ --cc=andreyknvl@gmail.com \ --cc=angelogioacchino.delregno@collabora.com \ --cc=ardb@kernel.org \ --cc=arnd@arndb.de \ --cc=dan.carpenter@linaro.org \ --cc=dvyukov@google.com \ --cc=elver@google.com \ --cc=glider@google.com \ --cc=herbert@gondor.apana.org.au \ --cc=jpoimboe@kernel.org \ --cc=kasan-dev@googlegroups.com \ --cc=keescook@chromium.org \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-crypto@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ --cc=linux-mediatek@lists.infradead.org \ --cc=llvm@lists.linux.dev \ --cc=matthias.bgg@gmail.com \ --cc=mchehab@kernel.org \ --cc=nathan@kernel.org \ --cc=ndesaulniers@google.com \ --cc=ryabinin.a.a@gmail.com \ --cc=trix@redhat.com \ --cc=vincenzo.frascino@arm.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.