Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp429384imm; Wed, 19 Sep 2018 00:58:45 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYqZXq7EHWqpukNj+05YARKmJczF2RGdU3TVxL9wmsl2SQlj6cdl18M9VxZnjS7GCK5mDFh X-Received: by 2002:a63:2106:: with SMTP id h6-v6mr30910951pgh.161.1537343925139; Wed, 19 Sep 2018 00:58:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537343925; cv=none; d=google.com; s=arc-20160816; b=I2ZR5+StaxdFSwXMdTpks9uC/lgzES+P49POwx1uKxyhYEHn4oMwtK7GAZVjc6HA3K RXrQYaXB7pxExeB7f35oR4AqH5qyZzOKV7UhXJk1t+/HZtKyTeC+HsvKMvVOnvcikfG+ OZpiw3kzHNzNB6TV/8z4SLVeTZdk4d46GXsDZS/TI4pz+QZBf4dm0efolQouO9UisvQA 3Snsm94se3TmhUXUT/ev0wVXescEQAT3Ojw3YHoiAnkkkk/o5En0/IbYLQpeCu+vHsZq ImChVkt3Rf7JOs/tcsvjz4b7MqWQ55TiMOaTK6IyEzB2yv9L3aJxryIcjbG42vwidd8u 96kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=PLiqxPl4xPUlR/Gv92Q/kQjiK3xXB6TbKaD3nGG6MXk=; b=QT/5nF1ACzxkJxp5WOj3yE/4pgUf8wc/TUlUHDXKhE7bgloZBcBLTHkjvnDAbSgBO3 k+hiyjOj9Fe4p07/MosGkl60X0w2Z5dejT9zMkM4uAPKc8kJz+ec6SvykwcGIzgOF1H6 mJ+pAwT5OZ1McAMFyZZivZOuQtT3BB2SKAA5LiQDYs/iqh6EAMrF626i7RxYL3i0mcDq 6FblJoYAdVbE56o6Pq7E0f5bI+EqwrNn4usa+g//amOMT291rsi2sOu5S0eZhQLGujaA v6dFNwnmBhN+cJv7PLPqZOx5B1n//vtZxq5ZXMbsXb+6VRKghjYIU24pqvkhlGKhmWfM yrcA== 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 g12-v6si19164596pgk.636.2018.09.19.00.58.28; Wed, 19 Sep 2018 00:58:45 -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 S1730938AbeISNfE (ORCPT + 99 others); Wed, 19 Sep 2018 09:35:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:40876 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730392AbeISNfE (ORCPT ); Wed, 19 Sep 2018 09:35:04 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8J7sDmA128578 for ; Wed, 19 Sep 2018 03:58:20 -0400 Received: from e06smtp04.uk.ibm.com (e06smtp04.uk.ibm.com [195.75.94.100]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mkgknmt3x-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Wed, 19 Sep 2018 03:58:19 -0400 Received: from localhost by e06smtp04.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 19 Sep 2018 08:58:17 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) 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) Wed, 19 Sep 2018 08:58:15 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w8J7wE5m62062836 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 19 Sep 2018 07:58:14 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5E001A4059; Wed, 19 Sep 2018 10:57:59 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F0531A4053; Wed, 19 Sep 2018 10:57:57 +0100 (BST) Received: from swastik.in.ibm.com (unknown [9.124.31.41]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 19 Sep 2018 10:57:57 +0100 (BST) From: Nayna Jain To: linux-integrity@vger.kernel.org Cc: zohar@linux.ibm.com, linux-security-module@vger.kernel.org, linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, dhowells@redhat.com, jforbes@redhat.com, Nayna Jain Subject: [PATCH v3 0/6] Add support for architecture specific IMA policies Date: Wed, 19 Sep 2018 13:25:16 +0530 X-Mailer: git-send-email 2.13.6 X-TM-AS-GCONF: 00 x-cbid: 18091907-0016-0000-0000-000002076623 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18091907-0017-0000-0000-0000325E52E6 Message-Id: <20180919075522.7684-1-nayna@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-19_03:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=842 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809190083 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The architecture specific policy, introduced in this patch set, permits different architectures to define IMA policy rules based on kernel configuration and system runtime information. For example, on x86, there are two methods of verifying the kexec'ed kernel image signature - CONFIG_KEXEC_VERIFY_SIG and IMA appraisal policy KEXEC_KERNEL_CHECK. CONFIG_KEXEC_VERIFY_SIG enforces the kexec_file_load syscall to verify file signatures, but does not prevent the kexec_load syscall. The IMA KEXEC_KERNEL_CHECK policy rule verifies the kexec'ed kernel image, loaded via the kexec_file_load syscall, is validly signed and prevents loading a kernel image via the kexec_load syscall. When secure boot is enabled, the kexec'ed kernel image needs to be signed and the signature verified. In this environment, either method of verifying the kexec'ed kernel image is acceptable, as long as the kexec_load syscall is disabled. The previous version of this patchset introduced a new IMA policy rule to disable the kexec_load syscall, when CONFIG_KEXEC_VERIFY_SIG was enabled, however that is removed from this version by introducing a different mechanism. The patchset defines an arch_ima_get_secureboot() function to retrieve the secureboot state of the system. If secureboot is enabled and CONFIG_KEXEC_VERIFY_SIG is configured, it denies permission to kexec_load syscall. To support architecture specific policies, a new function arch_get_ima_policy() is defined. This patch set defines IMA KERNEL_KEXEC_POLICY rules for x86 only if CONFIG_KEXEC_VERIFY_SIG is disabled and secure boot is enabled. This patch set includes a patch, which refactors ima_init_policy() to remove code duplication. Changelog: v3: * x86/ima: define arch_ima_get_secureboot - Edited subject line, added x86. * x86/ima: define arch_get_ima_policy() for x86 - Fixed the error reported by kbuild test robot. The error was appearing when CONFIG_X86 is enabled, but CONFIG_IMA_ARCH_POLICY is disabled. v2: * ima: define arch_ima_get_secureboot - New Patch - to retrieve secureboot state of the system * ima: prevent kexec_load syscall based on runtime secureboot flag - New Patch - disables kexec_load if KEXEC_VERIFY_SIG is configured and secureboot is enabled * ima: refactor ima_init_policy() - New Patch - cleans up the code duplication in ima_init_policy(), adds new function add_rules() * ima: add support for arch specific policies - modified ima_init_arch_policy() and ima_init_policy() to use add_rules() from previous patch. * ima: add support for external setting of ima_appraise - sets ima_appraise flag explicitly for arch_specific setting * ima: add support for KEXEC_ORIG_KERNEL_CHECK - deleted the patch based on Seth's feedback * x86/ima: define arch_get_ima_policy() for x86 - removes the policy KEXEC_ORIG_KERNEL_CHECK based on Seth's feedback. Eric Richter (1): x86/ima: define arch_get_ima_policy() for x86 Nayna Jain (5): x86/ima: define arch_ima_get_secureboot ima: prevent kexec_load syscall based on runtime secureboot flag ima: refactor ima_init_policy() ima: add support for arch specific policies ima: add support for external setting of ima_appraise arch/x86/kernel/Makefile | 2 + arch/x86/kernel/ima_arch.c | 35 +++++++ include/linux/ima.h | 18 ++++ security/integrity/ima/Kconfig | 8 ++ security/integrity/ima/ima.h | 5 + security/integrity/ima/ima_appraise.c | 11 ++- security/integrity/ima/ima_main.c | 17 ++-- security/integrity/ima/ima_policy.c | 167 +++++++++++++++++++++++++--------- 8 files changed, 214 insertions(+), 49 deletions(-) create mode 100644 arch/x86/kernel/ima_arch.c -- 2.13.6