Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp374834pxy; Wed, 5 May 2021 04:31:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw5Zo/CI0utt+0NXpFdKQV/cqvpLVCP74K38BbxDy+/TY+29dRMpgeoCop5WagACdPd7+ox X-Received: by 2002:a62:2a14:0:b029:263:20c5:6d8c with SMTP id q20-20020a622a140000b029026320c56d8cmr28667399pfq.23.1620214289820; Wed, 05 May 2021 04:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620214289; cv=none; d=google.com; s=arc-20160816; b=HYJ8+mNbefQnt5lnTgh2XKm5YULT9Eh5FM2BYQ9w8CxgGWKzBP3JATTxltfDZYzaNz n3gvZAdh3hzhgOqqIzOSQnKh3O5JwOaCCqmstRCbFAU3x6QBeJvlrR5svw+TMJHoyW8V x+vdkjTpzJzjAZ9A3Eat/dhkO1VqF67nPS8/RiR+eUe39WYpf7fClHb49++KcwDECueD WoPs6WBKtq7ZcbofHaO8dFcivzwZGvpRaqyjHPj3EWpNbeLeAmxPRJROxSMXNwelvFYH P2V0q0lYLtmyd3wbHlrHZNPz7gcEqznDB6vTjOtl0pCUGlwJ1r47UNwXcDTZR/E9+vdR IP9A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=EbgCxJFpjErsoMqzxjlEw/j3ZUxjhugE4/yf+gsAChk=; b=OS20S5cGNlUozx4Mha2IExeiBik95vBDduSu51dnX1uouwYeyueaGPDG510GymuS/v w7ege3oSQxdjRcYyOqNqx1dPQ/R/udSceinaznxbNaLo1jkWpmKUxBs3TT9Mp3xVNIZC KQXWsTYAzFwJlicQef2Li5dv4rZ/755D0F4XP3Nj9RuQ6MS8dxHvS1orcOmLH0YesOgr mYxnOU/74gTBdnd8w2/88Af23iwLFlD68SF5sgpkrgEacv1A3a/bzi4qZwPCQZUPDjCd L0TQKtkIyDw7Fxlpqmt8TEZGjWO7FO0fU6QGaO4pHQmSgXAgwzWGciobbh1N2TwTK7p9 r1RQ== ARC-Authentication-Results: i=1; mx.google.com; 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=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y4si6974692plt.220.2021.05.05.04.31.17; Wed, 05 May 2021 04:31:29 -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; 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=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233044AbhEELbL (ORCPT + 99 others); Wed, 5 May 2021 07:31:11 -0400 Received: from frasgout.his.huawei.com ([185.176.79.56]:3006 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232967AbhEELbB (ORCPT ); Wed, 5 May 2021 07:31:01 -0400 Received: from fraeml714-chm.china.huawei.com (unknown [172.18.147.207]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4FZvVl3R3hz6yjBC; Wed, 5 May 2021 19:24:15 +0800 (CST) Received: from roberto-ThinkStation-P620.huawei.com (10.204.62.217) by fraeml714-chm.china.huawei.com (10.206.15.33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Wed, 5 May 2021 13:30:03 +0200 From: Roberto Sassu To: , CC: , , , Roberto Sassu , Subject: [PATCH v6 03/11] evm: Refuse EVM_ALLOW_METADATA_WRITES only if an HMAC key is loaded Date: Wed, 5 May 2021 13:29:27 +0200 Message-ID: <20210505112935.1410679-4-roberto.sassu@huawei.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210505112935.1410679-1-roberto.sassu@huawei.com> References: <20210505112935.1410679-1-roberto.sassu@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.204.62.217] X-ClientProxiedBy: lhreml752-chm.china.huawei.com (10.201.108.202) To fraeml714-chm.china.huawei.com (10.206.15.33) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org EVM_ALLOW_METADATA_WRITES is an EVM initialization flag that can be set to temporarily disable metadata verification until all xattrs/attrs necessary to verify an EVM portable signature are copied to the file. This flag is cleared when EVM is initialized with an HMAC key, to avoid that the HMAC is calculated on unverified xattrs/attrs. Currently EVM unnecessarily denies setting this flag if EVM is initialized with a public key, which is not a concern as it cannot be used to trust xattrs/attrs updates. This patch removes this limitation. Cc: stable@vger.kernel.org # 4.16.x Fixes: ae1ba1676b88e ("EVM: Allow userland to permit modification of EVM-protected metadata") Signed-off-by: Roberto Sassu --- Documentation/ABI/testing/evm | 5 +++-- security/integrity/evm/evm_secfs.c | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Documentation/ABI/testing/evm b/Documentation/ABI/testing/evm index 3c477ba48a31..eb6d70fd6fa2 100644 --- a/Documentation/ABI/testing/evm +++ b/Documentation/ABI/testing/evm @@ -49,8 +49,9 @@ Description: modification of EVM-protected metadata and disable all further modification of policy - Note that once a key has been loaded, it will no longer be - possible to enable metadata modification. + Note that once an HMAC key has been loaded, it will no longer + be possible to enable metadata modification and, if it is + already enabled, it will be disabled. Until key loading has been signaled EVM can not create or validate the 'security.evm' xattr, but returns diff --git a/security/integrity/evm/evm_secfs.c b/security/integrity/evm/evm_secfs.c index bbc85637e18b..860c48b9a0c3 100644 --- a/security/integrity/evm/evm_secfs.c +++ b/security/integrity/evm/evm_secfs.c @@ -81,11 +81,10 @@ static ssize_t evm_write_key(struct file *file, const char __user *buf, return -EINVAL; /* Don't allow a request to freshly enable metadata writes if - * keys are loaded. + * an HMAC key is loaded. */ if ((i & EVM_ALLOW_METADATA_WRITES) && - ((evm_initialized & EVM_KEY_MASK) != 0) && - !(evm_initialized & EVM_ALLOW_METADATA_WRITES)) + (evm_initialized & EVM_INIT_HMAC) != 0) return -EPERM; if (i & EVM_INIT_HMAC) { -- 2.25.1