[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20181105142453.GA22449@hirez.programming.kicks-ass.net>
Date: Mon, 5 Nov 2018 15:24:53 +0100
From: Peter Zijlstra <peterz@...radead.org>
To: Andrey Ryabinin <aryabinin@...tuozzo.com>
Cc: Trond Myklebust <trondmy@...merspace.com>,
"mark.rutland@....com" <mark.rutland@....com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"ralf@...ux-mips.org" <ralf@...ux-mips.org>,
"jlayton@...nel.org" <jlayton@...nel.org>,
"linuxppc-dev@...ts.ozlabs.org" <linuxppc-dev@...ts.ozlabs.org>,
"bfields@...ldses.org" <bfields@...ldses.org>,
"linux-mips@...ux-mips.org" <linux-mips@...ux-mips.org>,
"linux@...ck-us.net" <linux@...ck-us.net>,
"linux-nfs@...r.kernel.org" <linux-nfs@...r.kernel.org>,
"akpm@...ux-foundation.org" <akpm@...ux-foundation.org>,
"will.deacon@....com" <will.deacon@....com>,
"boqun.feng@...il.com" <boqun.feng@...il.com>,
"paul.burton@...s.com" <paul.burton@...s.com>,
"anna.schumaker@...app.com" <anna.schumaker@...app.com>,
"jhogan@...nel.org" <jhogan@...nel.org>,
"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
"davem@...emloft.net" <davem@...emloft.net>,
"arnd@...db.de" <arnd@...db.de>,
"paulus@...ba.org" <paulus@...ba.org>,
"mpe@...erman.id.au" <mpe@...erman.id.au>,
"benh@...nel.crashing.org" <benh@...nel.crashing.org>,
Paul McKenney <paulmck@...ux.vnet.ibm.com>, dvyukov@...gle.com,
willy@...radead.org
Subject: Re: [RFC PATCH] lib: Introduce generic __cmpxchg_u64() and use it
where needed
On Fri, Nov 02, 2018 at 07:19:15PM +0300, Andrey Ryabinin wrote:
> UBSAN warns about signed overflows despite -fno-strict-overflow if gcc version is < 8.
> I have learned recently that UBSAN in GCC 8 ignores signed overflows if -fno-strict-overflow of fwrapv is used.
>
> $ cat signed_overflow.c
> #include <stdio.h>
>
> __attribute__((noinline))
> int foo(int a, int b)
> {
> return a+b;
s/+/<</
> }
>
> int main(void)
> {
> int a = 0x7fffffff;
> int b = 2;
> printf("%d\n", foo(a,b));
> return 0;
> }
It also seem to affect 'shift':
peterz@...ez:~/tmp$ gcc -fsanitize=signed-integer-overflow,shift overflow.c ; ./a.out
overflow.c:6:11: runtime error: left shift of 2147483647 by 2 places cannot be represented in type 'int'
-4
peterz@...ez:~/tmp$ gcc -fsanitize=signed-integer-overflow,shift -fwrapv overflow.c ; ./a.out
-4
Powered by blists - more mailing lists