Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp399101pxb; Thu, 21 Jan 2021 09:38:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxqXibazuzUKaB43NpZLzc/ySt070ebCpOWT3M2FAKGQ4H30boStgCWEc1rMmp/W8fU6Vcy X-Received: by 2002:a17:906:7253:: with SMTP id n19mr368854ejk.543.1611250703145; Thu, 21 Jan 2021 09:38:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611250703; cv=none; d=google.com; s=arc-20160816; b=RAICJis5ArHVO5YmQg5d9mM/AQhHFRG6yWVDTDeyvVduKM4Q/g50inhQz51PrC/Uu/ yWwnyE7aLbb/kNGeYJNHUwX9hjXC7XP05fA4BaxxuTZYkVzKbt07LEO4+6N/LxGJDXzZ X9QQHAYEbyeWzX61KGauT/Ba3wOIdF7MFS/ac/0maMQ8ZbvQDivNQ+me5XrS90oVV/da ryHMwJzVaKV93XY/xGFfTyHzguqQArIV/jYPYAdRrTutVn6oEdrCWYkqEYkrwD465Tci nZIifAK0Lko8kwMA5PHu/ruEsjmgk5HWiFLvsu8yD7E/nrA3BdFm7dPjpTRf+NANFAHr Ahpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-filter; bh=a4cCNjrAKs4+vz3aERM9jzdT7vtf1mGZiPbZ15KjmZ0=; b=mA3hMakWppVVRreAphUwYc8yprgAK3gtL7yWMF9h2Iv7igGxCdx9MEO36weCkWlTB6 wMNk+xRqG/1sY05uNgT7wogKkqBAH5nG6sP7V3AuKj1dYBDNymRKbJJffxhEuGAQph/m AkTzbNJm9iOkuR831L6Y/QlhXS58VptVSwESi8mN+tzL1cTlRsSEFM3Gx6J512YFYnpg 0k/RbLnTDJ2tCehAHiJTa/UMyL2i4lPvCGZFc/vcpRwVjF97/cYrEhLcAXrZtY/MmkDH SGCk1Kb7aEZpowo2PLOCt8NbRXPzRwkUCRv4zjnUqDVrcQggX9iW+FQwkuAGuGBNF7g0 QXkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=mv27Noc+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t4si2400975edw.62.2021.01.21.09.37.57; Thu, 21 Jan 2021 09:38:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@linux.microsoft.com header.s=default header.b=mv27Noc+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388530AbhAURg5 (ORCPT + 99 others); Thu, 21 Jan 2021 12:36:57 -0500 Received: from linux.microsoft.com ([13.77.154.182]:58292 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388250AbhAURfv (ORCPT ); Thu, 21 Jan 2021 12:35:51 -0500 Received: from sequoia (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id 42F1420B7192; Thu, 21 Jan 2021 09:35:07 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 42F1420B7192 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1611250508; bh=a4cCNjrAKs4+vz3aERM9jzdT7vtf1mGZiPbZ15KjmZ0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mv27Noc+Ifs08rNXx4cDHhfoP90JPBkoo09HeG1CZZO8jknWGmb7GgjeaTSl0oYOi v3HioJmVc+b9IQ2c0zBLrpNuOpnG7lpfrEvvg3Jd1Mcmqnm8GrbZme1tiLNFkjyhp4 jqvT18W+uz0o+3+iGcx6H049pKv3IpwIO+7B5P8A= Date: Thu, 21 Jan 2021 11:35:05 -0600 From: Tyler Hicks To: Lakshmi Ramasubramanian Cc: zohar@linux.ibm.com, bauerman@linux.ibm.com, dmitry.kasatkin@gmail.com, ebiederm@xmission.com, gregkh@linuxfoundation.org, sashal@kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: Re: [PATCH 1/2] ima: Free IMA measurement buffer on error Message-ID: <20210121173505.GE259508@sequoia> References: <20210121173003.18324-1-nramas@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210121173003.18324-1-nramas@linux.microsoft.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-01-21 09:30:02, Lakshmi Ramasubramanian wrote: > IMA allocates kernel virtual memory to carry forward the measurement > list, from the current kernel to the next kernel on kexec system call, > in ima_add_kexec_buffer() function. In error code paths this memory > is not freed resulting in memory leak. > > Free the memory allocated for the IMA measurement list in > the error code paths in ima_add_kexec_buffer() function. > > Signed-off-by: Lakshmi Ramasubramanian > Suggested-by: Tyler Hicks > Fixes: 7b8589cc29e7 ("ima: on soft reboot, save the measurement list") Reviewed-by: Tyler Hicks Tyler > --- > security/integrity/ima/ima_kexec.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c > index 121de3e04af2..212145008a01 100644 > --- a/security/integrity/ima/ima_kexec.c > +++ b/security/integrity/ima/ima_kexec.c > @@ -119,12 +119,14 @@ void ima_add_kexec_buffer(struct kimage *image) > ret = kexec_add_buffer(&kbuf); > if (ret) { > pr_err("Error passing over kexec measurement buffer.\n"); > + vfree(kexec_buffer); > return; > } > > ret = arch_ima_add_kexec_buffer(image, kbuf.mem, kexec_segment_size); > if (ret) { > pr_err("Error passing over kexec measurement buffer.\n"); > + vfree(kexec_buffer); > return; > } > > -- > 2.30.0 >