Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2038457imm; Thu, 27 Sep 2018 06:32:31 -0700 (PDT) X-Google-Smtp-Source: ACcGV62QhYi4nvGHydLTcxafeYkcKFe0dwMvPBCuyBKIijJ/WxcUnfduCFicYtFMzftXuBPags8e X-Received: by 2002:a62:18a:: with SMTP id 132-v6mr11645699pfb.207.1538055151119; Thu, 27 Sep 2018 06:32:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538055151; cv=none; d=google.com; s=arc-20160816; b=qbpFaSDuSdtUkTMhxqWv4E/2SYFGcVXIrvkTUINgO3QkgW+bgKcRQUlxGyawgAcIkd dCqHxGs22OZp03A3xWr3NprGn3wUOKLjf21dgL8wSawLEhATCvBlaj5j6ZbmTJDCXG+L em5EHemG4p1NByHkQQF5T+KoYIaWKzhfkXNhbXIrpRhNT2c1G0KUWfnOu3QMFeEl5Iei g7j0IOBtQpnWUq4AGkgt/SYSpMRYvLwygCKGKlPEYCAtZxnw392GG2fYjXxr9wtEgByk G98zko4YlFpDukxx3NCVxRzrb3eod+tQidOHMCCMZocQqBlYozHyGgdWPCn8pVmRsKnh J3VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-transfer-encoding :mime-version:references:in-reply-to:date:cc:to:from:subject; bh=TSXtU9W6y/mcoZo35z3gn44P+np6myEq5CL7+wZcpEk=; b=hRgitmD+KlY4bR3Pj3IQFNSuzDqh5Shl1jnbkl8g9F1j4IKuokrB2DDsDaJJWFNdQy FimQsk9HK/5ArQO/h1QaokD9tTL7Co6KGnvVML2LkDPdFreFbgp05ARLAX7mzdKjxIQc 4bNlTNZ9pParQxfPQamq8JiX3Z2qEf2g+Lg5FO7DzcN4T9MPHEj2M5J328PD1MId70ep xBnz8XxzUoymUlZKRNODjxm2mBXp2WBSmTX0h/Q2IZhSdxw+tN8/RMsk+vDOTVaqYeAR RmlaSGo5cuU3jXyVk02vLKDLnn51Xb9pJWnlYul0Ekjt2yyiqi/Eqo0Va3qf7NQuxFX0 lsEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r2-v6si1997520pgk.452.2018.09.27.06.32.12; Thu, 27 Sep 2018 06:32:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727330AbeI0TuT (ORCPT + 99 others); Thu, 27 Sep 2018 15:50:19 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:49628 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727199AbeI0TuS (ORCPT ); Thu, 27 Sep 2018 15:50:18 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8RDOlrW068175 for ; Thu, 27 Sep 2018 09:32:00 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mrxt7mjgf-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 27 Sep 2018 09:32:00 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Sep 2018 14:31:57 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp04.uk.ibm.com (192.168.101.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 27 Sep 2018 14:31:55 +0100 Received: from d06av24.portsmouth.uk.ibm.com (mk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8RDVsnJ1311158 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 27 Sep 2018 13:31:54 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E5D942041; Thu, 27 Sep 2018 16:31:38 +0100 (BST) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DAC5942045; Thu, 27 Sep 2018 16:31:36 +0100 (BST) Received: from localhost.localdomain (unknown [9.80.85.160]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 27 Sep 2018 16:31:36 +0100 (BST) Subject: Re: [PATCH v4 6/6] x86/ima: define arch_get_ima_policy() for x86 From: Mimi Zohar To: Nayna Jain , linux-integrity@vger.kernel.org Cc: linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, jforbes@redhat.com, Eric Richter Date: Thu, 27 Sep 2018 09:31:42 -0400 In-Reply-To: <20180926122210.14642-7-nayna@linux.vnet.ibm.com> References: <20180926122210.14642-1-nayna@linux.vnet.ibm.com> <20180926122210.14642-7-nayna@linux.vnet.ibm.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.20.5 (3.20.5-1.fc24) Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 x-cbid: 18092713-0016-0000-0000-0000020B5857 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18092713-0017-0000-0000-000032627EA7 Message-Id: <1538055102.3459.112.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-27_07:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809270132 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Eric, Nayna, On Wed, 2018-09-26 at 17:52 +0530, Nayna Jain wrote: > From: Eric Richter > This patch implements an example arch-specific IMA policy for x86 to > enable measurement and appraisal of any kernel image loaded for kexec, > when CONFIG_KEXEC_VERIFY_SIG is not enabled. > > For systems with CONFIG_KEXEC_VERIFY_SIG enabled, only the measurement > rule is enabled, not the IMA-appraisal rule. The patch itself looks good, but this patch description explains "what" the patch is doing, not "why".  Missing is the motivation for the patch. Mimi > > Signed-off-by: Eric Richter > - Removed the policy KEXEC_ORIG_KERNEL_CHECK which was defined to > disable the kexec_load syscall. > - arch_get_ima_policy() uses arch_ima_get_secureboot() to get secureboot > state > Signed-off-by: Nayna Jain > --- > arch/x86/kernel/ima_arch.c | 18 ++++++++++++++++++ > include/linux/ima.h | 4 ++++ > security/integrity/ima/Kconfig | 8 ++++++++ > 3 files changed, 30 insertions(+) > > diff --git a/arch/x86/kernel/ima_arch.c b/arch/x86/kernel/ima_arch.c > index bb5a88d2b271..245976e49a55 100644 > --- a/arch/x86/kernel/ima_arch.c > +++ b/arch/x86/kernel/ima_arch.c > @@ -15,3 +15,21 @@ bool arch_ima_get_secureboot(void) > else > return false; > } > + > +/* arch rules for audit and user mode */ > +static const char * const sb_arch_rules[] = { > +#ifndef CONFIG_KEXEC_VERIFY_SIG > + "appraise func=KEXEC_KERNEL_CHECK appraise_type=imasig", > +#endif /* CONFIG_KEXEC_VERIFY_SIG */ > + "measure func=KEXEC_KERNEL_CHECK", > + NULL > +}; > + > +#ifdef CONFIG_IMA_ARCH_POLICY > +const char * const *arch_get_ima_policy(void) > +{ > + if (arch_ima_get_secureboot()) > + return sb_arch_rules; > + return NULL; > +} > +#endif > diff --git a/include/linux/ima.h b/include/linux/ima.h > index 350fa957f8a6..dabd3abdf671 100644 > --- a/include/linux/ima.h > +++ b/include/linux/ima.h > @@ -39,10 +39,14 @@ static inline bool arch_ima_get_secureboot(void) > } > #endif > > +#if defined(CONFIG_X86) && defined(CONFIG_IMA_ARCH_POLICY) > +extern const char * const *arch_get_ima_policy(void); > +#else > static inline const char * const *arch_get_ima_policy(void) > { > return NULL; > } > +#endif > > #else > static inline int ima_bprm_check(struct linux_binprm *bprm) > diff --git a/security/integrity/ima/Kconfig b/security/integrity/ima/Kconfig > index 13b446328dda..97609a76aa14 100644 > --- a/security/integrity/ima/Kconfig > +++ b/security/integrity/ima/Kconfig > @@ -157,6 +157,14 @@ config IMA_APPRAISE > > If unsure, say N. > > +config IMA_ARCH_POLICY > + bool "Enable loading an IMA architecture specific policy" > + depends on KEXEC_VERIFY_SIG || IMA_APPRAISE && INTEGRITY_ASYMMETRIC_KEYS > + default n > + help > + This option enables loading an IMA architecture specific policy > + based on run time secure boot flags. > + > config IMA_APPRAISE_BUILD_POLICY > bool "IMA build time configured policy rules" > depends on IMA_APPRAISE && INTEGRITY_ASYMMETRIC_KEYS