Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp627240imu; Mon, 5 Nov 2018 06:28:14 -0800 (PST) X-Google-Smtp-Source: AJdET5eypGzAO2DrQYUkk/TriisB6Syq95ehMAUS1bdQud+NGU74nnuPgZvzpzMtVtOsPFb/nuZS X-Received: by 2002:a17:902:b7c5:: with SMTP id v5-v6mr10698353plz.40.1541428094018; Mon, 05 Nov 2018 06:28:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541428093; cv=none; d=google.com; s=arc-20160816; b=TrqvXyd5jSPiCsud8tzQl6pwDVr/dYPAG3Jm+xIR4gdvXjnIqxIzwH5cX+ZiqWQtWT t9dHwiNyF+GJTp6nT5yv1RzrA3N29SY0U1iY0Lyv0SbyZKYF/sMcPDfGLj2TDCKhAVsh 5J8ekvfDBJKngbkbufCLpp6fWzanvBwVANJuiueUUH4DfyGl/c61T7o8E1qJb+aQrPmi EiI9BJPHHN1ge+slllcXMgKpkAHRZ7SlJ2tmIK64IU/bywif47TI5L+0/tpoB68jPP9F RyZupJKc8mRaViy8vzXzskibdvuCieAedPh3z9VPat0qJX3AjdIlcRR+njGmgbY72Rgx JQlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=bDIKyuSp9LLH9BqGVqhJP/hbXdOmufd3UQW+85NbV+8=; b=rpCht6z+yFk7U03QKkaXQRApqhWvNShVydIMDgV/6mwMGn3NSUy08RUwjnmiJvK4bO YXa2yeDkaqrlSXiuQrBh9iaWIcUvqQAykFvOTU87rIdX9LeG2pL7EWAuoE9X+ysJgOuH omz9SmQXj8do1UAHCsFe/D9KJ10cJLIAywlixvgSMITnjW2fZU6ADzA5SRya4Kb/3LOg qD0pnDB30Ry7/brBwzEXpAqmUxW3pRFCKVYzIRhtoG4zOAAgE6tp/CKHQfjNujJmsA3H /F2Q+FuiauRWZF5LLXXz+ylDu5eQWbYBPCAumWHrrEsnTue29dm/IsMTmR3H8Y36x0uj /Mbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=rykwNpJ5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f1-v6si41738804pgv.468.2018.11.05.06.27.58; Mon, 05 Nov 2018 06:28:13 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=merlin.20170209 header.b=rykwNpJ5; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729991AbeKEXqN (ORCPT + 99 others); Mon, 5 Nov 2018 18:46:13 -0500 Received: from merlin.infradead.org ([205.233.59.134]:38728 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726173AbeKEXqM (ORCPT ); Mon, 5 Nov 2018 18:46:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=bDIKyuSp9LLH9BqGVqhJP/hbXdOmufd3UQW+85NbV+8=; b=rykwNpJ5nCzznn4Jucrx26gsq +JH4MPOXMJ+pyWb4JU6Gj3AHUuigkLWXl9uB/Dn7tVxRF87Ptd16aKHV8RQW0nrfm1DqdeIboPOpJ w2ytLOtAu3dVg33KI46V7z703S+T8XnZkGmRqV7gYgNLAL7GqHnE5WapNvgfRsWGdMSJ3gMnO0cyk gZVOd/rhM4BbpGP6BT2UJhVvVWmX/HGnTnK8eZWbA8bXiFbqStjSfBDyJ0iWJjwae4/JjrmnjZYSd F2LwaakSwVKD/wKt8d3+feCrExhqyR6midZcsGLi3jSKyovhcXMJjIGoqUavssAC/YMHmpKsUr2NC QLv2vSwLQ==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=hirez.programming.kicks-ass.net) by merlin.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gJfoG-0006kE-Li; Mon, 05 Nov 2018 14:24:57 +0000 Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 3223A2029F9FF; Mon, 5 Nov 2018 15:24:53 +0100 (CET) Date: Mon, 5 Nov 2018 15:24:53 +0100 From: Peter Zijlstra To: Andrey Ryabinin Cc: Trond Myklebust , "mark.rutland@arm.com" , "linux-kernel@vger.kernel.org" , "ralf@linux-mips.org" , "jlayton@kernel.org" , "linuxppc-dev@lists.ozlabs.org" , "bfields@fieldses.org" , "linux-mips@linux-mips.org" , "linux@roeck-us.net" , "linux-nfs@vger.kernel.org" , "akpm@linux-foundation.org" , "will.deacon@arm.com" , "boqun.feng@gmail.com" , "paul.burton@mips.com" , "anna.schumaker@netapp.com" , "jhogan@kernel.org" , "netdev@vger.kernel.org" , "davem@davemloft.net" , "arnd@arndb.de" , "paulus@samba.org" , "mpe@ellerman.id.au" , "benh@kernel.crashing.org" , Paul McKenney , dvyukov@google.com, willy@infradead.org Subject: Re: [RFC PATCH] lib: Introduce generic __cmpxchg_u64() and use it where needed Message-ID: <20181105142453.GA22449@hirez.programming.kicks-ass.net> References: <1541015538-11382-1-git-send-email-linux@roeck-us.net> <20181031213240.zhh7dfcm47ucuyfl@pburton-laptop> <20181031220253.GA15505@roeck-us.net> <20181031233235.qbedw3pinxcuk7me@pburton-laptop> <4e2438a23d2edf03368950a72ec058d1d299c32e.camel@hammerspace.com> <20181101131846.biyilr2msonljmij@lakrids.cambridge.arm.com> <20181101145926.GE3178@hirez.programming.kicks-ass.net> <20181101163212.GF3159@hirez.programming.kicks-ass.net> <5a846924-e642-d9d1-4e0e-810bd4d01c26@virtuozzo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <5a846924-e642-d9d1-4e0e-810bd4d01c26@virtuozzo.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > __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@hirez:~/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@hirez:~/tmp$ gcc -fsanitize=signed-integer-overflow,shift -fwrapv overflow.c ; ./a.out -4