From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758080AbbJVSun (ORCPT ); Thu, 22 Oct 2015 14:50:43 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:34384 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965394AbbJVStx (ORCPT ); Thu, 22 Oct 2015 14:49:53 -0400 From: Dmitry Kasatkin X-Google-Original-From: Dmitry Kasatkin To: zohar@linux.vnet.ibm.com, linux-ima-devel@lists.sourceforge.net, linux-security-module@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Dmitry Kasatkin Subject: [PATCHv3 5/6] evm: define EVM key max and min sizes Date: Thu, 22 Oct 2015 21:49:29 +0300 Message-Id: <1b40fd8bce820ff9d4f5552236bc159af9dbc0f9.1445539084.git.dmitry.kasatkin@huawei.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch imposes minimum key size limit. It declares EVM_MIN_KEY_SIZE and EVM_MAX_KEY_SIZE in public header file. Signed-off-by: Dmitry Kasatkin --- include/linux/evm.h | 3 +++ security/integrity/evm/evm_crypto.c | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/linux/evm.h b/include/linux/evm.h index 35ed9a8..0aeedec 100644 --- a/include/linux/evm.h +++ b/include/linux/evm.h @@ -11,6 +11,9 @@ #include #include +#define EVM_MAX_KEY_SIZE 128 +#define EVM_MIN_KEY_SIZE 64 + struct integrity_iint_cache; #ifdef CONFIG_EVM diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c index 7aec93e..cfb788c 100644 --- a/security/integrity/evm/evm_crypto.c +++ b/security/integrity/evm/evm_crypto.c @@ -24,9 +24,8 @@ #include "evm.h" #define EVMKEY "evm-key" -#define MAX_KEY_SIZE 128 -static unsigned char evmkey[MAX_KEY_SIZE]; -static int evmkey_len = MAX_KEY_SIZE; +static unsigned char evmkey[EVM_MAX_KEY_SIZE]; +static int evmkey_len = EVM_MAX_KEY_SIZE; struct crypto_shash *hmac_tfm; struct crypto_shash *hash_tfm; @@ -54,7 +53,7 @@ int evm_set_key(void *key, size_t keylen) if (test_and_set_bit(EVM_SET_KEY_BUSY, &evm_set_key_flags)) goto busy; rc = -EINVAL; - if (keylen > MAX_KEY_SIZE) + if (keylen < EVM_MIN_KEY_SIZE || keylen > EVM_MAX_KEY_SIZE) goto inval; memcpy(evmkey, key, keylen); evm_initialized |= EVM_INIT_HMAC; -- 2.1.4