Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4672021iob; Sun, 8 May 2022 21:25:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOmULyRqnzLAhWcpevXi6CqTuk5zijrryg4lWw202h8PUGet93mbb85kjdcOfmhcl3074v X-Received: by 2002:a17:902:a387:b0:15e:f63f:237f with SMTP id x7-20020a170902a38700b0015ef63f237fmr10850369pla.32.1652070329390; Sun, 08 May 2022 21:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652070329; cv=none; d=google.com; s=arc-20160816; b=ORhF4pnkit6hO/uibsNli/+lBYrp7WN6/p5lDEp6JQtJk3thKL4eshB+GhTyXlXS6Y GWajj5nfGv7Zx/EZeaOTmXxYsj/oADAlWXm+L40BVuErETdq4w/wb8hjnfkt4mBH86r6 iZttlgvzbywI1tyi8f/tmVLd5UBOKRto6NlEPk/WWpSBRMkYhi9riuKWCJckwpf38Aj0 VOYr78KWfeHF1BsOliBIxQPstlwJgahbJ6nUzkY8GB8LH9ZjNNq7T2jRdjc+uBN2ouZo X0sigY/IX1HZsqh/ke3HdWR685exr0EXUtkco0wITBY56qeVOYMp1Oi4UdVNGpcJ84n2 ZkRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=9MNeK9dq6XJ1tAJ41nZ2SJOTJlxFsMiN/YlTG3IABvM=; b=q+VHjulU/l2ZMYL/Ulz9xvz7FIHeHlnVdgHpN/XySUmdhuUw+uuxaZf56Sh83+anc0 dM9m4NEgEagLCBZC+xwa+VcwxF5dya6Q3mS2ZmeOZg9GVACVRHw/A2qPNl+rZKBNzBNS OatV9LqECPUGrZM82vL3fU/1i2l8AzFFLNSw8+RoLdztrZ1B+bxt2M2xvc220r/5gHZk SJMhLA4Cv4jsnlOxLvomd+vA4ZuJn+YykYxTZMxSB8wu2vOl99AbfM8ES+V9rQTJsdF9 sRJJCQfreTMt3+u4ct5i2o2kmVEME67b6OBWcnzi/1cV5+5JU2wGc7AqGFj79k5aXSUO B9vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GOG57SAg; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g11-20020a65580b000000b003c64e392a09si10944593pgr.592.2022.05.08.21.25.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 21:25:29 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=GOG57SAg; spf=softfail (google.com: domain of transitioning linux-crypto-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F3D7611E5F2; Sun, 8 May 2022 21:25:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345366AbiEFJ55 (ORCPT + 99 others); Fri, 6 May 2022 05:57:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236473AbiEFJ54 (ORCPT ); Fri, 6 May 2022 05:57:56 -0400 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF28867D28; Fri, 6 May 2022 02:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1651830853; x=1683366853; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=D2fOVPqK96/pXvpwlXxzgoBM06E6UgVfGVY77Vl/uHI=; b=GOG57SAghjmheKyF65U2OmRp+KyJ1fnXS9a838VpTSmFys8gqEN9R2ve M0Zkffb4CC/F3U22lUSzFL4BJWrJVwtyTlrEIjUjTx5ySYmCg7n5Gofxi y7ARIkgDWSBbhKc50mZP0gi68RWxpJoZLVstfaDAmY1b8Oxb4+Ms6+48K hBRQry5vTRflHxJKJ5jFtTROP+zjX1a9eQTQe0BVohsCrODlEitm+l5GE fwF7ATFI3RMeTwAjcqMUsX0grdA/yeP/18lgWEb8rfq+ktdXvRo8l87Bm Y47JJNEiaN8ScZzH61KfHa2y8eSP8VqzC5dOfGEzgl5oiw5jWS1Ai7jA2 A==; X-IronPort-AV: E=McAfee;i="6400,9594,10338"; a="331407505" X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="331407505" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 02:54:13 -0700 X-IronPort-AV: E=Sophos;i="5.91,203,1647327600"; d="scan'208";a="621757997" Received: from silpixa00400314.ir.intel.com (HELO silpixa00400314) ([10.237.222.76]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 May 2022 02:54:10 -0700 Date: Fri, 6 May 2022 10:54:07 +0100 From: Giovanni Cabiddu To: Greg KH Cc: herbert@gondor.apana.org.au, linux-crypto@vger.kernel.org, qat-linux@intel.com, vdronov@redhat.com, stable@vger.kernel.org, Adam Guerin , Wojciech Ziemba Subject: Re: [PATCH 10/12] crypto: qat - use memzero_explicit() for algs Message-ID: References: <20220506082327.21605-1-giovanni.cabiddu@intel.com> <20220506082327.21605-11-giovanni.cabiddu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Research and Development Ireland Ltd - Co. Reg. #308263 - Collinstown Industrial Park, Leixlip, County Kildare - Ireland X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 Fri, May 06, 2022 at 11:22:39AM +0200, Greg KH wrote: > On Fri, May 06, 2022 at 09:23:25AM +0100, Giovanni Cabiddu wrote: > > Use memzero_explicit(), instead of a memset(.., 0, ..) in the > > implementation of the algorithms, for buffers containing sensitive > > information to ensure they are wiped out before free. > > > > Cc: stable@vger.kernel.org > > Signed-off-by: Giovanni Cabiddu > > Reviewed-by: Adam Guerin > > Reviewed-by: Wojciech Ziemba > > --- > > drivers/crypto/qat/qat_common/qat_algs.c | 20 +++++++++---------- > > drivers/crypto/qat/qat_common/qat_asym_algs.c | 20 +++++++++---------- > > 2 files changed, 20 insertions(+), 20 deletions(-) > > > > diff --git a/drivers/crypto/qat/qat_common/qat_algs.c b/drivers/crypto/qat/qat_common/qat_algs.c > > index 873533dc43a7..c42df18e02b2 100644 > > --- a/drivers/crypto/qat/qat_common/qat_algs.c > > +++ b/drivers/crypto/qat/qat_common/qat_algs.c > > @@ -637,12 +637,12 @@ static int qat_alg_aead_newkey(struct crypto_aead *tfm, const u8 *key, > > return 0; > > > > out_free_all: > > - memset(ctx->dec_cd, 0, sizeof(struct qat_alg_cd)); > > + memzero_explicit(ctx->dec_cd, sizeof(struct qat_alg_cd)); > > This is for structure fields, why does memset() not work properly here? > The compiler should always call this, it doesn't know what > dma_free_coherent() does. You are referencing this pointer after the > memset() call so all should be working as intended here. > > Because of this, I don't see why this change is needed. Do you have > reports of compilers not calling memset() for all of this properly? Apologies, I had a wrong assumption. Based on a comment in the memzero_explicit() documentation I assumed it should be always used to zero sensitive data. * memzero_explicit - Fill a region of memory (e.g. sensitive * keying data) with 0s. I'm going to drop this patch. Thanks, -- Giovanni