Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2748178pxb; Mon, 31 Jan 2022 03:31:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJyE8anwzes4+GNlx8gmbcicUd6lKnwPMmlaRohGj3bsOynYM+8pf8mi+KdLQK1eZLAUC/zm X-Received: by 2002:a17:902:c40d:: with SMTP id k13mr19910648plk.151.1643628709708; Mon, 31 Jan 2022 03:31:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643628709; cv=none; d=google.com; s=arc-20160816; b=e8tsZ2VzXiumYN8YXZfTHYYBELzG1HBZg3SccruBZ4J7WvkNbo1juDJyM9TthAxmQ9 HGT449JyGbZ+DBJZ0M0tWS/ajs0YysTIXClufxarwRkDhQzZ2a/0IKAz4JI/n0ZzzeD6 kCLfa911m7/9iS56slmHfTvO1Lu/pbzywXlbZIoYj1tWJvoxWHjcG+qtt08mHoSHuSyl j+gJi/SG7W/8vhhYblB2sTOt9m/pIpOodOBxPBpRTVknaBMSFmoGDE011GP35rTkMvVk M5wwzRtJchFe5cdLzxA9BDINhycGNGNNUhU4cKApjvXg7ANrBMaUJRT3KQuiRLzcVWly K1Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FDse3S8N6Ln2TSiDKLNcv7GexIq1BlIyvqHe0Pe3YQg=; b=0OneyaJ18/GZMcFwG4urpRfIJaKdCPb8lPKBHgEDrc5qSNGsinMJjn+DvFFyW10KoS AQRW7qt1Y7IbHCrL6Xo+9SLnSO+fFoQU6dLVceozeNMivwKIF9oMyzlkarUmBfg0pdae ZCNzd1tptwwKvxBpKJfNQTNWpPOE9R4LNkfSuXTCpJhGXC9iwyNM7cg/YUEdOcqlQLaf Uuaw5MKMOsx7yLFtOWmuvNlAMsTTjQV+FN6ImxP2BE+dFyLkzc3Vo1WmlW6penAndeXI KXv3D+FqY81Ev466RgaJmdWoDa+9APOlzu5jIXILeCEBPsj1l3dElhG/eZru6HH1M6Zl A7xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mb2uSSA6; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a38si13862700pfx.138.2022.01.31.03.31.26; Mon, 31 Jan 2022 03:31:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Mb2uSSA6; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350725AbiA1TAS (ORCPT + 99 others); Fri, 28 Jan 2022 14:00:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49656 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350723AbiA1TAR (ORCPT ); Fri, 28 Jan 2022 14:00:17 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C17DEC06173B; Fri, 28 Jan 2022 11:00:16 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 3C681B826E5; Fri, 28 Jan 2022 19:00:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACCA5C340EE; Fri, 28 Jan 2022 19:00:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1643396414; bh=JBkyHUEEIK2NkmwkLCfSdEHCKGjUhXFMjam+YzyL9pU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Mb2uSSA61b3blQ0D+gojuqpuWBPHply69ksvNtu1oNgT9oUSLYjiJwjoLAQYbvXIf 1ccKy4+4GZsgG3dZw1LaHgbV/zm1YrmUgwgqG4YYZlQxNido9645Pdt63B9PQ9DFSt Q74uRvV2/R4jsDxSLyuGTDiijQsX8Mg2Sz7hIhrRnHsiTN5NXmqxJrBG6njxS3Q4X4 vPJmctZGAzzSNXOA/eFqTZ4zjuMFNIl4gCLs3ASdctV6PYKst9Wknj3lMNoEV5ngae waKv3xMoNUVD6HxtYwE0lxTFkMfcNYIdRcqpYzrQ84k/9nCqVUU/1EIkzSuVlJ7JS+ NwoJHq/GagnxA== Date: Fri, 28 Jan 2022 11:00:12 -0800 From: Eric Biggers To: Jarkko Sakkinen Cc: keyrings@vger.kernel.org, Denis Kenzior , David Howells , Marcel Holtmann , James Morris , linux-crypto@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH 1/3] KEYS: asym_tpm: fix buffer overreads in extract_key_parameters() Message-ID: References: <20220113235440.90439-1-ebiggers@kernel.org> <20220113235440.90439-2-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Jan 26, 2022 at 04:22:53PM +0200, Jarkko Sakkinen wrote: > On Wed, Jan 26, 2022 at 04:21:53PM +0200, Jarkko Sakkinen wrote: > > On Tue, Jan 18, 2022 at 04:59:47PM -0800, Eric Biggers wrote: > > > On Sat, Jan 15, 2022 at 11:40:48PM +0200, Jarkko Sakkinen wrote: > > > > > > > > > > - Avoid integer overflows when validating size fields; 'sz + 12' and > > > > > '4 + sz' overflowed if 'sz' is near U32_MAX. > > > > > > > > So we have a struct tpm_header in include/linux/tpm.h. It would be way > > > > more informative to use sizeof(struct tpm_header) than number 12, even > > > > if the patch does not otherwise use the struct. It tells what it is, 12 > > > > does not. > > > > > > I don't think that would be an improvement, given that the code is using > > > hard-coded offsets. If it's reading 4 bytes from cur + 8, it's much easier to > > > understand that it needs 12 bytes than 'sizeof(struct tpm_header)' bytes. > > > > > > I'd certainly encourage whoever is maintaining this code to change it to use > > > structs instead, but that's not what this patch is meant to do. > > > > I would consider dropping asym_tpm as it has no practical use cases > > existing. > > At least I have zero motivation to maintain it as it does not meet > any quality standards and is based on insecure crypto algorithms. > I neither have participated to its review process. Fair enough, I'll send a patch to remove it then. - Eric