Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752361AbdHHSNm (ORCPT ); Tue, 8 Aug 2017 14:13:42 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:56386 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752294AbdHHSNl (ORCPT ); Tue, 8 Aug 2017 14:13:41 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Pan Bian Cc: kexec@lists.infradead.org, linux-kernel@vger.kernel.org References: <1502195440-3600-1-git-send-email-bianpan2016@163.com> Date: Tue, 08 Aug 2017 13:05:16 -0500 In-Reply-To: <1502195440-3600-1-git-send-email-bianpan2016@163.com> (Pan Bian's message of "Tue, 8 Aug 2017 20:30:40 +0800") Message-ID: <87bmnqey03.fsf@xmission.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1df90Z-0003Qz-P2;;;mid=<87bmnqey03.fsf@xmission.com>;;;hst=in01.mta.xmission.com;;;ip=67.3.200.44;;;frm=ebiederm@xmission.com;;;spf=neutral X-XM-AID: U2FsdGVkX18r1IyDWtpZuddN1cgv8xdn2Y+GQAX1dpA= X-SA-Exim-Connect-IP: 67.3.200.44 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.4991] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa08 1397; Body=1 Fuz1=1 Fuz2=1] X-Spam-DCC: XMission; sa08 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Pan Bian X-Spam-Relay-Country: X-Spam-Timing: total 215 ms - load_scoreonly_sql: 0.02 (0.0%), signal_user_changed: 2.4 (1.1%), b_tie_ro: 1.72 (0.8%), parse: 0.57 (0.3%), extract_message_metadata: 1.90 (0.9%), get_uri_detail_list: 0.67 (0.3%), tests_pri_-1000: 15 (6.9%), tests_pri_-950: 0.89 (0.4%), tests_pri_-900: 0.73 (0.3%), tests_pri_-400: 20 (9.3%), check_bayes: 19 (9.0%), b_tokenize: 3.5 (1.6%), b_tok_get_all: 4.7 (2.2%), b_comp_prob: 1.16 (0.5%), b_tok_touch_all: 2.2 (1.0%), b_finish: 0.61 (0.3%), tests_pri_0: 163 (75.9%), check_dkim_signature: 0.42 (0.2%), check_dkim_adsp: 29 (13.5%), tests_pri_500: 2.9 (1.4%), rewrite_mail: 0.00 (0.0%) Subject: Re: kexec_file: use crypto_free_shash to free memory X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1218 Lines: 35 Pan Bian writes: > In function kexec_calculate_store_digests(), kfree() is used to free > memory allocated by crypto_alloc_shash(). It is better to use function > crypto_free_shash(), which also zeroizes the memory to be freed. Why is it important to zero memory? There is nothing sensitive being stored or hashed. The hash is used for integrity checking purposes. If the argument is that kfree is simply the wrong frunction for freeing something allocating with crypto_alloc_shash() I can believe that. In which case that sounds like something that needs to be fixed. But I am concerned that wasn't your argument and you are talking about something that appears to be completely irrelevant. Eric > Signed-off-by: Pan Bian > --- > kernel/kexec_file.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c > index 9f48f44..94eeb38 100644 > --- a/kernel/kexec_file.c > +++ b/kernel/kexec_file.c > @@ -627,7 +627,7 @@ static int kexec_calculate_store_digests(struct kimage *image) > out_free_desc: > kfree(desc); > out_free_tfm: > - kfree(tfm); > + crypto_free_shash(tfm); > out: > return ret; > }