From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 AEC243624C4; Wed, 1 Apr 2026 08:57:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=90.155.92.199 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775033848; cv=none; b=JDbaUta/iSL890gPIVRwQif1edyxj80d7A0DuIJ4XuEiBJRODcVOtBomdGgrEWPKFqv9xnVGEhfCd5SWgi1VTW6iEXGBqMArcDEKSzwP0f7J+MRIReAgjfEfqrjop7vPK3IKqlyNbPYDZ9tNC/eWmxCcAOkEPlHuVNWLhDLyp8M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775033848; c=relaxed/simple; bh=MO5Dtje2grOtBQTnEYTUa7IHkS/+xLx5hH8FxLfUSqA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fSHUtbd5xpPKucok68b7XMj0Kg0Kgt6MlDI98SdUBhVOHA0B2Ia/YWIdvoE0qoxQIJs9Daywb2seYLsoletvzhBm/esQqV1B4V2P95rVlPIfaE+v2b25s6b1Ma1b6sz34VeYDC85twTTkzPJzL6iYVl/ZOkfngPHI3Y0Ys95cuM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (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=SJrQ47v0; arc=none smtp.client-ip=90.155.92.199 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=infradead.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="SJrQ47v0" 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=BSOlLzvS3EKkRVsstBVsGVbDsJymklK0utfYJvW9Xso=; b=SJrQ47v0lAhZLjMS3HczkFUno3 p6Y1cPKEa+2xK1mwcNjWTk7wLq2Rv4fTksCldcsfd8US8aWsQ5nLPoMxu83WeLwUAej4Bge+1hcXB PwrPy2YmFv4wne0pSxhr2HeQGNN3KgOi/49+CrP6HffS6f5Ml8SyVNlhH+QsIlvdnj5PEXlNuHeA9 mg4UvawYnldkdZcdrUK2sYOPJaJEJM37YK/PuSkuv4OkThj/1WDVy1Z0oYW9Upmd8f85gAI/9Ln0E TqcUOedfHbcW6IZwjTqjTM8hiQ2lx5cJ1S6ItOftfpxaJ/CRbEppJ7mM06xuzrpIV/JpTdC9ZgTxi nOPVjzug==; Received: from 77-249-17-252.cable.dynamic.v4.ziggo.nl ([77.249.17.252] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.98.2 #2 (Red Hat Linux)) id 1w7rNz-0000000HU5p-0eCn; Wed, 01 Apr 2026 08:57:15 +0000 Received: by noisy.programming.kicks-ass.net (Postfix, from userid 1000) id 326F23032D1; Wed, 01 Apr 2026 10:57:06 +0200 (CEST) Date: Wed, 1 Apr 2026 10:57:06 +0200 From: Peter Zijlstra To: Kees Cook Cc: Linus Torvalds , Justin Stitt , Miguel Ojeda , Nathan Chancellor , Andrew Morton , Andy Shevchenko , Arnd Bergmann , Mark Rutland , "Matthew Wilcox (Oracle)" , Suren Baghdasaryan , Thomas Gleixner , Finn Thain , Geert Uytterhoeven , Thomas =?iso-8859-1?Q?Wei=DFschuh?= , llvm@lists.linux.dev, Marco Elver , Jonathan Corbet , Nicolas Schier , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kasan-dev@googlegroups.com, linux-hardening@vger.kernel.org, linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: Re: [PATCH 5/5] types: Add standard __ob_trap and __ob_wrap scalar types Message-ID: <20260401085706.GU3738786@noisy.programming.kicks-ass.net> References: <20260331163716.work.696-kees@kernel.org> <20260331163725.2765789-5-kees@kernel.org> <202603311253.95C54588E@keescook> <202603311321.4EE9FEA@keescook> Precedence: bulk X-Mailing-List: linux-doc@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: <202603311321.4EE9FEA@keescook> On Tue, Mar 31, 2026 at 01:31:16PM -0700, Kees Cook wrote: > int func() > { > ... > u8 __ob_trap product = 5; > ... > product = a * b; // if store is truncated, goto __overflow > ... > return product; > > __overflow: > pr_info("%u\n", product); // shows "5" I'm confused by this 'product is still 5' thing. It seems to me that making this happen will, in general, require more instructions/registers than allowing the old value to be clobbered and have product be the truncated result of whatever overflow. Specifically, what is the value of preserving the old value? > return -1; > }