Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp2053326pxb; Sun, 16 Jan 2022 08:23:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFsElX3nPnaZSW7YDFa8sUMH48baOBXBBc5euR2GWE/B1Nc6lg09Rh30tsPH1eK2nE25oi X-Received: by 2002:aa7:8394:0:b0:4be:ab79:fcfa with SMTP id u20-20020aa78394000000b004beab79fcfamr17532370pfm.3.1642350195749; Sun, 16 Jan 2022 08:23:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642350195; cv=none; d=google.com; s=arc-20160816; b=YydV5jBQcqm5vgGCln/a+5eHvaCopg52yNMdINlS12uV/r6ZPUJqvHSir8B3NQJAUs FQWGyPzxOzTXl5hGJAR39nzq7fEM7YxyUx1Bm6WYPgGCnu+HejlAUax2PWkAHi6kaLHU UeFwvc1X3h87yVcpKOZGWMFyxBPT+CqzyrMFOwcUZPJUvoWERoVwZGNB0iKI3XXqccit +zVMcWY9pzwLzUn/EZXqKRBK+ZuN/Dkxq113YvCI1xpELQBU/z1KlGWMBRzih7eb0uYE dyF6OH1w264gmFynEvwUlYL2JZh3iG01bieUNzQ3aS1+lICduBcZ0Ar+Z5vucL7cYb4L aLOA== 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=W+ZXUNavQErQqDyEVz7jNKZqKMVBbwBOSWmvx4Wf5gY=; b=Gx58ee50gCx44Xsv4o/eSFTWWEvuPvtNUiC9ppauDnZbWUbL7pLeiymM8MAbb8l4tE TMwwHjTUMDnVL+5xU5lfEBZw9ZPb3clGsxYU7gVcaIZeYYx+xRrIjBarva0oPg4fGrhT 5axZbLzB6Bc1QTYsskFP7E5wWemPvGkYX4P5drin9nBU1ZPIfV8OLQrknj6HXdsiunO3 hltpeLkH9a8gz3lSf/DcNeRLxz740KemFOCqsCI/tJnqTRRF+1QLO92/xXmTIYuhfdkU cvmpmoSOLNRuCJDWK8TOEzfOn/9JuZBUIDyGzCnAJvoTh/jo/yK69yQBKupgvbIF9msw 5vGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="s2vLCv/n"; 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 r12si12118095pgv.297.2022.01.16.08.23.04; Sun, 16 Jan 2022 08:23:15 -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="s2vLCv/n"; 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 S233763AbiAOV0d (ORCPT + 99 others); Sat, 15 Jan 2022 16:26:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233761AbiAOV0d (ORCPT ); Sat, 15 Jan 2022 16:26:33 -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 B77FAC061574; Sat, 15 Jan 2022 13:26:32 -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 59EA8B80B64; Sat, 15 Jan 2022 21:26:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63938C36AE5; Sat, 15 Jan 2022 21:26:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642281989; bh=YBvlnsBnrtDKytZx6mouCpEaP7blm+tVQ1xjpk4JmxM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=s2vLCv/nTsNhylO8M063FT+vlJLL/YxGhfWcFte1emypc/2qkEsnKBiXuzWXAczjE hMJXn4ybLtEu0/wZA9uDlU7I0LEYOK6El9ac6fuDZbsdQ/3ZyblJGEQ9PPiHlpY3Q7 26iXjjZv5cNBUmUwB18ixD3hL5NmVrNqeW+EOHIk2t8hkT05oJonhdXwfPWLQakoio Ra1zNkug8EmXn5I9b1kSjE7SsPYGdQiPuQ74H/fd9YfVw8bV6qsedBPtvFPIowcCAk +0QVB9Jixng9P+RCeNqwqKXzclCHvhbASO4Z9w4knsAtvuVs6vTNdRtQtThvvIUiwL lhNVuArQJzhWQ== Date: Sat, 15 Jan 2022 23:26:16 +0200 From: Jarkko Sakkinen To: Eric Biggers Cc: keyrings@vger.kernel.org, David Howells , linux-crypto@vger.kernel.org, Marcel Holtmann , Denis Kenzior , stable@vger.kernel.org Subject: Re: [PATCH] KEYS: fix length validation in keyctl_pkey_params_get_2() Message-ID: References: <20220113200454.72609-1-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 Sat, Jan 15, 2022 at 11:53:34AM -0800, Eric Biggers wrote: > On Sat, Jan 15, 2022 at 08:45:03PM +0200, Jarkko Sakkinen wrote: > > On Thu, Jan 13, 2022 at 12:04:54PM -0800, Eric Biggers wrote: > > > From: Eric Biggers > > > > > > In many cases, keyctl_pkey_params_get_2() is validating the user buffer > > > lengths against the wrong algorithm properties. Fix it to check against > > > the correct properties. > > > > > > Probably this wasn't noticed before because for all asymmetric keys of > > > the "public_key" subtype, max_data_size == max_sig_size == max_enc_size > > > == max_dec_size. However, this isn't necessarily true for the > > > "asym_tpm" subtype (it should be, but it's not strictly validated). Of > > > course, future key types could have different values as well. > > > > With a quick look, asym_tpm is TPM 1.x only, which only has 2048-bit RSA > > keys. > > The code allows other lengths, as well as the case where the "RSA key size" > doesn't match the "public key size". Probably both are bugs and they should > both be 256 bytes (2048 bits) only. Anyway, that would be a separate fix. > > - Eric I'm fine with the current commit message. E.g. I have no idea at this point whether there should be in future separate asym_tpm2 or all bundled to asym_tpm. Acked-by: Jarkko Sakkinen BR, Jarkko