Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp763836lqd; Wed, 24 Apr 2024 16:57:17 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV1fC0GUITGDFCG30xxoGIMkUOV/9lTpNWY0m5dkFYhJ1i9Q3AcpMPW6YblutxbvRDF32h130M74zxmZkZ0yvpxYDTLWVhMhGs849d+ZA== X-Google-Smtp-Source: AGHT+IHqw93nSU2bJDBYGqVdmGa6UPKFST1QVEdWB3VC4BYbbaAzOvDKG/PzK7Mx+pfC8wEF6N8t X-Received: by 2002:a17:902:d2ce:b0:1e1:1791:3681 with SMTP id n14-20020a170902d2ce00b001e117913681mr5428647plc.61.1714003037047; Wed, 24 Apr 2024 16:57:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714003037; cv=pass; d=google.com; s=arc-20160816; b=d4mwchpUFkRb6nL5zYl5eknjX4TWvZF4RNIpWDBaY30Q0WlVbJLVZOZsa8GuO7fRQh ucSzLz6aBBcdswhK+wnM8B/ikpJVc8wXMOH9ZTEgwMjELXfd4t12TGJ9AfN6F0PL+fjv CFBcBFzSPAxh5AElBV4L3lc80Mg9xjrP09Pyy4jr87JaR2MglLAi9BU0rbEnY6BclbeU j4dbOF3+hNfuOrK+1ddA4vm+ZUBQ0DHz9a3YjW71FoMqKjmqwnehwP+FInLL88B9BsP/ 14dEw6XrPJPBQEXqUZr0CFLKWFme8mt9+6VyYEemP985YGiTn9rdUNZ7rCLvBeODAKD4 PQrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=WC01BChjfLiCxvTf81kaHLBrwZI8ocIBxX8N7T/Yecw=; fh=utiYzFb3RiUICF3u+8iAeY6OieAhY8VNVm1gII1PQfw=; b=Am0Taowj7dF1ejnnUy0ydneo2DSaXgnraRfbSYskdTSkul1fuL9bT3o+IEggG7aIE+ ecxfMdNh7BIklNX8i+K6hTTf5FNDlWJXybNQf50Q+pjaD3Mj9PhjPETFUexPEJBNDEVI KjOSw6FBWn8qogchJat5zsDSD5nxWSYUcySfAYHwP+ad/68fQB1PnjEpZpCVDwIvS4PY EaP2ldAk1HzRodEVW+fMbIF6OJBqvOwCQbIddWjhhEdu+gA6zb2wMOru/0dng3ZwjWp9 aASJtO9gx+hwZkQ7Sg/RGsAy4A0Zo1peUVvXkmLj+xQ7/uVgGPKnGb3rlq4sJdRVl7or yguA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=RE5QUlyV; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-157796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157796-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j10-20020a170902da8a00b001e3cd26cef3si12297257plx.503.2024.04.24.16.57.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 16:57:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-157796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=RE5QUlyV; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-157796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-157796-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D9E56287BE4 for ; Wed, 24 Apr 2024 22:42:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5ED9716E888; Wed, 24 Apr 2024 22:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="RE5QUlyV" Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0210016DEDE; Wed, 24 Apr 2024 22:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.50.34 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713998522; cv=none; b=XhdVhszAlzSDuyAF8KXvf/DFc+RF2Tzky2/pFOOBblIl5DDeEzBbxa2ud8DF5qpMjBJOtq/3CDeXz0TIt3Ro2PZoO9wy9Z6XE7CeKMYspHWCAMC4X6HPR+uzUPPzSQjZ/q4xzqgGI7+IjoOE8oN//y9N3elbZSjQCzoSA6lV5rE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713998522; c=relaxed/simple; bh=I84fytRW8RAO4I14CXSokqeSS4YK/44PsOPnBAk8gSw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=CKjUgaJbbGtENhLimanAVBRWF5df5VgW642bC9afqejF55RyIRjNvYQ5Gx2zBlZzSBop6uzQZEzreJtk25xcb0bspnw03jHGd9VMTI7r51qG5vOZncTgC8bjW4UXKjdF0dTluoVTXO92YOhaF9Km5GfdxSJKCuRNf7fxwJY9cgc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=RE5QUlyV; arc=none smtp.client-ip=90.155.50.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.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; bh=WC01BChjfLiCxvTf81kaHLBrwZI8ocIBxX8N7T/Yecw=; b=RE5QUlyV3i854Efn5mgdt2iDsf RB5NXVlzPmUD48spV4HYj2oJcTLmI4QMgCIFURVCuSD2pxnQjesnzLaFUBrUgfUce/3Hf8EMSDkS/ UeBYFNSok9xOOKBwDK1svwGsSzphKFrGZCFSuwqYip4nDqtTW0cZ9Np+6TWxcGMMR0legu/kfk4G9 EZ1TcCVeCPKK2ffgaPOw151PEwE+jPlNWWC7c1Vq8Lvm2W7LYvz9zLNmAZ0Qq5zsa5XRUe23so/aC G5JDnadmOnznrDXzoDYEWoZmD4ek1OAo/6u3JxrFXPXTRG7Ay8HrgUUXj1rAfGGrAj2wbTrDM6BtN Ol+D4lxQ==; Received: from j130084.upc-j.chello.nl ([24.132.130.84] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzlJ8-00000001pU6-173r; Wed, 24 Apr 2024 22:41:42 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id D0FE330043E; Thu, 25 Apr 2024 00:41:41 +0200 (CEST) Date: Thu, 25 Apr 2024 00:41:41 +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: <20240424224141.GX40213@noisy.programming.kicks-ass.net> References: <20240424191225.work.780-kees@kernel.org> <20240424191740.3088894-1-keescook@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240424191740.3088894-1-keescook@chromium.org> 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.