Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp961394ybh; Wed, 22 Jul 2020 18:37:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ0SZPPOxMcWDH5F2fR74qotlykTmyuGaXgyoF48yRoSAhIuGt9/Cb0ONHNTUwh8ppXkPO X-Received: by 2002:a17:906:3291:: with SMTP id 17mr2294868ejw.370.1595468230086; Wed, 22 Jul 2020 18:37:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595468230; cv=none; d=google.com; s=arc-20160816; b=PUjOLVw+v5//tcd4oeOEHNHefvNWBeyl3aexxMJ/4Odcc4CDjOCOu9vodV7Pg4URaJ CmXvAdKtj8gkcrTjDirgj5jXjcSvrQzAvFfv9gQZocpriz0j6YdRW/4bzhzgFaXSS+bI hO/Honkq6+DJxbJvwgMfC4Vj8vUhGBYxXPtYAm7NXuDqNirJswDlcMvhmN8NCMXw8cc2 DUcieJ7eP6VqLUJ0Wr3lQgbaHtO2G+PDwir70CMsYy7x6soBLRYa3xOx3Yhl6sVcK4+r pc8VoDQBV25Vosdlnmbi+xU3bjn75snZwvfchlkg2Q0dSdMRZKseDWceFWPLYBBqb0Q+ FHIQ== 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=hjadAxRwZ4ONqEYKSJ+unw6gm44p6xM2haYQlRSifME=; b=dAJt/1q2OA39fQw3s/Ag3F6HUtqls50/y9WnJFJC0I3JIRmZk/sniGjhHlR+2ooBS+ y4hQc+Tf00A7s+Y6AGfizxbqvf1R51wzwq+pVk8aS91DrdfoFnHJqCKoYxEdcdqEdUY1 vdVqfF1+XBTOyJ1LgAGNQc5nVlATYRW2UAD/bZbM6uyRypmctcwoP00yTaCrRMdQuUoq 3jQZ3HTIyJ09RITj+SmjPvTni6Ql2BNHyW+0iMStdDOEPERpyDP3GYGWdCRqyI2S0KNv 3OkrIPS+uC3twFLxNQQJ1IvEP6Zk6DoU144/MEcv4slvgAGhyJ+VRBazP1b/8J2MZRmM gllQ== 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 k27si286365ejb.408.2020.07.22.18.36.47; Wed, 22 Jul 2020 18:37:10 -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 S2387462AbgGWBg3 (ORCPT + 99 others); Wed, 22 Jul 2020 21:36:29 -0400 Received: from mga09.intel.com ([134.134.136.24]:43875 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728914AbgGWBg2 (ORCPT ); Wed, 22 Jul 2020 21:36:28 -0400 IronPort-SDR: hM2SfAXARxKwbMxSk6JaOHkSl/70rntNggy4kLVTWpRYjv4Oou8Q4MsN0IQX8LJ+6Xjzq9PbD5 3tCZ6iWZFBYg== X-IronPort-AV: E=McAfee;i="6000,8403,9690"; a="151761096" X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="151761096" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jul 2020 18:36:27 -0700 IronPort-SDR: OCxofJAfgBSRpuQqcUhQpDfslXUhmaxClJafopr1zuUTivfh3c0/hmltsjqykrtxffYelxX4xJ z9sGg/9Dc+MQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,383,1589266800"; d="scan'208";a="310842811" Received: from schwings-mobl.ger.corp.intel.com (HELO localhost) ([10.252.33.132]) by fmsmga004.fm.intel.com with ESMTP; 22 Jul 2020 18:36:23 -0700 Date: Thu, 23 Jul 2020 04:36:22 +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: <20200723013622.GB45081@linux.intel.com> References: <159485211858.2340757.9890754969922775496.stgit@warthog.procyon.org.uk> <20200723013223.GA45081@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200723013223.GA45081@linux.intel.com> 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 Thu, Jul 23, 2020 at 04:32:38AM +0300, Jarkko Sakkinen wrote: > 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; > } To rationalize why the 2nd way is better: the diff would tell the whole story. Now this commit requires to check *both* the diff and the source file to get the full understanding what is going on. /Jarkko