From patchwork Tue Nov 3 20:35:14 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: 317122 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=-9.8 required=3.0 tests=BAYES_00,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=ham 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 6AB43C388F7 for ; Tue, 3 Nov 2020 21:01:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3BB5F21534 for ; Tue, 3 Nov 2020 21:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437313; bh=brxivmLHVOFcB6yKo4u1DCUMFD26aDKAZUrTEAKqghU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=AWIrHi0XS04alzVzZacDGr1f0qUa9yVE0iPEXfpcJSVl4WPqcjGOSMQDgZJ+pUPlh UPPqdN4018alwxXKZWVoBAMyUh14Da9s082c3NYE1sVev3vwGYgdHARMF32kReei/D t9gfVlrkNQFcfP4O9wOw4A4dhcIjl9Wh7NogLE+s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387532AbgKCVBv (ORCPT ); Tue, 3 Nov 2020 16:01:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:38622 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387501AbgKCVBu (ORCPT ); Tue, 3 Nov 2020 16:01:50 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 8EE2D20658; Tue, 3 Nov 2020 21:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604437310; bh=brxivmLHVOFcB6yKo4u1DCUMFD26aDKAZUrTEAKqghU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MEUprXKGYdDRC3/mn0AeU2LLJD3/ORFRRjXaLOPoZqcL35RiiVE23jsNnpPgCjZdT PomdAIXfVzB0d40BLlJcSXZzwNym5ZmAmvyhEojR5/cp9/Q5fbwVZU8wzW7qmo4TzE timjAkbRjMG157i3Mw0EwlY6qa34XcrK59VT9hCY= 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 022/191] evm: Check size of security.evm before using it Date: Tue, 3 Nov 2020 21:35:14 +0100 Message-Id: <20201103203235.556322057@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201103203232.656475008@linuxfoundation.org> References: <20201103203232.656475008@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Roberto Sassu commit 455b6c9112eff8d249e32ba165742085678a80a4 upstream. This patch checks the size for the EVM_IMA_XATTR_DIGSIG and EVM_XATTR_PORTABLE_DIGSIG types to ensure that the algorithm is read from the buffer returned by vfs_getxattr_alloc(). Cc: stable@vger.kernel.org # 4.19.x Fixes: 5feeb61183dde ("evm: Allow non-SHA1 digital signatures") Signed-off-by: Roberto Sassu Signed-off-by: Mimi Zohar Signed-off-by: Greg Kroah-Hartman --- security/integrity/evm/evm_main.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/security/integrity/evm/evm_main.c +++ b/security/integrity/evm/evm_main.c @@ -186,6 +186,12 @@ static enum integrity_status evm_verify_ break; case EVM_IMA_XATTR_DIGSIG: case EVM_XATTR_PORTABLE_DIGSIG: + /* accept xattr with non-empty signature field */ + if (xattr_len <= sizeof(struct signature_v2_hdr)) { + evm_status = INTEGRITY_FAIL; + goto out; + } + hdr = (struct signature_v2_hdr *)xattr_data; digest.hdr.algo = hdr->hash_algo; rc = evm_calc_hash(dentry, xattr_name, xattr_value,