Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp960389ybh; Wed, 22 Jul 2020 18:35:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJ8mwwLiZ+VRs7ejwSTQ4HYZS2ucaOIzDJ/Jc9VFO3rAL0uSkEI07JkzxpBeSsEM5MJ7WM X-Received: by 2002:a17:906:7253:: with SMTP id n19mr2244085ejk.387.1595468106314; Wed, 22 Jul 2020 18:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595468106; cv=none; d=google.com; s=arc-20160816; b=vIy3zTSVPdxYCX5P/Y04TI9fQiS6+v/dcM46ZDGvRXOVP/vUX1icjFDbuxoeErVjq0 P1ZFfTwEzDuym+AKfP99eIaVaaLlNEJSUWWBkdlQZ2a9LgkoFGOoj66jCli9e2nOJY2o kcBPk22kvleJKialysqKkYJ219h1JBf3c5KFqsf6hmaUzHxxZd6AWs75CT3nN1W4lzbN z041lPkHm5FiU9TUWQP4qG1e2jDWADJ+xjCmIKplBdNiBXRDo65CKTOKmzK0SkWhh5hW xvMVaW2uBviP0/xtWYbea9e46tkQ68Q2s9fo4EjmFDiHyqvz+pS8ID1q9RX0fDt+Qt1n HJQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:ironport-sdr:ironport-sdr; bh=yaDEIs5kESPNF6iyIT9AxDSo+X17op7b79U9SwVvq7g=; b=XSanMSEx2KzxlEU5WaV0HlZNZWu9nKfrcq6NUv5Hdx9hkHezD1Wr234ht9m6khIBbk j9ffzWMb8BZe4+BkhdSKimbP2XoxCg2a6C5kTQGMborz9uJmEXdCe/lVv8EIiWnABKJK XMz0+PShNdgojSAzdGfAdfQxFu83k/JYPRghB9P1MPrsyA6asVttjReRH0U6Ki62sEY5 TwKIWtAMU3yGGRQQ8tBeZ9BdTxl4diNwg6joFH9TjBcxUT6bs1mCjrIL2eu9Zcv5AVSB A9NZavEKja3GhrDfD6MBl0wUcFqafZGQjZFgj4QZdb4Pwi6EG+qC5feW4eCg9W7uwTfy L/HQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si1048774eju.478.2020.07.22.18.34.41; Wed, 22 Jul 2020 18:35:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387424AbgGWBcj (ORCPT + 99 others); Wed, 22 Jul 2020 21:32:39 -0400 Received: from mga01.intel.com ([192.55.52.88]:59090 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733075AbgGWBcj (ORCPT ); Wed, 22 Jul 2020 21:32:39 -0400 IronPort-SDR: +jqdWu9hzF+UozJIx3GeMjVwAHzx3jTzexjcBkX++A6/ErV7ESuE3s6bUgZ4OKAvahe3bhUZ33 0EfV3PhOVeoQ== X-IronPort-AV: E=McAfee;i="6000,8403,9690"; a="168585605" X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="168585605" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 18:32:38 -0700 IronPort-SDR: pTsqcZHQQ3nPDSGFdQBjwFz9HTWkoVOffURZxPc2szniHsomaYCFLjyRjSjMQ/bejoqNdNeOwO 3f582BsuQ/jw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="488656357" Received: from schwings-mobl.ger.corp.intel.com (HELO localhost) ([10.252.33.132]) by fmsmga005.fm.intel.com with ESMTP; 22 Jul 2020 18:32:36 -0700 Date: Thu, 23 Jul 2020 04:32:35 +0300 From: Jarkko Sakkinen To: David Howells Cc: torvalds@linux-foundation.org, Wei Yongjun , keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] keys: asymmetric: fix error return code in software_key_query() Message-ID: <20200723013223.GA45081@linux.intel.com> References: <159485211858.2340757.9890754969922775496.stgit@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <159485211858.2340757.9890754969922775496.stgit@warthog.procyon.org.uk> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 15, 2020 at 11:28:38PM +0100, David Howells wrote: > From: Wei Yongjun > > Fix to return negative error code -ENOMEM from kmalloc() error handling > case instead of 0, as done elsewhere in this function. > > Fixes: f1774cb8956a ("X.509: parse public key parameters from x509 for akcipher") > Signed-off-by: Wei Yongjun > Signed-off-by: David Howells Why f1774cb8956a lacked any possible testing? It extends ABI anyway. I think it is a kind of change that would require more screening before getting applied. > --- > > crypto/asymmetric_keys/public_key.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/crypto/asymmetric_keys/public_key.c b/crypto/asymmetric_keys/public_key.c > index d7f43d4ea925..e5fae4e838c0 100644 > --- a/crypto/asymmetric_keys/public_key.c > +++ b/crypto/asymmetric_keys/public_key.c > @@ -119,6 +119,7 @@ static int software_key_query(const struct kernel_pkey_params *params, > if (IS_ERR(tfm)) > return PTR_ERR(tfm); > > + ret = -ENOMEM; This is extremely confusing to read way to handle 'ret'. Would be way more cleaner to be just simple and stupid: if (!key) { ret = -ENOMEM; goto error_free_tfm; } > key = kmalloc(pkey->keylen + sizeof(u32) * 2 + pkey->paramlen, > GFP_KERNEL); > if (!key) /Jarkko