From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AE8CBC4167B for ; Mon, 12 Dec 2022 09:16:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231842AbiLLJQa (ORCPT ); Mon, 12 Dec 2022 04:16:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231858AbiLLJQC (ORCPT ); Mon, 12 Dec 2022 04:16:02 -0500 Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 584C2E0D1; Mon, 12 Dec 2022 01:15:55 -0800 (PST) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1p4eu7-006PYn-Dc; Mon, 12 Dec 2022 17:15:20 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Mon, 12 Dec 2022 17:15:19 +0800 Date: Mon, 12 Dec 2022 17:15:19 +0800 From: Herbert Xu To: Roberto Sassu Cc: Eric Biggers , dhowells@redhat.com, davem@davemloft.net, zohar@linux.ibm.com, dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, keyrings@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Roberto Sassu , stable@vger.kernel.org Subject: Re: [PATCH v2] KEYS: asymmetric: Copy sig and digest in public_key_verify_signature() Message-ID: References: <20221209150633.1033556-1-roberto.sassu@huaweicloud.com> 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-integrity@vger.kernel.org On Mon, Dec 12, 2022 at 10:07:38AM +0100, Roberto Sassu wrote: > > The problem is a misalignment between req->src_len (set to sig->s_size > by akcipher_request_set_crypt()) and the length of the scatterlist (if > we set the latter to sig->s_size + sig->digest_size). > > When rsa_enc() calls mpi_read_raw_from_sgl(), it passes req->src_len as > argument, and the latter allocates the MPI according to that. However, > it does parsing depending on the length of the scatterlist. > > If there are two scatterlists, it is not a problem, there is no > misalignment. mpi_read_raw_from_sgl() picks the first. If there is just > one, mpi_read_raw_from_sgl() parses all data there. Thanks for the explanation. That's definitely a bug which should be fixed either in the RSA code or in MPI. I'll look into it. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt