Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp395536pxb; Thu, 21 Jan 2021 09:33:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzBItC7HPHYn1mWVEL3R8xNvUes+5ZbxLCd/E5ovLmrvzhKM6JtPxivHxIBEaosBzdn3O2Q X-Received: by 2002:a50:8741:: with SMTP id 1mr155485edv.349.1611250399196; Thu, 21 Jan 2021 09:33:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611250399; cv=none; d=google.com; s=arc-20160816; b=j9piHInxFa/S2GHTwfAv60I6u8Zf1t6zpRTkaNXDU+EvblC2CxMe9vJqkFfYtIK1aF JAQpUrzAI9kwj7DnuFtA5DicfUWSC3rF5tuLAfFl+8x9g1NrsH3s+iGyr7Qa6DC/zIH9 d4iMDvQ2g81EuVe02Nhhl6zpkQkxFGBMb/SrQxORlVk/KLpmLY9PLvlEyZoP+2To9JTz TT14bVHFdjdWiDelptr4GUk9WzruWYYdCPG7Jcdo4HzxI+1LAhI0LRq/9TirqY2+Nk3F +GzbCDjzEuPRx9bLJ5r5NksQqgvlMI0ornlwjUC6AB4eQVEw57stm5nY3PKr14svRkGe ei3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature:dkim-filter; bh=YiTmzmg5J73novUtm6vEd4VPk53XO64N4ccc6961PuA=; b=jg105g6k3Nn8cbOjgtwg+aPLH2LrhwsozmxqZGEVPJzE8qcqWz4MFq3PBSw7z3m0Qk QP/bFrKJQW3Mn8exj9EHkFB+ITV40V6iUmKBadLO1IcntbLVOlGDyVNl0C8rjU2BEuoH pyY+PAKJuRANP5X3TeltXbmNiWsxuoYk8Qs98b4VYGmJXgSlB4UGqb+uxzF8ZYG5JnTi zpGvOMpzWx6dHEeUY2UxzZC6mVVgih0pC4C5l3qlTdZOmdU3VT4gnu880oXUfCkLMdoP OQSC0W+VO6jy/wQNe47B71hwa6e5PYkYaBTPOrOCHNc1KOcL42ZpMH++iilYMNQ8yao6 JUvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b="ei/uUMtO"; 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 h4si2354312edd.105.2021.01.21.09.32.51; Thu, 21 Jan 2021 09:33:19 -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="ei/uUMtO"; 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 S1731734AbhAURbJ (ORCPT + 99 others); Thu, 21 Jan 2021 12:31:09 -0500 Received: from linux.microsoft.com ([13.77.154.182]:57634 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388526AbhAURat (ORCPT ); Thu, 21 Jan 2021 12:30:49 -0500 Received: from localhost.localdomain (c-73-42-176-67.hsd1.wa.comcast.net [73.42.176.67]) by linux.microsoft.com (Postfix) with ESMTPSA id AB70B20B7192; Thu, 21 Jan 2021 09:30:08 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com AB70B20B7192 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1611250208; bh=YiTmzmg5J73novUtm6vEd4VPk53XO64N4ccc6961PuA=; h=From:To:Cc:Subject:Date:From; b=ei/uUMtO1yzKPHNhK4bGp7mmR5GayhbwKrS3EaQbHeXn60i6nEtntPd7qCfgf2cdf pgwGNK3FoG1agO97qcOj4fU3AF9pbBG0E5h2BxOmGKSa9UVTaO22SVQv8T4uCfmWo5 rR2i6wJylWw54R2/jOZYCiHov1HvoIsBhM8ymxEU= From: Lakshmi Ramasubramanian To: zohar@linux.ibm.com, bauerman@linux.ibm.com, dmitry.kasatkin@gmail.com, ebiederm@xmission.com, gregkh@linuxfoundation.org, sashal@kernel.org, tyhicks@linux.microsoft.com Cc: linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Subject: [PATCH 1/2] ima: Free IMA measurement buffer on error Date: Thu, 21 Jan 2021 09:30:02 -0800 Message-Id: <20210121173003.18324-1-nramas@linux.microsoft.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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") --- 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