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 905BBC4345F for ; Wed, 24 Apr 2024 22:45:21 +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=LNa3r6Tpi6GEyj87iebmZJHll6GNya4IdJryx+6ejCg=; b=r4+TSCEdhkBbcN 85fNX0MzfGxgCTMirUTMadLYAlu2qfqoXycJ3xesGE1A5Iu9qktMPhxjhCbP6u9z6MPYRQnWOvaFx +owI2rm4tzlUatX9Wp69BPjosqwTsJo+QD5YsUDtQlbiecdni6/8Yg4XolWf993IFlUwu9CaqTcx/ UYnHwNlkvLrco9lyLXBzvBtMZuHCwPn8Nxc+BRea2FYLBcDcx/8beWoxtHJUycYewQXr2i5gKXxzE xlw7UnRWSqFRMVs0rKyu7LbMD+Siy4dESnst5fpkaxmjpDfuFXTqIvuoFmyyAIzHjnyQ1Hu6sQKCP iHgbnwgcayRpqFO97btQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzlMX-00000006GLI-0sjx; Wed, 24 Apr 2024 22:45:13 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rzlMU-00000006GKG-0uI4 for linux-arm-kernel@lists.infradead.org; Wed, 24 Apr 2024 22:45:11 +0000 Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6f30f69a958so373167b3a.1 for ; Wed, 24 Apr 2024 15:45:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1713998709; x=1714603509; darn=lists.infradead.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=bQ7aAoW8uYuZUJ8c+fQ05Y2fxYHEV3uQB6MRkhy36Ug=; b=Z0iQFABsYYL7aLOI6qr5pzLmVLq/sBo49KOekhi6I1aeEkMWMowe/q52NufG35kxIf wHN73WaOx+mtqWMaVjTAGbhyJBbFsY+pAumkozLU2EXR9soJ+LkPHAsF++aN0jX6hiKl dSBWVO/+u7HnOLSDOgmh9be2VjDQYvmpRbqbQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713998709; x=1714603509; 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=bQ7aAoW8uYuZUJ8c+fQ05Y2fxYHEV3uQB6MRkhy36Ug=; b=mLliXF5cXVoeohh4WFH0yqZbCV6/Mwmfz5nsb/0E1yE92atHWLdFcdX9TiP2KgTFcH dZfDN/xxSELo29QHLRNk6/VW8xVT3gBDZpmR++DyIo8xw8fplmn1TsBaIwy9jQvfqIfX UviTy9vcfsBffC0l6HRxoV4K1BRIz+XBsS+48W9bBdUzJMafwAgkIesCvTayAy4DvZEG x5WaItqsfHD2h+R3Y7B0+eLyylM2rSql8BxpxgQD3Dx81upjSG5cVqC3p0Jn2//yG0iN ejvGHKprjsj8j71zsR9J5dtCmMnKX3PtE6fi0izTYALptFnxE07fucIsXcm3mw5fK0HJ dJaA== X-Forwarded-Encrypted: i=1; AJvYcCVmuRrCDhcFjpa+vGrWxiGhmriH7nJjhf4OUOpFiXMIPeDA2G30VuG63ZpMlF29RRwBY2NtAg9WizlHBtrUyM6t7yvmzCljPpZg3gKSM/SV0imGNYo= X-Gm-Message-State: AOJu0YwFDFVTH9AW8YVCWB3KsgkwplPqiRLLRpGMsQNbf84ymf7efR3s +yLBj7PCEam7WO8/clUNKRC3Gzdd8XUL0WWU/DlxNZC9x+GYphz/nJAF1hmnYw== X-Google-Smtp-Source: AGHT+IEAjXKcOqWbmJBmZ5dMg2rtYhG1LF2zwzQbtnGchw8LS/JZuvVMQDMhTtYVw79O2YlLzJPAxg== X-Received: by 2002:a05:6a00:4fcb:b0:6eb:2b:43b4 with SMTP id le11-20020a056a004fcb00b006eb002b43b4mr5470380pfb.27.1713998708861; Wed, 24 Apr 2024 15:45:08 -0700 (PDT) Received: from www.outflux.net ([198.0.35.241]) by smtp.gmail.com with ESMTPSA id ln2-20020a056a003cc200b006eff6f669a1sm11902767pfb.30.2024.04.24.15.45.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 15:45:08 -0700 (PDT) Date: Wed, 24 Apr 2024 15:45:07 -0700 From: Kees Cook To: Peter Zijlstra 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: <202404241542.6AFC3042C1@keescook> References: <20240424191225.work.780-kees@kernel.org> <20240424191740.3088894-1-keescook@chromium.org> <20240424224141.GX40213@noisy.programming.kicks-ass.net> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240424224141.GX40213@noisy.programming.kicks-ass.net> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240424_154510_281248_39A76FE7 X-CRM114-Status: GOOD ( 17.23 ) 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 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 -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel