Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5161549imm; Tue, 9 Oct 2018 10:34:49 -0700 (PDT) X-Google-Smtp-Source: ACcGV630VfF/qk0ruVzT/xfBAZFkCB2MXchiOCZm8/QmMGrRM3cQbKy4Qe3KJ4qE2NX7zgZdKTv+ X-Received: by 2002:a65:47cb:: with SMTP id f11-v6mr27101304pgs.166.1539106489410; Tue, 09 Oct 2018 10:34:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539106489; cv=none; d=google.com; s=arc-20160816; b=ba1WhtYxAZvZVlRM51wX/olGvWUHv9SjLnH5E5Iyw4qxmFHNpssG5eI9Oo4htRuUFY gcGs7gVPQBdqhJlXrsDQs7kzBQFn3B2HGwa1sMXdCd6FENwJCvwTo9dClilpMcHR7MGx ZGi+VW5Zh5yoms7wHSnj0htmBrOBoqfvJUqz/2PkAT+b5dSacr5Wz2X/NPUMVdNw+7/J ZeW4YfzcAvw4oAVZ9Rb6v/Nb6D8cwe8gZTfs9SexDJZhtXmBOEw+95fYHZpakCNUw2nO R7sh00UxmimGdzO6lqXFfP/hM6LtefnqShB23+CyyRkc0EM5sJg4EA48yk7UxdoR71UA cLcA== 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=PSovUB80gDL+l3GOXFGSH04GFzUqaZ8zCG0Xj9BqZ8g=; b=lo9xqC8Y9uJuldQ9dUl/l2zGeSzA6imvqiAqBVQZr4FcVkGtgf9ePzfJCAKeuuPBu8 0IjNkYVUOljHDzRPOCmahxDZxiL2tBYhTga+xlTgnFtz+KE/JnD0XSv7sHWZEOF6VvVe DoTyCqltdzLluhHuMYDA15OUEV1QqoVxsBmHAGiEblUvw6OCeU0Alhfu1WG18+62JkrO 10N5emjI+w3a3Kz5oYCy/vQDk2WX469BJdoSZBHU1ZNkpZU+Qec6Z6LRe/fe9TXctHzN GmT7S4Wqf/gszlknytX02GtyYQ/SkpggMMgZO+QU5eOcjeTpMiJSlBLzi/JL0WZ7/7Q6 7FXA== 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 74-v6si22077547pga.231.2018.10.09.10.34.34; Tue, 09 Oct 2018 10:34:49 -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 S1726723AbeJJAwE (ORCPT + 99 others); Tue, 9 Oct 2018 20:52:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55500 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbeJJAwE (ORCPT ); Tue, 9 Oct 2018 20:52:04 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w99HTY53063424 for ; Tue, 9 Oct 2018 13:34:00 -0400 Received: from e06smtp03.uk.ibm.com (e06smtp03.uk.ibm.com [195.75.94.99]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n0wusrsdt-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Oct 2018 13:34:00 -0400 Received: from localhost by e06smtp03.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 Oct 2018 18:33:58 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp03.uk.ibm.com (192.168.101.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 9 Oct 2018 18:33:53 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w99HXpux8585618 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Oct 2018 17:33:52 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FD8B52051; Tue, 9 Oct 2018 20:33:25 +0100 (BST) Received: from swastik.in.ibm.com (unknown [9.195.38.245]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 11EB552050; Tue, 9 Oct 2018 20:33:19 +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, seth.forshee@canonical.com, pjones@redhat.com, vgoyal@redhat.com, dyoung@redhat.com, ebiederm@xmission.com, kexec@lists.infradead.org, Nayna Jain Subject: [PATCH v6 0/6] Add support for architecture specific IMA policies Date: Tue, 9 Oct 2018 23:00:32 +0530 X-Mailer: git-send-email 2.13.6 X-TM-AS-GCONF: 00 x-cbid: 18100917-0012-0000-0000-000002B4B414 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18100917-0013-0000-0000-000020E90810 Message-Id: <20181009173037.32630-1-nayna@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-09_12:,, 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=938 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810090169 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nayna Jain 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, as described below. 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: v6: * ima: prevent kexec_load syscall based on runtime secureboot flag - Includes Mimi's feedback - replace #ifdef with IS_ENABLED in .c file * ima: add support for arch specific policies - Fixed one line exceeding 80 character's warning * x86/ima: define arch_get_ima_policy() for x86 - Includes Mimi's feedback - replace #ifdef with IS_ENABLED in .c file and fixed a comment v5: * ima: refactor ima_init_policy() - Includes Mimi's feedback - updated patch description, and code fixes. * ima: add support for arch specific policies - Includes Mimi's feedback - updated comment. * ima: add support for external setting of ima_appraise - Includes Mimi's feedback - This patch is deleted. This is handled by enabling IMA_APPRAISE_BOOTPARAM only if IMA_ARCH_POLICY is not enabled. The change is done in the Patch 5/5. v4: * ima: refactor ima_init_policy() - Fixed the issue reported by Dan Carpenter. Replaced logical operator (&&) with bitwise operator (&). 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 (4): 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 arch/x86/kernel/Makefile | 2 + arch/x86/kernel/ima_arch.c | 33 +++++++ include/linux/ima.h | 15 ++++ security/integrity/ima/Kconfig | 10 ++- security/integrity/ima/ima_main.c | 17 ++-- security/integrity/ima/ima_policy.c | 167 +++++++++++++++++++++++++++--------- 6 files changed, 195 insertions(+), 49 deletions(-) create mode 100644 arch/x86/kernel/ima_arch.c -- 2.13.6