Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4452768imw; Tue, 19 Jul 2022 06:56:41 -0700 (PDT) X-Google-Smtp-Source: AGRyM1upO6HL9+RTSo2xNmUhi4Xsc0Za2nUkO4DxivvJKZE/S/rl3TCkIsZSCdn8UT65yqg1flL+ X-Received: by 2002:a05:6402:1c92:b0:43b:a336:2377 with SMTP id cy18-20020a0564021c9200b0043ba3362377mr1721421edb.15.1658239001746; Tue, 19 Jul 2022 06:56:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658239001; cv=none; d=google.com; s=arc-20160816; b=vKbEaIOcBF5MB+ObqayqA0mxf47aXQ4JHT4BkhqOLn+wJqd8tpZyVoVLkLFfoGM9yq vOVJs49VMOf95vfR7e2WEoqmDpdgkSAopz2mho6DqDTIQ8+H3MmhOF7it2fK7iXn/3Ec c9I6JTVWnIZm8rSlJX0Q4J8Nq3DLsG06GXchtQzSNgiSdrZGu6eUu6k7+S3LzqrI4yMz VYuZa91/Fg7Pbr2P5SPHo+IMdZF+bpeWW7TuiEDILtMjsaQRMkYapCWdVDaZpIgAs3EQ IAvm6qJvB1jUvxLlD4Jp8LplMUVlqhpu7im5kRJbpudPuPNC6uJTeY9AUJ6Wb41AWEeO RR4A== 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=YqFG2cWtdAdzaXojcfgoPwwi3dtJC2qoRryQ0NCLAvM=; b=gLZuLcVTKrbOvPR8OE0dQ5woLYYq0TezqmeTAIx6Loo2L9ssmFlABLHb9A5FcjZwQE lclqiMaM5H8503wGAVAnRC0SWallXv4hC7s7TKebQ1xWZ1hH7XvdgEh7syfurgW9LmYX 0UQX/5B1dDiNliVCDrflcWpTKzIQySF8QN1S9t6Ew7oprc+acSZo6C4ieyrEZdCLJdPj emjAuDxT8jRbO88u/ul7co+6kNnT0gv9UPzbdzcQh6YPEnu2IZlbSLKa3pDDPMleF2u4 73gIoEc6Fj8envYIzxE3N0LmXNMDYjWxKwAnRbMJRj/lDsjI+l/j/GopTp49JhpJNnNJ Ofxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tF1ZQkEA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w6-20020a056402268600b0043aad9460dfsi21179724edd.19.2022.07.19.06.56.16; Tue, 19 Jul 2022 06:56:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tF1ZQkEA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234465AbiGSMWh (ORCPT + 99 others); Tue, 19 Jul 2022 08:22:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237968AbiGSMWP (ORCPT ); Tue, 19 Jul 2022 08:22:15 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C24F5C376; Tue, 19 Jul 2022 05:08:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BC3C4B81B1A; Tue, 19 Jul 2022 12:07:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E902EC341C6; Tue, 19 Jul 2022 12:07:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232461; bh=UWyRdUbZ+4+sGFdCn0lE/K6GVaJrH++vlaoIujAs+NQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tF1ZQkEAe1UubSCOOw9VzxYF7j+OAjLc0RohMODG/6N6KYsIt46kp61e0UQRFMkHE OXtp63YTgDpl0M9/wjFkWTurLQByhlH7fXvpWZ+I3MRcQGsjmCjPRSAElD+ZKfNECN xlf8d0TRF3SiF/9S2YMLQ60pMW03l/e75DoOSZuo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jianglei Nie , Mimi Zohar , Sasha Levin Subject: [PATCH 5.10 066/112] ima: Fix potential memory leak in ima_init_crypto() Date: Tue, 19 Jul 2022 13:53:59 +0200 Message-Id: <20220719114632.864305701@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114626.156073229@linuxfoundation.org> References: <20220719114626.156073229@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jianglei Nie [ Upstream commit 067d2521874135267e681c19d42761c601d503d6 ] On failure to allocate the SHA1 tfm, IMA fails to initialize and exits without freeing the ima_algo_array. Add the missing kfree() for ima_algo_array to avoid the potential memory leak. Signed-off-by: Jianglei Nie Fixes: 6d94809af6b0 ("ima: Allocate and initialize tfm for each PCR bank") Signed-off-by: Mimi Zohar Signed-off-by: Sasha Levin --- security/integrity/ima/ima_crypto.c | 1 + 1 file changed, 1 insertion(+) diff --git a/security/integrity/ima/ima_crypto.c b/security/integrity/ima/ima_crypto.c index f6a7e9643b54..b1e5e7749e41 100644 --- a/security/integrity/ima/ima_crypto.c +++ b/security/integrity/ima/ima_crypto.c @@ -205,6 +205,7 @@ int __init ima_init_crypto(void) crypto_free_shash(ima_algo_array[i].tfm); } + kfree(ima_algo_array); out: crypto_free_shash(ima_shash_tfm); return rc; -- 2.35.1