Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp119936pxa; Wed, 26 Aug 2020 06:26:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvRMOgEh9mDvWRoHT6TUQRNJ1b6cEVA66yc0Tx1yOQHXHT7Y3meryEMEM57m/wM6O0x+xi X-Received: by 2002:a17:906:91c8:: with SMTP id b8mr6217308ejx.103.1598448366974; Wed, 26 Aug 2020 06:26:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598448366; cv=none; d=google.com; s=arc-20160816; b=UC0p6Kbm8QdW+92cHhghmRQEcD7WghjfzSFQvy7vcLp5M6tTU+aEtASNh4CP1wmjFz BUvEwocR9i881PaBPrL/m3Xb71HU9GXmlCUcL2g1QnMQf8vpfq/swbY/rSF76+DDOK9y lAXrDkjxQF3zSuxKUTtl8JOR9S9EJSl29g+Kh4u1VFYAVB69utbQx4GpdZb04r2p81R3 Qdr3jpp1ECnTNHnEXg66yFtzTbwbB9T9e0eb8VtT3nqP3RVKwBOZLir+JvTSNr4KS7PX gwZd1nkE69lL69FTt2q1tvOe4C2a1k1Uze3V70+J3S5BPm1IsUtRinkvt75B1tVJM1Pm DvDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=KzstNuDLEgCqMhPzfbUI0ChLkjuGrPj7EWJxjD5ej3s=; b=KzXxwOUexxqzE7HdRg/RLoOKtygWl5jcaaT8K3Y/IUccB05mCQnskXBKgMa48+abBh Npd+njq+rLZ27NQvaSzindJHHaF7oN1Rvdhlztlxc02hqfu4IvcGonQGd7bgO2bARFBN gfwKfvE+B3yvITGcdMM0IDZZtnaqHJVwNv0UlElWOkWcsvbnd9c29wSe3FcdjOb1bMV3 rJNZPbn7BOScsYSxXEIk8LT/nV8KjIzJxjXsNRvGYXX3JyDTAdciIMSRDAWqSnlofW9B PH7dcBJeX3GwY0PphS4MV6u/Bc+xglYdlg4ugulJCF1DzKjb6MpFD0iCIVtte1Yz2GcP oRjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aIzcJauX; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z13si1548684ejc.304.2020.08.26.06.25.40; Wed, 26 Aug 2020 06:26:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aIzcJauX; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729504AbgHZNYq (ORCPT + 99 others); Wed, 26 Aug 2020 09:24:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728132AbgHZNYp (ORCPT ); Wed, 26 Aug 2020 09:24:45 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67CECC061574; Wed, 26 Aug 2020 06:24:44 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id k20so1753791wmi.5; Wed, 26 Aug 2020 06:24:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=KzstNuDLEgCqMhPzfbUI0ChLkjuGrPj7EWJxjD5ej3s=; b=aIzcJauXxLxWhF6r1s3rboD6nalp/PGjCJWEq3AMaA6EFkGQ/hBCeAf7lArmkCHsla G/I26tLIyMHEvT69xDMo6l92lRjaN9chguVZvrI4gfv/nCRo2WgHJxO31tUb43kkVlQ/ i6+mNrYTcQ069BsfTIOl6YQKfyKZguXzLugN6PZuBYzGpBsBzLHBZcjO0HAWLJzf0wdt oUrvJntuevR9sboZRbbAzeNaRhDfzD/k1HOBENl7Wf1k8rz2LpAMVN7cefFSsHkbanBk PbPXEm3+ZDkDaOiQWXhO01FkXrrS6ExN5ib5rnDKFOxqj0OQCU0cMkWXozH9vC5GQX7q Z1UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=KzstNuDLEgCqMhPzfbUI0ChLkjuGrPj7EWJxjD5ej3s=; b=cHUKmNUtx3G6DFfYhvrz8rCb+u/yugw7NBl5GkJ5IF1NQMspy7C/F/UPswZ1nwtDNO ObVbt8jFI1Z/6Xbldu0GzSRAleF/lg+45oT32+l2/Pq5k3nMrSi9aVtEq5x2dVKdK4MK HH1rEqOhisKMnKd4nJY5XpDkxQia+UwQ57jtw/88KTQx73wL1RKmCr125OHER0INCOJw pUVwYKyzSGUjFfB/RwlqrM4IJtGilC3RlvUCI7eFDdV8MuH1nh3ic1VFvu+tr4HbzCAy VCQ+9AdM4ibtojP18SfyHl1K7NDK9ZxeVMVcvxyZMfgb/4yjrWzT2mNAWLNhlnyVyVFt JUSA== X-Gm-Message-State: AOAM532H/mfQ9iEzML5BeE+tMHe3I7AGW5AMRE3dKds+IoGD+w1tNA73 bbJxyyJsJhA+a1f3au/Yre0= X-Received: by 2002:a7b:ca4e:: with SMTP id m14mr6032901wml.17.1598448283018; Wed, 26 Aug 2020 06:24:43 -0700 (PDT) Received: from Red ([2a01:cb1d:3d5:a100:264b:feff:fe03:2806]) by smtp.googlemail.com with ESMTPSA id l1sm6642625wrb.12.2020.08.26.06.24.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Aug 2020 06:24:42 -0700 (PDT) Date: Wed, 26 Aug 2020 15:24:40 +0200 From: Corentin Labbe To: Denis Efremov Cc: linux-crypto@vger.kernel.org, Corentin Labbe , Herbert Xu , "David S. Miller" , linux-amlogic@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] crypto: amlogic - use kfree_sensitive() Message-ID: <20200826132440.GA13819@Red> References: <20200826131657.398090-1-efremov@linux.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200826131657.398090-1-efremov@linux.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Wed, Aug 26, 2020 at 04:16:57PM +0300, Denis Efremov wrote: > Use kfree_sensitive() instead of open-coding it. > > Signed-off-by: Denis Efremov > --- > drivers/crypto/amlogic/amlogic-gxl-cipher.c | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > > diff --git a/drivers/crypto/amlogic/amlogic-gxl-cipher.c b/drivers/crypto/amlogic/amlogic-gxl-cipher.c > index d93210726697..f3dca456d9f8 100644 > --- a/drivers/crypto/amlogic/amlogic-gxl-cipher.c > +++ b/drivers/crypto/amlogic/amlogic-gxl-cipher.c > @@ -341,8 +341,7 @@ void meson_cipher_exit(struct crypto_tfm *tfm) > struct meson_cipher_tfm_ctx *op = crypto_tfm_ctx(tfm); > > if (op->key) { > - memzero_explicit(op->key, op->keylen); > - kfree(op->key); > + kfree_sensitive(op->key); > } > crypto_free_skcipher(op->fallback_tfm); > } > @@ -368,8 +367,7 @@ int meson_aes_setkey(struct crypto_skcipher *tfm, const u8 *key, > return -EINVAL; > } > if (op->key) { > - memzero_explicit(op->key, op->keylen); > - kfree(op->key); > + kfree_sensitive(op->key); > } > op->keylen = keylen; > op->key = kmemdup(key, keylen, GFP_KERNEL | GFP_DMA); > -- So the {} are no longer necessary. Same for the "if (op->key)" test since kfree handle NULL. Thanks