Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp36001314rwd; Mon, 10 Jul 2023 16:22:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGWAc9nsqbl/ZhIyHhMgvzOU8iZUftWCvSwIJH9vl/feQ76HRLYMumFHR3GsE+qb0AZk+HC X-Received: by 2002:a17:902:728a:b0:1b8:6850:c3c4 with SMTP id d10-20020a170902728a00b001b86850c3c4mr11069446pll.22.1689031329033; Mon, 10 Jul 2023 16:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689031329; cv=none; d=google.com; s=arc-20160816; b=F7EZMqryUvDMEAZO7/GsTRJopo+BooY3qqbrWvpK8KWHDj9u/3HyhthHG+kwmQBZh9 fTF/hdpv3DCTfRuFVHDrmuCgESDaPK6bt1wyo2qI7pYndcO1aYY+fGU8N+gGhk4K36Y3 utPi5XDOFMHLXqlELj3NC5EFIb9xPKGXhq62m3XRdRJfsRjGHkjNK4SiUz7jyArOSRQp ING0RiveN17g7GtaVOEIn1KvHv7nwVVIzJ8VrBE3MNlu2VJCkvbGjzBS+dqWdmxnoDef jW2tcLtYYyT69/0fSSrGbl3qSJHmui5aTpNFLKN72E0Nd5Ch8S+iI6rbk730PzWGmEA1 UyzA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:references:subject:cc:to:from :message-id:date:content-transfer-encoding:mime-version :dkim-signature; bh=lscZf/HGAxlzE7bk1409Lj9L312lU7tsK/1nphr5GNY=; fh=EXlQ39UOIkVEBCVejBWVo4U8uwp99tSRsCb1s4xZKsw=; b=htC7G88l73oh1S4NlZPKlXk/aYzim0MIbvIulQcHMQoMzKzZ18SUfOO7eIYM892eyK 26BnKGje3NDDnzUBDhUsxP8X58sNToqFseXKRcYHZWFWI6K4hBkUPHXjw+t30OAY5Q9d zyj8k7JRxDOK59ONJzr6hdgIs2d06xehcJxfhan+Xf+rRsZnMjGxcLCj6EtpqlyTCanu t7B1sqmxjrM3vVK/FW/xuAvFXWR1w6Y0nP7kceUND/Tyu9BwPFSAHlRKQ2kGh5mLbNpM oCvQVbD3XBqc4QdZU7CW++qpdYCrgnP0hhWyMJrvJLCa2hBSgIHkMDH6QlmjhHYz1jHN abxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WHrn6dUc; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u4-20020a17090341c400b001b8c4021be9si529551ple.397.2023.07.10.16.21.46; Mon, 10 Jul 2023 16:22:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=WHrn6dUc; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S230119AbjGJXKm (ORCPT + 99 others); Mon, 10 Jul 2023 19:10:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230335AbjGJXKk (ORCPT ); Mon, 10 Jul 2023 19:10:40 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 424801BF; Mon, 10 Jul 2023 16:10:37 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BEFFD61259; Mon, 10 Jul 2023 23:10:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 70293C433C7; Mon, 10 Jul 2023 23:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689030636; bh=8sYs0oJhv8C3D6vbycCvzDy7MRStcTggwjlS91xXHfo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=WHrn6dUce/0SK5OppFPh4z+NfBA+J0JIjZ/a2s+It0xqanPkCN8NuiniAGWFsszDJ jtp/Q82CXOn1h9afl1tYGna68+t7niowebCXAzXv7MJOw0DJFNgNPoouunw8lgS3rm dxM5adaMzmaJAN+sjZjwEdS2Vsrl++UxM5CCHCGelwrJKhKTIDa0Lk8yZgSOhTKZIK cCiX/34FaI1ktsRhy3TKVyHjPUtX9vE11DnIZ8TierCkdhmVRraHl6Z9QIDitYnirI o837NZHFKr95lwIIdH25p/CPnQWTzqqFyh9wQgRAHQtlkrt6jMKZ0IiB1Uf9RLOQEQ 8ExLKoTg/AzCA== Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 11 Jul 2023 02:10:31 +0300 Message-Id: From: "Jarkko Sakkinen" To: "Dan Carpenter" , "Herbert Xu" Cc: "David Howells" , "David S. Miller" , , , Subject: Re: [PATCH] KEYS: asymmetric: Fix error codes X-Mailer: aerc 0.14.0 References: In-Reply-To: X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon Jul 3, 2023 at 5:18 PM EEST, Dan Carpenter wrote: > These error paths should return the appropriate error codes instead of > returning success. > > Fixes: 63ba4d67594a ("KEYS: asymmetric: Use new crypto interface without = scatterlists") > Signed-off-by: Dan Carpenter > --- > crypto/asymmetric_keys/public_key.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys= /public_key.c > index e787598cb3f7..773e159dbbcb 100644 > --- a/crypto/asymmetric_keys/public_key.c > +++ b/crypto/asymmetric_keys/public_key.c > @@ -185,8 +185,10 @@ static int software_key_query(const struct kernel_pk= ey_params *params, > =20 > if (issig) { > sig =3D crypto_alloc_sig(alg_name, 0, 0); > - if (IS_ERR(sig)) > + if (IS_ERR(sig)) { > + ret =3D PTR_ERR(sig); > goto error_free_key; > + } > =20 > if (pkey->key_is_private) > ret =3D crypto_sig_set_privkey(sig, key, pkey->keylen); > @@ -208,8 +210,10 @@ static int software_key_query(const struct kernel_pk= ey_params *params, > } > } else { > tfm =3D crypto_alloc_akcipher(alg_name, 0, 0); > - if (IS_ERR(tfm)) > + if (IS_ERR(tfm)) { > + ret =3D PTR_ERR(tfm); > goto error_free_key; > + } > =20 > if (pkey->key_is_private) > ret =3D crypto_akcipher_set_priv_key(tfm, key, pkey->keylen); > @@ -300,8 +304,10 @@ static int software_key_eds_op(struct kernel_pkey_pa= rams *params, > =20 > if (issig) { > sig =3D crypto_alloc_sig(alg_name, 0, 0); > - if (IS_ERR(sig)) > + if (IS_ERR(sig)) { > + ret =3D PTR_ERR(sig); > goto error_free_key; > + } > =20 > if (pkey->key_is_private) > ret =3D crypto_sig_set_privkey(sig, key, pkey->keylen); > @@ -313,8 +319,10 @@ static int software_key_eds_op(struct kernel_pkey_pa= rams *params, > ksz =3D crypto_sig_maxsize(sig); > } else { > tfm =3D crypto_alloc_akcipher(alg_name, 0, 0); > - if (IS_ERR(tfm)) > + if (IS_ERR(tfm)) { > + ret =3D PTR_ERR(tfm); > goto error_free_key; > + } > =20 > if (pkey->key_is_private) > ret =3D crypto_akcipher_set_priv_key(tfm, key, pkey->keylen); > @@ -411,8 +419,10 @@ int public_key_verify_signature(const struct public_= key *pkey, > =20 > key =3D kmalloc(pkey->keylen + sizeof(u32) * 2 + pkey->paramlen, > GFP_KERNEL); > - if (!key) > + if (!key) { > + ret =3D -ENOMEM; > goto error_free_tfm; > + } > =20 > memcpy(key, pkey->key, pkey->keylen); > ptr =3D key + pkey->keylen; > --=20 > 2.39.2 I'll pick this as I'm late with 6.5 PR. Reviewed-by: Jarkko Sakkinen BR, Jarkko