Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp1673894rwn; Fri, 9 Sep 2022 02:09:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR7noJhYQUmepGQ5XTwbS5ReEtmjBwZOOtOlbowSN5Kb3+2VSIIXYzsv8R+ea8V7kTrRHlbb X-Received: by 2002:a2e:bea3:0:b0:261:d1d7:95a9 with SMTP id a35-20020a2ebea3000000b00261d1d795a9mr3528598ljr.448.1662714544598; Fri, 09 Sep 2022 02:09:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662714544; cv=none; d=google.com; s=arc-20160816; b=sC07vRqT6Rn6eLMqt0QFXYxNkwHbZQ/30neF5JVELiLY2a5OguILvoFaqtUXka2imb Wu2bd6L72Vz/SKm0C/N8w3GSJfell7+c5UoPpFDlZQlrENVGvYIIjzc5WOAQUZFI9LjA tO6+1ZDooKqJj9PKnoX9PFXQEpBUgCmPgFw5+SXlG/02LffHNQoPWR/odUYjfDeGMyAe xETfYmV1uUe0EKammtNWdddx28Wm7IGrEtHsYnvxNviuSt4vYrUUWpVyArsEOmNVc+za WuFUToqtmcObg4q8FW//fNV8kiipShy75C6cHidd9KomJUhlCp7CAzKjawOTsEggTnTi ykTA== 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; bh=VLyOoSi7is1knEsTFdxWp8Q21meNQHXxag6x+b2Cq5Q=; b=TMOX4i3fAC/hPFnvhi/7eTutM21PQIwYcfYkA2JMiJr19voFjdSw916VFGE20lEWkP 1JJnaXRFgM91ChZH7Sotw+u/JszP3fH2pxrrbks3VkvALsJj3VknAjwzdIeRx/pHGQJ6 OHzaFS4MHCpWSlmMc1UptlQ9Km0E/gAzDDVatxqJ9A3Y+QI5efO/u20wxVOzkNrSyTlE rrovWIBFg/N2qHQmm/wdC946VwymU0ajkcoSSxzMWWk3NovCONadccwV3teX+j1YYPlP mG2bAZgAk5KQ6fSsNCOMn6kn1OeGrtx6meXIyxsv7WCFGxWAy0Lmc7nVvS2JZi0d4JFW VB8Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bf44-20020a05651225ac00b0048ce860a2easi515824lfb.538.2022.09.09.02.08.31; Fri, 09 Sep 2022 02:09:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231159AbiIIJID (ORCPT + 99 others); Fri, 9 Sep 2022 05:08:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232035AbiIIJHt (ORCPT ); Fri, 9 Sep 2022 05:07:49 -0400 Received: from fornost.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 909DC5727F; Fri, 9 Sep 2022 02:07:45 -0700 (PDT) Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1oWZzB-002oDK-H4; Fri, 09 Sep 2022 19:07:42 +1000 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Fri, 09 Sep 2022 17:07:41 +0800 Date: Fri, 9 Sep 2022 17:07:41 +0800 From: Herbert Xu To: Ignat Korchagin Cc: "David S . Miller" , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-team@cloudflare.com Subject: Re: [PATCH v2] crypto: akcipher - default implementation for setting a private key Message-ID: References: <20220831183706.1600-1-ignat@cloudflare.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220831183706.1600-1-ignat@cloudflare.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 Wed, Aug 31, 2022 at 07:37:06PM +0100, Ignat Korchagin wrote: > Changes from v1: > * removed the default implementation from set_pub_key: it is assumed that > an implementation must always have this callback defined as there are > no use case for an algorithm, which doesn't need a public key > > Many akcipher implementations (like ECDSA) support only signature > verifications, so they don't have all callbacks defined. > > Commit 78a0324f4a53 ("crypto: akcipher - default implementations for > request callbacks") introduced default callbacks for sign/verify > operations, which just return an error code. > > However, these are not enough, because before calling sign the caller would > likely call set_priv_key first on the instantiated transform (as the > in-kernel testmgr does). This function does not have a default stub, so the > kernel crashes, when trying to set a private key on an akcipher, which > doesn't support signature generation. > > I've noticed this, when trying to add a KAT vector for ECDSA signature to > the testmgr. > > With this patch the testmgr returns an error in dmesg (as it should) > instead of crashing the kernel NULL ptr dereference. > > Fixes: 78a0324f4a53 ("crypto: akcipher - default implementations for request callbacks") > Signed-off-by: Ignat Korchagin > --- > crypto/akcipher.c | 8 ++++++++ > 1 file changed, 8 insertions(+) Patch applied. Thanks. -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt