Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp557718rdb; Tue, 23 Jan 2024 07:45:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IFuq4Ygn5Db4Arb39tBQ/6AjRfW5RV1qXdikzfB24t2IWM9Zl9QIquZcIrBEJ5byRGotcy0 X-Received: by 2002:a17:902:eb4c:b0:1d3:eca1:91b8 with SMTP id i12-20020a170902eb4c00b001d3eca191b8mr5884550pli.46.1706024741877; Tue, 23 Jan 2024 07:45:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706024741; cv=pass; d=google.com; s=arc-20160816; b=S4u8GqyZCwOnnm4BzJO8b/cHjn+7yo3+Xs9Ki2Jvg/KpJZD7TbmGpiDxzDHX8Rs82H Cok9yzhe8GU4SeHS2GT4Rymf2NasgRAXOIre4uo5DmB1nx91h2a+EtUWOeENjClxZilS +kJNuDEbvjwU21NMRbSjZ6OZcfZ7JD8R2yMyvXvENEXvFXq5OMh/g/xD4r+tYNlkwlfn olB3/PPTsRjOoDFpnMMtflQ+ItdV+GSmBSlD3tzN8SFQ8m5Plp1O1b+1S82afdc6l6cu /zoUXaowYdppQQPtmiFV+6UpuWmmby+gG4ZOAdNeoxCBgcOTg9Lqnv9BiXGcfQEAR+Jb d6eA== 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=EMJEvJ0btcMe/8Olg7ds9l8yKXaa2jUGkjlLRmoI+bQ=; fh=nvmwD5v2joFPLxgL+D323QyJJYWyXiDFKv0V0aqm2WA=; b=z4IDhQJCJjCpIiAJIWgYlLepirsEVzk2r/FV1Nn8/SoWCUfw5XKK8p1eqSO+CuhkSr hBRyhVEspI522ZPnGMeL9tMMarkGIGkzxjMrNZyRRUiFTw7S15kG438HnyMUB6GSPi/g KEEi+9U8NcAXfYkiinANlBl1nQtUHezMGUX5sgvC+hxoOyasWIvBLIgLmvdGYaLfg60F Ne2SzYkHEYoN0eQ/4y2yfdmMXomrH3E14fC2kVRQVx3U2u9nny/li6CkAcrQeKHaFDQG n4igMWJdsfAez4DWz96K3L+EW4WPf0d6g/nU+iWYBPU19R2OO5EG0ymXuLfgua+uaHY2 JxtA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lK89aVGl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-35533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35533-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id w12-20020a170902e88c00b001d74ea0944asi963834plg.50.2024.01.23.07.45.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 07:45:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=lK89aVGl; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-35533-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35533-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id C50DAB2300B for ; Tue, 23 Jan 2024 15:30:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D7905FEEB; Tue, 23 Jan 2024 15:30:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lK89aVGl" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 7DEB851C3A; Tue, 23 Jan 2024 15:30:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706023812; cv=none; b=aJA1BVSztyWggxjVBOcJUmKnLRn7o+hk8WaRwJtJTMEoOMPOQruO44v7ra6IIn0ri8we5Z2A5JYgPqYR1/s4BsnI27i2h9hXPm38Dh++E6i9hb0dYSh13hQkrBzQgeMvR75cMhwa/KhLcRmPdsolb+nH2kz7lDXDhQAUIbzo8lc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706023812; c=relaxed/simple; bh=ni+H++b32vfegPdtL8QkxuZ4iXmva5ufBJv+Q+YyV24=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=K1HA7Rh5dY6joIgiBD6roLBAJy+Z7gRjC3vTpEEPhWH1sM0ITxITHfO3/X26iRY+yQcXOKGPtCccPqW/fPotTq1UXXkKSTi5k/Ajr8jdsrrMZqSvVpftDtxL/VAmuY/CpPoxfro/XTmvhgIvUHnCCPKZ2yAXBNoAuRF2rQiVpt0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lK89aVGl; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBFB6C433C7; Tue, 23 Jan 2024 15:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706023812; bh=ni+H++b32vfegPdtL8QkxuZ4iXmva5ufBJv+Q+YyV24=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lK89aVGlV14uKQ29sz2ltqCKK/zNAno9Ye/bSUoE0ObllarRTyht7KbOMqgagehTB zU1/64YE1WgBaELl34GcYUEn6qatSgBLrheN9XS6L4PJJvfPxx6CUfUgbR7aG2EgvH /SHl6G6lNSYWWxdpy7xPmWb2pAvRvCEWyDhm6B1Yr9QLDR+JFFyjmDu5XRfR9HX/4N uWKW/XewgamAXkzzYPApSKaKK/OkZnwNQEnAKTksPLk3ou+yPpIVTrfc0LUDfXODd4 pyXumwRwmYxyCWMOw/NWtd0wK6rNRGpviMGNg4ytzE4PPzkel+Ty7iD5gYsPXDhpqC Z1soaoxkZgtUQ== Date: Tue, 23 Jan 2024 16:30:05 +0100 From: Christian Brauner To: Kees Cook Cc: linux-hardening@vger.kernel.org, Benjamin LaHaise , Alexander Viro , Jan Kara , linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, "Gustavo A. R. Silva" , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org Subject: Re: [PATCH 37/82] aio: Refactor intentional wrap-around test Message-ID: <20240123-zerzausen-ahnen-02455c8a91bc@brauner> References: <20240122235208.work.748-kees@kernel.org> <20240123002814.1396804-37-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=utf-8 Content-Disposition: inline In-Reply-To: <20240123002814.1396804-37-keescook@chromium.org> On Mon, Jan 22, 2024 at 04:27:12PM -0800, Kees Cook wrote: > In an effort to separate intentional arithmetic wrap-around from > unexpected wrap-around, we need to refactor places that depend on this > kind of math. One of the most common code patterns of this is: > > VAR + value < VAR > > Notably, this is considered "undefined behavior" for signed and pointer > types, which the kernel works around by using the -fno-strict-overflow > option in the build[1] (which used to just be -fwrapv). Regardless, we > want to get the kernel source to the position where we can meaningfully > instrument arithmetic wrap-around conditions and catch them when they > are unexpected, regardless of whether they are signed[2], unsigned[3], > or pointer[4] types. > > Refactor open-coded wrap-around addition test to use add_would_overflow(). > This paves the way to enabling the wrap-around sanitizers in the future. > > Link: https://git.kernel.org/linus/68df3755e383e6fecf2354a67b08f92f18536594 [1] > Link: https://github.com/KSPP/linux/issues/26 [2] > Link: https://github.com/KSPP/linux/issues/27 [3] > Link: https://github.com/KSPP/linux/issues/344 [4] > Cc: Benjamin LaHaise > Cc: Alexander Viro > Cc: Christian Brauner > Cc: Jan Kara > Cc: linux-aio@kvack.org > Cc: linux-fsdevel@vger.kernel.org > Signed-off-by: Kees Cook > --- What's the plan? Merge the generic infrastructure and we can pick the individual patches?