From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6F93AC4345F for ; Wed, 24 Apr 2024 22:54:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4nJuXx3px6446OYfuHxrrX7h0AMp0F6AvQLJSpWLYyw=; b=0FVF8K38z2jdZJ jcqSvyc8kD8xncMN8k+r1xNA/bCSh/p/Oetrfh30vN1e4tnTj+Ihl5hTSaQP+jPD6XxIjkyUO67Ct 2T1iRrOM4otAnmZhtRwvf78/rlVz6MsbgXBzRUt2eU/WPjNDs/36ckUqpCZDIw4ZEsw+FFhGoMVV9 6I5Hwoj2w38TYZj9tp8a8Cy4PjcFvPhcz8AoG17TgkAWk5buvGqOM3ZJ4o4cSdbnnPL2rXnYdWLuM vPw+NyTPFhZj35JtytdG5STFxl+sfSUtkrFtRPHaEWBcTYi9tREhpQeW8qm14DYet3Me2Nf2fLDJh f2h7rkkbShrwKXSTDhjQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzlVl-00000006Hjt-2cYL; Wed, 24 Apr 2024 22:54:45 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzlVk-00000006HjV-1Q7I for linux-arm-kernel@bombadil.infradead.org; Wed, 24 Apr 2024 22:54:44 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; 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; bh=0/eQjSTv8D6eZQAQWbqT2LJmg+Blfc0mgxAHCYd1hAM=; b=V23yVE2fnmFqMNMneHrFe2nxSM zIWX162MuXqByjLfKBbVwbcp0AzY6fOr+0zfvw3ceFos1ccHbkuaHaEJFbPDycFIj7r7MKcF3AoF9 Ud6OrWWxfWsmc/D/+WPeVi1hgsxDm+xxuEvPjvu6V9rqYd4gytTsn/nUr0lGOIgRmdOThR/yErVzY Mp0SW0j3wOVIs5oVCS2IWT6ty3aWNKwgTx+o7gyzjjIXeUcvMSvHWtx/LYxCM2uEFyk5JbJnKhQqI ksWgC3vKtJidBTEq1tb37xRzuRV/Cv8knq5a8vixM6EfUhAnYGC4lr+jvFKN79uqdv+0symsrN1UX sZ19Qvcw==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzlVc-0000000EdKy-3Czb; Wed, 24 Apr 2024 22:54:37 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 6ACAD30043E; Thu, 25 Apr 2024 00:54:36 +0200 (CEST) Date: Thu, 25 Apr 2024 00:54:36 +0200 From: Peter Zijlstra To: Kees Cook Cc: Mark Rutland , Will Deacon , Boqun Feng , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Jakub Kicinski , Catalin Marinas , Arnd Bergmann , Andrew Morton , "David S. Miller" , David Ahern , Eric Dumazet , Paolo Abeni , "Paul E. McKenney" , Uros Bizjak , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 1/4] locking/atomic/x86: Silence intentional wrapping addition Message-ID: <20240424225436.GY40213@noisy.programming.kicks-ass.net> References: <20240424191225.work.780-kees@kernel.org> <20240424191740.3088894-1-keescook@chromium.org> <20240424224141.GX40213@noisy.programming.kicks-ass.net> <202404241542.6AFC3042C1@keescook> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <202404241542.6AFC3042C1@keescook> X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, Apr 24, 2024 at 03:45:07PM -0700, Kees Cook wrote: > On Thu, Apr 25, 2024 at 12:41:41AM +0200, Peter Zijlstra wrote: > > On Wed, Apr 24, 2024 at 12:17:34PM -0700, Kees Cook wrote: > > > > > @@ -82,7 +83,7 @@ static __always_inline bool arch_atomic_add_negative(int i, atomic_t *v) > > > > > > static __always_inline int arch_atomic_add_return(int i, atomic_t *v) > > > { > > > - return i + xadd(&v->counter, i); > > > + return wrapping_add(int, i, xadd(&v->counter, i)); > > > } > > > #define arch_atomic_add_return arch_atomic_add_return > > > > this is going to get old *real* quick :-/ > > > > This must be the ugliest possible way to annotate all this, and then > > litter the kernel with all this... urgh. > > I'm expecting to have explicit wrapping type annotations soon[1], but for > the atomics, it's kind of a wash on how intrusive the annotations get. I > had originally wanted to mark the function (as I did in other cases) > rather than using the helper, but Mark preferred it this way. I'm happy > to do whatever! :) > > -Kees > > [1] https://github.com/llvm/llvm-project/pull/86618 This is arse-about-face. Signed stuff wraps per -fno-strict-overflow. We've been writing code for years under that assumption. You want to mark the non-wrapping case. _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel