From patchwork Sat Oct 31 11:36:42 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: 317386 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=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 D1F00C4742C for ; Sat, 31 Oct 2020 11:46:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9BEF520731 for ; Sat, 31 Oct 2020 11:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144809; bh=Dmx4856aMDF3NR3IzuQtcn7Pcfi9Y6BrCatuOiMQszA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RyyTwAV0XKwxdL+YBdXPXD/pdxq7STNe0g6QhMk2QHh93uPiF1DX+QyDO4FDY7KSS WKr/Ayu6vJajyo/9Bq105WnaQneBoJXkirSfXJARtHoy+Pa7CVZPryNgENBwnxfTqZ h4oiucmw74kVPYnEyO28PKmBZkpKH20UMh2gkfwU= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727730AbgJaLqn (ORCPT ); Sat, 31 Oct 2020 07:46:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:47642 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbgJaLqV (ORCPT ); Sat, 31 Oct 2020 07:46:21 -0400 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 02E19205F4; Sat, 31 Oct 2020 11:46:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144781; bh=Dmx4856aMDF3NR3IzuQtcn7Pcfi9Y6BrCatuOiMQszA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bL2VCSKQxoAa66nj39vTh3ZWywTYsW+Rsc3NWQr18bvPn6sLiNBTla902+hKgV1sr wk5AvylvpBuFRMfai+uNI0aj00r0THOb3zXl1XAGpe1wm17PUMw9JStEACgcW2bN2u jHd9BqMgc3c+3j/gesti5UYbpMI2qxLVk9NVOkuM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roberto Sassu , Mimi Zohar Subject: [PATCH 5.9 60/74] evm: Check size of security.evm before using it Date: Sat, 31 Oct 2020 12:36:42 +0100 Message-Id: <20201031113502.906844030@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113500.031279088@linuxfoundation.org> References: <20201031113500.031279088@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 @@ -181,6 +181,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,