From patchwork Fri Jun 19 14:33:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 223816 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38188C433E2 for ; Fri, 19 Jun 2020 16:20:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0CFAB2168B for ; Fri, 19 Jun 2020 16:20:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592583620; bh=nhdA2eKYfMl7sV28TAxAvdtbNIZX1h14G52W58rGGUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=I+vP7Vtsr/4TbZSaclc43ib0FEHPbkyIFWupjkHBunlI0ePOLuhh8zQZK/nGVTmUR XTdjlyd0sN6Jw2jAU5wRLTVj1YHhWNi1/IpB3zOxj8BdpfggEId0AdkX0MyTy6lHBd wog3uJVf5ZtiIlMC6X2ATqv6LmlufsDRIixvTP2Q= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390719AbgFSPBd (ORCPT ); Fri, 19 Jun 2020 11:01:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:57876 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390710AbgFSPB1 (ORCPT ); Fri, 19 Jun 2020 11:01:27 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B4AFE206DB; Fri, 19 Jun 2020 15:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1592578887; bh=nhdA2eKYfMl7sV28TAxAvdtbNIZX1h14G52W58rGGUc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yq/9foRv1tEC82VFHB7xXZn4yV6lmZ4C6iZNpLLoFNOpWGkbI+RafUiJe9aB0bdPV RczKP6tK4HLuWbGyMP0Mhfz02eAcnkqCt5MHgylY2ORiMyDq8x5ENbUAVabXbqSevI bqDzqcS/LnWn4E8P/7SBOA3CTd14G2hMjAy/61mM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roberto Sassu , Mimi Zohar Subject: [PATCH 4.19 195/267] evm: Fix possible memory leak in evm_calc_hmac_or_hash() Date: Fri, 19 Jun 2020 16:33:00 +0200 Message-Id: <20200619141658.107810737@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619141648.840376470@linuxfoundation.org> References: <20200619141648.840376470@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Roberto Sassu commit 0c4395fb2aa77341269ea619c5419ea48171883f upstream. Don't immediately return if the signature is portable and security.ima is not present. Just set error so that memory allocated is freed before returning from evm_calc_hmac_or_hash(). Fixes: 50b977481fce9 ("EVM: Add support for portable signature format") Signed-off-by: Roberto Sassu Cc: stable@vger.kernel.org Signed-off-by: Mimi Zohar Signed-off-by: Greg Kroah-Hartman --- security/integrity/evm/evm_crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/security/integrity/evm/evm_crypto.c +++ b/security/integrity/evm/evm_crypto.c @@ -249,7 +249,7 @@ static int evm_calc_hmac_or_hash(struct /* Portable EVM signatures must include an IMA hash */ if (type == EVM_XATTR_PORTABLE_DIGSIG && !ima_present) - return -EPERM; + error = -EPERM; out: kfree(xattr_value); kfree(desc);