Received: by 2002:ab2:60d1:0:b0:1f7:5705:b850 with SMTP id i17csp1209664lqm; Thu, 2 May 2024 08:10:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWS4jIfWQAM7QtIeUw9qOeuNo1FoocZI+EyZQmc5NDPlP60mUg/MrVt3n4TVLguaz2hepgxK2yZjjmWqUX1djcJ6AgP3XKiA+Dag/tNow== X-Google-Smtp-Source: AGHT+IFR5fPurBcUJn4uOfSTFqjwxV7jpf65M8AwXWtzJaERWkH1WkNd29V+WLA8XQb9lUuZvwha X-Received: by 2002:a05:6a00:4b54:b0:6f0:c214:7974 with SMTP id kr20-20020a056a004b5400b006f0c2147974mr8331244pfb.12.1714662601733; Thu, 02 May 2024 08:10:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714662601; cv=pass; d=google.com; s=arc-20160816; b=g9uIFZI3HZx+rekFmYdKWshxuUHMVXoNGwIaL9X8esLSo7w2H0/PjnoEMRMiEqe+SK wam5HSln3l7Db1tLtmmhDVD30sxgu9iddxqpZMF4S7LeY3cidw96x2cC09IZKIw0MvGj 5NnqZoRuQ0XHvXhqs2cTlHTGwnysPSoFOj9q/I4WvZT59dyUeGtA/0mBfnM4pBIMnTDr arJyZ7uw/PB8qTPBzxtXOoIaP8ToYNUCAg60oF7ws37V2DDmVpsUbIVqXgGMvH08BZIC 2zWglz7sLMUboiyuGRQE0Rn93xEb73DvbgfoKd3RUXk2aDZW1G/UnGg31/Y2bQAz1ups vtJg== 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=CQ8b7bzfCx6EpLlIeYt5D5YIUVdmKAgE9Z3grYfPDDo=; fh=RzAsis+XEotthK92ifL9Xn6BaHsFlOg7CixJR+e1g64=; b=zK/BtEPlGGdZYuXHDT6VSWlbNhiJPEJxjsHzlZuD75OTSN1HLxh7xCw4Y+5/V5iegs NE9bdAU5TZKYG8xB5HpPPzoepYtZvoiPDMRSSnVfss67qcKxX8GDo0ldrzebTFX4k9o8 C1Qivg52jPHitSIAOP/vlT++/t4gDOdTleLjY3kac2TpySO5aJp90mvEb6Vz7Pl7uYP+ cr5gm0mZyApbDjKuyucj0lnfWfe5P1Dy/zH6nTjDEXiYzWDSclnlK5X7j7Jy5XZ85RVj KnmsCwj4whBfLaRNVsz06pggCdzPo2hAHXFFYRkuA0Q2RqM65h62UjSUgJXv17AChrbu voqg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kOUi18yF; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-166606-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 j4-20020a62b604000000b006f3ee5042c8si1188412pff.149.2024.05.02.08.10.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 08:10:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-166606-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=@chromium.org header.s=google header.b=kOUi18yF; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-166606-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-166606-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.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 ED1A128C310 for ; Thu, 2 May 2024 14:57:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 36CF6154453; Thu, 2 May 2024 14:57:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="kOUi18yF" Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 353EA15356B for ; Thu, 2 May 2024 14:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714661825; cv=none; b=an3v0n6QZ6YeO35LssqHfz9beJhbOBft86wi3XOtrSX9YQzJ9j10u7hn5NKLiZW8eMKcNNqyCGLiWo//bcZURzUzehc1N3gMwgYvRgU7u7PsQ3ExPEDVdJto5vclOt+gDKnYhPqvfeGCgpJIzQcX0pjx4HfoUrq82GYjyLU7sL4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714661825; c=relaxed/simple; bh=NH4QIZCd1e7ll0ytLJZvsXtnpe6W+YknkMOUe2chw/U=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=k5MrC2oXWwELZ2woIZRMC01IIXRcSK2jPfoA7ZctAA+lWBOUd7U/Tnm5ApS1Q/2bHsLtU4sgSq5cIGRwswkTT15TQJ6y7qJPV6zgACP1lwoX9q8ACtAenTOrHgKMot3MgL/36/Rd2ELQtw07dLfBztf0lVj2tmeBtTgqTws+jnQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=kOUi18yF; arc=none smtp.client-ip=209.85.210.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6edc61d0ff6so7945636b3a.2 for ; Thu, 02 May 2024 07:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1714661823; x=1715266623; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=CQ8b7bzfCx6EpLlIeYt5D5YIUVdmKAgE9Z3grYfPDDo=; b=kOUi18yFJznxD0I7D2bkIZ7g/Dz5s7ufRd99GwsVKDDJ/1k+Iz8WyCULX0lfMSNvoT N/HMqCqJr8xQsdqdS8JzRgFSHfLSqGXlrDFq2HYc1VTvBTvH7JQ2KGDiYJ69ZGa1xpv7 V8Ut/VQq+OdKe0cQfjViVvID918nnmV699qGc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714661823; x=1715266623; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=CQ8b7bzfCx6EpLlIeYt5D5YIUVdmKAgE9Z3grYfPDDo=; b=MN3+inZqGfgIKqhZDMbAVDC6ETJTP16IZNzHRj+js86jZBOvAk2oy/w7XcVSUx8CUw YEpPP6rVSqUVSTjjefVWaSFrlws1v8j61usyCYJPDatJSuGPmrsP6mFem1DHECQGVbm7 sFMHLYqS42j+VziJ1YIEy9lqQ6EW5WnMX9ORLr+oBPjT1l+l1Gwi2S1HgAA4vrXgNb9h i+wx6Maa10oirA6xCshCixtfZ5MAtLgYXjdFFMXoYEYAqaQw/XYLCZkCcDyaeXjE0lHD Ma5IRQnfmrFSTsSnEx6f/fOshTLLKDQdJ7UZoHcd4z4XLG04/gnb5HToQQtS3Sc/Z6Jf 2QNg== X-Forwarded-Encrypted: i=1; AJvYcCVbp1Vo4KUHJLtU/e9FhEYPei1RNqlz5Pa03GVWYube6lmWspUERQ/8uCYPS3KuP3DkDJS2v+X8a+Gq/yRdVdcZuGLjJw7WWQcU1EN2 X-Gm-Message-State: AOJu0YwtZvEa0OI4U4Gf56GUKCWrxCF9Q4vpN2hj2FaNg6gBYJhuQe4n jW1pSSiMvqnUN7l8NIceRmRkfMrrnupMXVTc0wkOcx76BQXRHmhPKrleQa5iCg== X-Received: by 2002:a05:6a20:5b22:b0:1aa:411d:a8e with SMTP id kl34-20020a056a205b2200b001aa411d0a8emr5633798pzb.62.1714661823495; Thu, 02 May 2024 07:57:03 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id cb5-20020a056a02070500b0061236221eeesm1175970pgb.21.2024.05.02.07.57.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 May 2024 07:57:03 -0700 (PDT) Date: Thu, 2 May 2024 07:57:02 -0700 From: Kees Cook To: David Howells Cc: Mark Rutland , Will Deacon , Peter Zijlstra , 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: <202405020755.0101DBCB@keescook> References: <20240424191740.3088894-1-keescook@chromium.org> <20240424191225.work.780-kees@kernel.org> <2100617.1714117250@warthog.procyon.org.uk> 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: <2100617.1714117250@warthog.procyon.org.uk> On Fri, Apr 26, 2024 at 08:40:50AM +0100, David Howells wrote: > Kees Cook wrote: > > > - return i + xadd(&v->counter, i); > > + return wrapping_add(int, i, xadd(&v->counter, i)); > > Ewww. Can't you just mark the variable as wrapping in some way, either by: > > unsigned int __cyclic counter; Yeah, that's the plan now. Justin is currently working on the "wraps" attribute for Clang: https://github.com/llvm/llvm-project/pull/86618 -- Kees Cook