Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp1132139ybg; Thu, 11 Jun 2020 01:36:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXb3eI2iVzpMAY6LnJMsqrFi1YCsZJmQtm7APbyYLUm7Qfukyf0FBZ/End2GChtHmBo8Ta X-Received: by 2002:a50:9d83:: with SMTP id w3mr5878388ede.95.1591864606358; Thu, 11 Jun 2020 01:36:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591864606; cv=none; d=google.com; s=arc-20160816; b=enCvSAcbiZ4aYDXTvEC6GwutKjh9RPpz24Uvtk5wBajkF/cQrxhmA9X5Mm5Jo7chvi HXbZpk2urkwESZgTpOSqPsANu6SqNmnwAokphe2d7t+znRXh82Nj7hpCruwN1EMT1nxo py4wn88TMdYYZDLZXfvWp3xGoI8jij1Jj6bros1a150AOnTmrn6nNv55RKgkxy/5VqXH b7qqLk8ZqqwerdYyXtFUa3m2sfeOR6XsLrDTpHzYQJHUSydDa2CcsrlzqBUdEteiEOSm NaUCTth8h7yXIbC5tCLCGUdds6qK9XakR9n9qQmhVkUYQaGSA7Q5ggZoW6Abt8c922s0 xi8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=weuO0XFY/dx0FwiZnPD9oxzQ7IOVWYOP67G4Q17Dtpg=; b=AlG3368FSs1z325q4b3Nsd1nWRjwmHCUL1H/laBMuva/IfOIkcnYe5TKOnsDkJb7mk V3+xkhMUXwJu8+i0ElQqvy35iAvRWXdgM68Y8NJ9v4rvZYicJKqLcyR4ZODbdIek/p6Q 7yCtjBjMODNRIT2U3vardZ/m1bdoIkd+x7Sav4DjfcuDtkgiwEl4delODgIC9UyUKGqw CGmaRhFv5pkXl9DRRe1dJxo0dDBuCA4PiTlvZ7mMMdWHb5ZA2xNG11WnYEMveLN6iYOZ tsWLA+V1XcQAugPHaNgLjGZ5g4Xm/BBfGRzNrgGcNi1xuH6CZutxkjN1Hz6N+qo7lpya Cs8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@chronox.de header.s=strato-dkim-0002 header.b=WtLg4Gcy; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o18si1587898ejr.423.2020.06.11.01.36.22; Thu, 11 Jun 2020 01:36:46 -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=fail header.i=@chronox.de header.s=strato-dkim-0002 header.b=WtLg4Gcy; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbgFKIeH (ORCPT + 99 others); Thu, 11 Jun 2020 04:34:07 -0400 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.163]:9800 "EHLO mo4-p00-ob.smtp.rzone.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726651AbgFKIeG (ORCPT ); Thu, 11 Jun 2020 04:34:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1591864445; s=strato-dkim-0002; d=chronox.de; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: X-RZG-CLASS-ID:X-RZG-AUTH:From:Subject:Sender; bh=weuO0XFY/dx0FwiZnPD9oxzQ7IOVWYOP67G4Q17Dtpg=; b=WtLg4GcyOYKd87Kixtck60zs+Q1yOifiNC2EL8WamFmawagYTmiEjYLTGmq8czb0Yd OXIcdxcbsl3M+gr/wnHwu/MFM434JxmM9ZhG5Oye2NxNVXtxjHF6zWKWaWmPmKCTSUKO fMVkBdu1ORagsWg3aXoeXDj6o1GZj1DEjzVxDbDrENN5cp3CnMA3UXSUfxdrJU4IIXe7 d3o382Yw1/Y25ruF7cGgJjrzzTAHX8Yp7pBxk9GwXGvN/egD2l0fa2ZN9cRH7U3w0zj4 kqbgHv5vLaE/QnX7PvKRy7lebedVPVLn07urCaKEvu7iIfevyJa/8YoC+dBt2p3RL5Nf fWSw== X-RZG-AUTH: ":P2ERcEykfu11Y98lp/T7+hdri+uKZK8TKWEqNyiHySGSa9k9xmwdNnzGHXPaIfSfDhz3" X-RZG-CLASS-ID: mo00 Received: from tauon.chronox.de by smtp.strato.de (RZmta 46.10.1 DYNA|AUTH) with ESMTPSA id 6010b6w5B8Xx05J (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Thu, 11 Jun 2020 10:33:59 +0200 (CEST) From: Stephan Mueller To: Zheng Bin Cc: herbert@gondor.apana.org.au, davem@davemloft.net, linux-crypto@vger.kernel.org Subject: Re: [PATCH] crypto: drbg - Fix memleak in drbg_prepare_hrng Date: Thu, 11 Jun 2020 10:33:58 +0200 Message-ID: <37905178.8f6zGtLfKx@tauon.chronox.de> In-Reply-To: <20200611083356.88600-1-zhengbin13@huawei.com> References: <20200611083356.88600-1-zhengbin13@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Am Donnerstag, 11. Juni 2020, 10:33:56 CEST schrieb Zheng Bin: Hi Zheng, Thank you for the note, but I think this is handled, albeit differently. Search for patch "[PATCH v3] crypto: DRBG - always try to free Jitter RNG instance" that is sent to the list (but not yet applied). Thanks > drbg_prepare_hrng > drbg->jent = crypto_alloc_rng > err = add_random_ready_callback > default: > drbg->random_ready.func = NULL -->set NULL, if fail > > drbg_uninstantiate > if (drbg->random_ready.func) -->If NULL, will not free drbg->jent > crypto_free_rng(drbg->jent) > > Need to free drbg->jent if add_random_ready_callback return fail. > > Fixes: 97f2650e5040 ("crypto: drbg - always seeded with SP800-90B compliant > noise source") Signed-off-by: Zheng Bin > --- > crypto/drbg.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/crypto/drbg.c b/crypto/drbg.c > index 37526eb8c5d5..a643ab7eac7a 100644 > --- a/crypto/drbg.c > +++ b/crypto/drbg.c > @@ -1524,6 +1524,8 @@ static int drbg_prepare_hrng(struct drbg_state *drbg) > /* fall through */ > > default: > + crypto_free_rng(drbg->jent); > + drbg->jent = NULL; > drbg->random_ready.func = NULL; > return err; > } > -- > 2.26.0.106.g9fadedd Ciao Stephan