From mboxrd@z Thu Jan 1 00:00:00 1970 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 E2B7A10F1; Tue, 23 Jan 2024 03:29:43 +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=1705980584; cv=none; b=KD7Fnge+T9POJvAV8qAKe6sx92HBtT8JmbeIorRg4KP7mBmGdiTT+JCIrJqT4MRxC2GiGlCqCW1H3DBGErzk2orKr3LaLYGalpQk+kJPDFgMT3nwDOd/CwbU96FlZoFLNXs6I2urnXRju2kOHr2SLaov3F9i/MeN71pfR+2WhL0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705980584; c=relaxed/simple; bh=U1v5qrYKbV+f+R8OtytsdZNiZAtmV31IrDUJJyID3bk=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=Q0YmV5gDg3VwcxQlxqdemhPnPEavoW7fR8gLM5xm078rlHPS7xP/tmnOZocVehg/pCwyaxkUZrpZEsLhM65GL54MzofCKmiwjqND1gVjiXb+0xdY2pL+vuEDBDSTEJFvGwDty4Jq17wiysMICq8W5OQ5Bw/45aDnVB/Ik/pHEGQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Wng2Ly9p; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Wng2Ly9p" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A2CEC433C7; Tue, 23 Jan 2024 03:29:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705980583; bh=U1v5qrYKbV+f+R8OtytsdZNiZAtmV31IrDUJJyID3bk=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=Wng2Ly9p0gJUrUy0fOD4sFGGZ3A/c+t4sAUY6sRcNyedhhhAQEuGsBs991gjlQhWi L9W34O7F9D6wLVxhLculzkedvobKw3ENzJv1JQTt2VBpihomaaGQWcWBbsYybwdIJF ig5KyQrCJqCLjUKrpQep0GrdUC5rmFXzYY056mFzRum+NFP1zAAHW6lCBRRBozSmzS IKrxbZ/KFH/jeSI4AjmRfZwnEkxStHujgD3WpURC8HreGp2IRC4gaNEfbGxo/7AosX j93RdCdt5BGaL7DtelBesGtRUoWStsloAYet8odRBsaEEjZhqLKLRgsDIy8/b6GhYk f7F7CMQMRIVtw== Date: Mon, 22 Jan 2024 19:29:42 -0800 From: Kees Cook To: Eric Biggers , Kees Cook CC: linux-hardening@vger.kernel.org, Herbert Xu , "David S. Miller" , Aditya Srivastava , Randy Dunlap , linux-crypto@vger.kernel.org, "Gustavo A. R. Silva" , Bill Wendling , Justin Stitt , linux-kernel@vger.kernel.org Subject: Re: [PATCH 46/82] crypto: Refactor intentional wrap-around test User-Agent: K-9 Mail for Android In-Reply-To: <20240123030745.GA1097@sol.localdomain> References: <20240122235208.work.748-kees@kernel.org> <20240123002814.1396804-46-keescook@chromium.org> <20240123030745.GA1097@sol.localdomain> Message-ID: 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-Transfer-Encoding: quoted-printable On January 22, 2024 7:07:45 PM PST, Eric Biggers w= rote: >Just to double check, you really intend to forbid *unsigned* integer wrap= around? >This patch's commit message focuses on signed, and barely mentions unsign= ed=2E >The actual code changes in this patch only deals with unsigned=2E I don't mean to forbid wrap-around; we just need to annotate it=2E I can s= ee how this commit log didn't do a great job explaining this=2E I hope the = cover letter is more sensible: https://lore=2Ekernel=2Eorg/linux-hardening/20240122235208=2Ework=2E748-ke= es@kernel=2Eorg/ >Also, what's the motivation for addressing the 'x + y < x' case but not o= ther >cases in the same file? It's a code pattern we could find easily=2E It's working from the instance= s found via Coccinelle earlier in the series: https://lore=2Ekernel=2Eorg/linux-hardening/20240123002814=2E1396804-5-kee= scook@chromium=2Eorg/ > For example, the le128_add() function which this patch >modifies has two other intentional wraparounds, which this patch doesn't = touch=2E For dedicated wrapping functions we can mark them with __unsigned_wrap: https://lore=2Ekernel=2Eorg/linux-hardening/20240123002814=2E1396804-6-kee= scook@chromium=2Eorg/ >Also, the le128_sub() function just below le128_add() is very similar but= does >wraparound in the other direction=2E That's 6 cases in 20 lines of code,= but this >patch only addresses 1=2E And of course, lots of other crypto code relie= s on >unsigned wraparounds too, which this patch overlooks=2E =20 Right -- finding these kinds of things is where a lot of time will be spen= t in the future, I suspect=2E :) > So I'm a bit confused >about the point of this patch=2E If we really wanted to explicitly annot= ate all >the intentional wraparounds in a particular piece of code, so that the co= de can >be run with the corresponding sanitizer enabled, wouldn't it be necessary= to >actually test the code with that sanitizer enabled to find all the cases? Yes, but there's a lot of code to test -- I'm trying to get the first step= s done=2E And then once the sanitizers are in good shape, the fuzzers can g= rind=2E (I'm trying to add some parallelism to this project; this code patt= ern was known so I figured we could address it now=2E) -Kees --=20 Kees Cook