Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6209051ybe; Tue, 17 Sep 2019 22:58:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaJlNiziNFYvUbgp4WD2GnZdbc5B5tM7826IKb9JohaKVnfDCzWpFE0FfZfdlivf1Rs0TM X-Received: by 2002:aa7:d844:: with SMTP id f4mr142366eds.269.1568786290618; Tue, 17 Sep 2019 22:58:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568786290; cv=none; d=google.com; s=arc-20160816; b=U+lP2gHO+jgsjBit9e7XA9X5ouWjBYZzRvKm2e0TfM8tKvQkyxonNb2TvaCXhDRSQa ay4uNkNsUZYvxHxXCcQxTJQCx6p8JHk/ug84L7Dmr0YSlbkPO+xIilDuGL87ZjjTquBy /eajkEjyDbfIswcw21xegP/Ei90A7TAWjZIR/WutlYZglix14L/vvVFnDrdFAUXC4oMa dSAX+7hdeCf6HKzMbjSoCBF8JyvSizt94inV79Y5gczVs+V3GZAkV2XHPHxz5qtbe2lO W5UZKeJMQrjFJXkO27zB0DhV7aIW1mKaSW2citY43jEOI1+JdmtCxe8V2CokUFrMQrcs wBkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=Ke/fI1ObcFRu9ZYev+wWJlFAFV7LhjP8nEA+bR04VaY=; b=ZKPDwW4mDQMlDhASD2YoGlH9UBA/LQiGFalVKMDqsRWWxw0Kna2fK+qo3p3AratrOn 29jQVGSy6S6DiV/PdPNTVWWjJqEZbLscWKK1dhhLyioiAYSHnxLGDKwdluhy2GZ3s8+3 9/f4IYoEZwmGHWmfMe++dFaiccqQTIK2yw6knhYB92yROx6Q8GeT6kBrDwMVd8s1ZXbK M6WlcSpke2gyeJwFVSRQSF3AubEIcvE7Ap/tHp/Rlw5ougKwciI4IyPlD0NcxLQA2SEa 0XboqusUSExMmUJRNH/U5jhF9qbjqRcnufwCc3CUBKdgpVyVJtaD+TXSnFx1vtfEYGaA ueVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l22si2734040edb.241.2019.09.17.22.57.47; Tue, 17 Sep 2019 22:58:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728068AbfIRCjz (ORCPT + 99 others); Tue, 17 Sep 2019 22:39:55 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:58806 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726832AbfIRCjy (ORCPT ); Tue, 17 Sep 2019 22:39:54 -0400 Received: from DGGEMS414-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id E8493CCD94CCCA3EC4AC; Wed, 18 Sep 2019 10:39:52 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS414-HUB.china.huawei.com (10.3.19.214) with Microsoft SMTP Server id 14.3.439.0; Wed, 18 Sep 2019 10:39:45 +0800 From: zhong jiang To: , CC: , , , , Subject: [PATCH net-next] ixgbe: Use memzero_explicit directly in crypto cases Date: Wed, 18 Sep 2019 10:36:35 +0800 Message-ID: <1568774195-8677-1-git-send-email-zhongjiang@huawei.com> X-Mailer: git-send-email 1.7.12.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In general, Use kzfree() to replace memset() + kfree() is feasible and resonable. But It's btter to use memzero_explicit() to replace memset() in crypto cases. Signed-off-by: zhong jiang --- drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c index 113f608..7e4f32f 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c @@ -960,9 +960,11 @@ int ixgbe_ipsec_vf_add_sa(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf) return 0; err_aead: - kzfree(xs->aead); + memzero_explicit(xs->aead, sizeof(*xs->aead)); + kfree(xs->aead); err_xs: - kzfree(xs); + memzero_explicit(xs, sizeof(*xs)); + kfree(xs); err_out: msgbuf[1] = err; return err; @@ -1047,7 +1049,8 @@ int ixgbe_ipsec_vf_del_sa(struct ixgbe_adapter *adapter, u32 *msgbuf, u32 vf) ixgbe_ipsec_del_sa(xs); /* remove the xs that was made-up in the add request */ - kzfree(xs); + memzero_explicit(xs, sizeof(*xs)); + kfree(xs); return 0; } -- 1.7.12.4