[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20151208155914.d0b005c82906f3203660fd47@linux-foundation.org>
Date: Tue, 8 Dec 2015 15:59:14 -0800
From: Andrew Morton <akpm@...ux-foundation.org>
To: Andrey Ryabinin <aryabinin@...tuozzo.com>
Cc: <linux-kernel@...r.kernel.org>,
Peter Zijlstra <peterz@...radead.org>,
Sasha Levin <sasha.levin@...cle.com>,
Randy Dunlap <rdunlap@...radead.org>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Jonathan Corbet <corbet@....net>,
Michal Marek <mmarek@...e.cz>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>,
"H. Peter Anvin" <hpa@...or.com>,
Yury Gribov <y.gribov@...sung.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Konstantin Khlebnikov <koct9i@...il.com>,
Kostya Serebryany <kcc@...gle.com>, <x86@...nel.org>,
<linux-doc@...r.kernel.org>, <linux-kbuild@...r.kernel.org>
Subject: Re: [PATCH v4 3/3] UBSAN: run-time undefined behavior sanity
checker
On Thu, 3 Dec 2015 18:50:07 +0300 Andrey Ryabinin <aryabinin@...tuozzo.com> wrote:
> UBSAN uses compile-time instrumentation to catch undefined behavior (UB).
> Compiler inserts code that perform certain kinds of checks before
> operations that could cause UB. If check fails (i.e. UB detected)
> __ubsan_handle_* function called to print error message.
>
> So the most of the work is done by compiler. This patch just
> implements ubsan handlers printing errors.
>
> GCC has this capability since 4.9.x [1] (see -fsanitize=undefined
> option and its suboptions).
> However GCC 5.x has more checkers implemented [2].
> Article [3] has a bit more details about UBSAN in the GCC.
>
> ...
>
> +#ifdef CONFIG_ARCH_SUPPORTS_INT128
> +typedef __int128 s_max;
> +typedef unsigned __int128 u_max;
> +#else
In file included from lib/ubsan.c:21:
lib/ubsan.h:77: error: expected '=', ',', ';', 'asm' or '__attribute__' before 's_max'
lib/ubsan.h:78: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'u_max'
lib/ubsan.c:89: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'get_signed_val'
gcc-4.4.4 doesn't appear to like __int128. The only other use of
__int128 is include/linux/math64.h:mul_u64_u32_shr() and it uses
defined(__SIZEOF_INT128__) as well.
Using that gives me
lib/ubsan.c: In function 'val_to_string':
lib/ubsan.c:127: warning: right shift count >= width of type
lib/ubsan.c:128: warning: right shift count >= width of type
so I bodged that site too. I need to get an mmotm release out the door.
--- a/lib/ubsan.c~ubsan-run-time-undefined-behavior-sanity-checker-fix-3
+++ a/lib/ubsan.c
@@ -120,7 +120,7 @@ static void val_to_string(char *str, siz
{
if (type_is_int(type)) {
if (type_bit_width(type) == 128) {
-#ifdef CONFIG_ARCH_SUPPORTS_INT128
+#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__)
u_max val = get_unsigned_val(type, value);
scnprintf(str, size, "0x%08x%08x%08x%08x",
--- a/lib/ubsan.h~ubsan-run-time-undefined-behavior-sanity-checker-fix-3
+++ a/lib/ubsan.h
@@ -73,7 +73,7 @@ struct invalid_value_data {
struct type_descriptor *type;
};
-#ifdef CONFIG_ARCH_SUPPORTS_INT128
+#if defined(CONFIG_ARCH_SUPPORTS_INT128) && defined(__SIZEOF_INT128__)
typedef __int128 s_max;
typedef unsigned __int128 u_max;
#else
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists