Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3529987pxb; Mon, 1 Mar 2021 12:26:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJwK9ohrEGFzNDUo78LTcE0SD3KZ9uLqje9iSX61oyRYe/PvgUwHz56h/SaWNOkzJ6TYchNq X-Received: by 2002:a17:906:4705:: with SMTP id y5mr7830392ejq.119.1614630360735; Mon, 01 Mar 2021 12:26:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614630360; cv=none; d=google.com; s=arc-20160816; b=nhnEE3fr0I0bHUcKJkusAW11UITRGMHQLrXXnsMnKpg6V9bjfrq4tW5XnqRDAdeOKe Zj7qyGUvCujllQ54EdGbZhvlny+ZLyreD0j5YCgwy3cCZsH8swF9LzeEmhA3Dfod6FN0 sxQvf0rn6RFBGxUDrHMDTVW9iWsjtTElyQnEc2Zrq1WQXBbBe+Pd6Ub0a2kOFHK+ZdTp YbcWl+9qReLvhYGn/CupWiJTRZuZSTpoKfvhrW69ZrDI8VWAAESGh4d47ArYupDotVRO u3Aq+5xTgTJQetaAlqi5ruUc4eK/rWHopVVLQsWembD+iZ7Dglh9PNlhjFf5xpbHf2iA Edwg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yq7DILTiJ3zZCdoAq7rEC/rluWzrBoPLPRSsJNy6enQ=; b=PUaLoOlnRJu/FT2kXAofAL+zKwyvDfvXxoSf11QOtjgyi+XTcxelKVCAdFX00Hx04w J3h8h0Q18qmA88dU5y2eH4SEo37uA1t5Jm9Ze/iZluN1OGSxJiQ0uohx+0go04kAbrid uq+PT6yNwpVnaorhma3QGJ/PcSWquaVmxRWnh6tliH0mtuHDLmR41jOI/Dhiw/KbkKNT 5/lbj0WOT9bVRk4R6zZDgNO7Y70GZNZSY6MBrYXAhNGBB6paXNr5YSYhC4Wqxn9xzDvt hbrw7t/1IyMXdvQlzae2EtCQIqO0J35S6mxAyFjz+3pX7VJKvLSn2OOQoq0bk7LFPwhx AnzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nINskIfF; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si11487719edq.523.2021.03.01.12.25.38; Mon, 01 Mar 2021 12:26:00 -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=@linuxfoundation.org header.s=korg header.b=nINskIfF; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243314AbhCAUXx (ORCPT + 99 others); Mon, 1 Mar 2021 15:23:53 -0500 Received: from mail.kernel.org ([198.145.29.99]:35192 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237020AbhCARGg (ORCPT ); Mon, 1 Mar 2021 12:06:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BFE8E65001; Mon, 1 Mar 2021 16:40:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616807; bh=gOMefC9T8pVJlqTguISPF0XBCCHhjCx9ZBsQCrvLtzA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nINskIfFvXBSwG469vDt4R2GXNBUJZymX9i33aNULm7Sj/uoafbo+RnvSAlnyDtmO cIgwz7EhYuGGg+lCTko1XyajPEGSH1WamLNCokG+tefahvDTo8cPrScIZnJcYJ6dRU 1aUTWXQf+hOevF1YbH7kzN4UPkNNOz19+fudcMZs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lakshmi Ramasubramanian , Tyler Hicks , Mimi Zohar , Sasha Levin Subject: [PATCH 4.19 103/247] ima: Free IMA measurement buffer on error Date: Mon, 1 Mar 2021 17:12:03 +0100 Message-Id: <20210301161036.713777144@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lakshmi Ramasubramanian [ Upstream commit 6d14c6517885fa68524238787420511b87d671df ] 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") Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- security/integrity/ima/ima_kexec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c index 16bd18747cfa0..9f8449dea5b69 100644 --- a/security/integrity/ima/ima_kexec.c +++ b/security/integrity/ima/ima_kexec.c @@ -124,6 +124,7 @@ 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; } -- 2.27.0