Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1984566pxx; Sat, 31 Oct 2020 04:51:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhV0Ght6dYDz8E/XEczWIF6KBp2rE0TmSBuaEWjlX+6sNUuhXPLrfs88+kIwCGqGUg5Nbe X-Received: by 2002:a50:85c6:: with SMTP id q6mr7466508edh.126.1604145081496; Sat, 31 Oct 2020 04:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604145081; cv=none; d=google.com; s=arc-20160816; b=MkM6eCVJtRmifty201UKqyeSLybT7ClWqSMLpC3FiWJRuHhVJk8/KN+MDIS521IteI m35XzLOteZCEwwg8A3WWuj746vBWRTNeZgB5b8Sad0kaJmM9T2VBnb5zn2g9IyF+FnOo jnTiyEn3qHtAwYzZct8cDUM+eZk3+QS/5pb543Q24ycP96ng+JscXbBiNMoUidkj/hWu AggpClNQduI3UGn4ghiF/qqWQI3Fw+2C5s2u5dOAwllmUJ3uwspXTnxnaKp1pKLFcg7L GYtg3BVNiODZ3KK5SggFc+XJmkPbulNx84AWhPXvH+LB0/taFUHA4OBgUTbjgvb48dPW 75tg== 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=Xes0f0BGN4kHG52to5mizVgA+0PshKhfi3x6FG89Loo=; b=WWmh4t0qBaDElGwBlKEfKx09RajCXhWWjEjTlmzM9vik7bgBodwczFofw+99sHYdPU cnsbDJwOiXch7grV49ofiJtDnA1lfCpB0nzbiB26iylekISPYZJVIHoXUpstyaFQ27zC bhSs0IZJMldtK3ka9D/phkEcnkRtvrdEF0DvkDqBPlqPpy8vhTHamOPGVNczhIgutcjl LvRS7JBuj1kkglGkTWNKKhFrFMfkOViRoTSdaYm5jTFlbTYrIsHe2L4kyzVSG1y6ET/i EDDq68SSjf5QEgHlZujOPNRvUz28IylkjUNA8VqWa1mKYTHDonMgv0LfbncYokB22kaA 906g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XQdqR/Qg"; 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=fail (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 w5si2959810eju.299.2020.10.31.04.50.59; Sat, 31 Oct 2020 04:51:21 -0700 (PDT) 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=@kernel.org header.s=default header.b="XQdqR/Qg"; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727965AbgJaLtO (ORCPT + 99 others); Sat, 31 Oct 2020 07:49:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:42912 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727150AbgJaLnF (ORCPT ); Sat, 31 Oct 2020 07:43:05 -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 C5BAA205F4; Sat, 31 Oct 2020 11:43:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144585; bh=Dmx4856aMDF3NR3IzuQtcn7Pcfi9Y6BrCatuOiMQszA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XQdqR/Qg0OBAEFH1kTKYR/sl9A/38w1binMbBXHuPftmxujv0/fLiMXHQnuM2pkgS tbZ7XsdufPgahijTmhWFATV+YGcdJqqKGeJBE2M2NKq05bR/vh1pWtrMK0hjysfghG Bwe/38dSaVWpHR/liP560Nc2RVthzSiErGUz80Io= 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.8 57/70] evm: Check size of security.evm before using it Date: Sat, 31 Oct 2020 12:36:29 +0100 Message-Id: <20201031113502.229354143@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113459.481803250@linuxfoundation.org> References: <20201031113459.481803250@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: 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,