From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f71.google.com (mail-oo1-f71.google.com [209.85.161.71]) (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 BCBCC4B4873 for ; Tue, 8 Sep 2026 22:34:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788906880; cv=none; b=W2PK5RuXWFUmG5RHClxzl7vn9aes6yFE2yaZMkwfTf0pJ8cHyk1ulY8Qo2zTZ9j7YLPkuaZBVq3tkK9T/DvlDz9VYIGyynVkiEsezFq6yYAU+3i2yjS6+ZL2vQNuoaa8lCpSoar3tRzW0298TXGxX01rrCWN3gxY3rfYwe304EA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788906880; c=relaxed/simple; bh=htNILk9Kpq12336HFpWbDN67/SR46TQMYtfCjV9wRxY=; h=Date:In-Reply-To:Mime-Version:Message-ID:Subject:From:To:Cc: Content-Type; b=oXx2aCQFFOhXSfsq677i6QoMXUREWosg8k1aMsE22RAXFHgcrZ0eXo1uTCDnR2PBwUP/Aw1Has2cec3q5I8ECUmwpvIm96q/T5TI7f3a5egbR1nUXUhiCpJjKpKbK/ZobhJvVHqdCfjHJqkFY8daG+5zcqs26JSpqWq6tar1lQk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=uaYTHfPu; arc=none smtp.client-ip=209.85.161.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="uaYTHfPu" Received: by mail-oo1-f71.google.com with SMTP id 006d021491bc7-6b1a3f01d2aso6697160eaf.1 for ; Tue, 08 Sep 2026 15:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1788906878; x=1789511678; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=Y6DHdss8MRJ7r65GA41ught1FKJ932kAtSg2l2oUqQc=; b=uaYTHfPueU0TDrIv7KfTmvg3C6htsYvnOGJ3Qni25YFImkYLkV92Wh/3Nz4Oq2/CKl RPPNGU417AnV7rHYhfb6+9CGAUxH3qKjPJ/zZt7Imwkr6AJwZ94eOudhGpHCCDrBR+A4 cstus1mk+P7bbepGyatAXAOmVVFrPFNGOx7ZbhCVXZBpEpoygqjRHqAe1ssYn/72ItzA u5GLCMjx7HcsmJamW6aKZkPpk5ZIwfFyfVC/0A03jh+RLXmbRDiUC/l7kFc0sYvgQ4mZ HQETneyJDLiJCe+L1xN6IIxELlBKPd325sE8ZsVwKKzWTGUun6yJv87MUQBZNkUy/pVJ oN+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788906878; x=1789511678; h=content-type:cc:to:from:subject:message-id:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=Y6DHdss8MRJ7r65GA41ught1FKJ932kAtSg2l2oUqQc=; b=R9VqnbvCfLVTDM+ar4M5QsTa2+Mse4Xce+ndYq1WKID1wUbP4TFR3KzOTCjzy7dAqd BjUZCEU2wGFJ2Sn5JtuGqU+cxz7NkhEkkwup9/FwxIV4IWnMAqhrBdTPqouCivzHCmrr qRnNZXQzolbCxX8TIGohr0a9TfRLdr0FLt9BDzIPDmWel4vvspr3g7ggNlaNH/XbiIt9 l8opPOxWgHc8qcF2i74VE/18S+EOZFpaAp/M9JV+ULwesYP2xwZq7xOYgvolHD8qt1pg nv++ctnikRcoUo4BWZcKUOcaW+yigFxYIvn/5FB09041uNmwF/C9SawFn8Y6+MdphoZZ g30g== X-Forwarded-Encrypted: i=1; AKwUvBzag41Q9HXYu+sdx28EtRQiqTz7kNBZCDAxhq2oFHeX4iBmmfWWuJo/irIDlnPBjN5qW0oxuIOvJUE=@vger.kernel.org X-Gm-Message-State: AFuF++m0A5l8Qk3FLKtSQfw2CkyGj9Zzj3qcsddE+ybclxQgk8LrW1dU R1pSR1Zq9UPYE7FXrzo851XkyUpx/QrXYMeC8Amuu2VOxPVoJFYrZfEHvjkAlsyYD1yBgYVTwWf 6quGHaWmEYQouv9nDdQVVHk6XEA== X-Received: from japm26.prod.google.com ([2002:a02:cdda:0:b0:5f1:325b:8e4c]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:179b:b0:6b6:c0bc:365c with SMTP id 006d021491bc7-6b6fcbdc9dfmr18638803eaf.22.1788906877369; Tue, 08 Sep 2026 15:34:37 -0700 (PDT) Date: Tue, 8 Sep 2026 15:34:35 -0700 In-Reply-To: <20260401092027.GW3738786@noisy.programming.kicks-ass.net> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Message-ID: Subject: Re: [PATCH 3/5] compiler_attributes: Add overflow_behavior macros __ob_trap and __ob_wrap From: Justin Stitt To: Peter Zijlstra Cc: Vincent Mailhol , Kees Cook , Marco Elver , Andrey Konovalov , Andrey Ryabinin , Jonathan Corbet , Shuah Khan , Miguel Ojeda , Nathan Chancellor , kasan-dev@googlegroups.com, linux-doc@vger.kernel.org, llvm@lists.linux.dev, Linus Torvalds , Nicolas Schier , Arnd Bergmann , Greg Kroah-Hartman , Andrew Morton , linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, linux-kbuild@vger.kernel.org Content-Type: text/plain; charset="us-ascii" Hi, On Wed, Apr 01, 2026 at 11:20:27AM +0200, Peter Zijlstra wrote: ... > > So I would like to second this option as being interesting. > > But while pondering it, I did want to note that all of the options, with > the exception of __ob_wrap (which is effectively what we have today for > *everything*), will be 'interesting' to compose with _Atomic, another > one of these qualifiers. > > Now, in the kernel we don't use _Atomic, so strictly speaking I don't > care ;-) But here goes... > > Something like _Atomic int __ob_wrap, is trivial and good. > > _Atomic int __ob_trap is either doable or impossible depending on how > you define the result to be on 'trap'. Specifically, the semantics > proposed where it keeps the old value makes it impossible. > > And _Atomic int __ob_saturate is equally 'challenging', since the > fundamental thing of 'reset to min/max on under/over-flow' is rather > a non-atomic kind of thing. Look at the trouble we went through with > refcount_t to sort of make this work. > FWIW, I've moved to simply disallow OBT+Atomic. We've got this under -fexperimental so I'm well within my right :). The idea being: __ob_trap isn't workable with Atomic (depending on storage semantics) and __ob_wrap isn't very useful there either, plus I had some parsing bugs where specific ordering of things could result in OBT being silently dropped with _Atomic and those magically go away by disallowing this pairing all together. I just opened the PR over at [1] and it is still pending but this is probably where I'll go with _Atomic and OBT :) Link: https://github.com/llvm/llvm-project/pull/222179 Thanks Justin