Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp728909imm; Fri, 5 Oct 2018 10:44:18 -0700 (PDT) X-Google-Smtp-Source: ACcGV63gZLqKLsQFShq46h0cGNfhhfvsoMx4s8mEvqCsWOEtZ0eLBwFJEHScJ+HwQj+NLWVQpxpn X-Received: by 2002:a17:902:9696:: with SMTP id n22-v6mr12768443plp.212.1538761458666; Fri, 05 Oct 2018 10:44:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538761458; cv=none; d=google.com; s=arc-20160816; b=QHKLKSud6anpOsiM0ly06GXUMzC7Mc5WddnxE8gLiO5qSV6BVYXZppIiicN0/SpRMi oc8sjijdfzMCP8kVPbx8Y6N8x2VD8Aln8rAtm/C5eWR6k9tK00MH4UlQYmqggYh1897I 1vFhiVgGFwGgfvWeFU6iFkE5EYMUeuHIV79FmimN8c0TSbeayDU3gnBXPFKaFYyN+ZnV 7/6W//hyLUH6qdieKnxirQK6rTVVAfkybsumXKqszb79FuR9zw9m9yjPTcr8p6aom+C/ GUWi+FEUVVAw0fkA4jitW1WTFqRwAmCSBzLW3GDm8ppEJRIVV85zzy7BcYMzSL5kqN6M wsmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:references:in-reply-to:date :subject:cc:to:from; bh=iB8HyqO2qhkHz4Mnk3xDCqaGAHl1NeIkMANvY1gHTB4=; b=zzyDJhd1yhxYhy+Q9jkxPEauWdIjyLVuILMdhXHpjRxcUhbS1Ao4IgOkGjsf8a6nIz VylPdzg0UrJFoh/UChch0jhbW7kl8W6/Do+0XHXy9p5G9qu6Ml4YYw4eKfAHfZHIrz0f lKwIRuDLLrbDad6WkU6pxcLDzkpCOxnTHK2YrWr8JXU331scnmf5PjGcb1JTIHeycqdw qQT8BTTl36mUbP5zM5fcsFDUNE27nUGgCztWHTJqqevfSbCmzGdkorUvGAtaHRjQZAsy qVJbahbMURJGC/kOkQ2gokRsabCmDsBxN4xAH5sGmzuOHETTXsJH1jUEkPiQcMdaeihC 8sXg== 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 12-v6si7321479pgd.191.2018.10.05.10.44.03; Fri, 05 Oct 2018 10:44:18 -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 S1729083AbeJFAna (ORCPT + 99 others); Fri, 5 Oct 2018 20:43:30 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48830 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbeJFAn3 (ORCPT ); Fri, 5 Oct 2018 20:43:29 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w95HdN6A086916 for ; Fri, 5 Oct 2018 13:43:44 -0400 Received: from e06smtp05.uk.ibm.com (e06smtp05.uk.ibm.com [195.75.94.101]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mxan0eb2j-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 05 Oct 2018 13:43:43 -0400 Received: from localhost by e06smtp05.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 5 Oct 2018 18:43:37 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp05.uk.ibm.com (192.168.101.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Fri, 5 Oct 2018 18:43:33 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w95HhVHn53608670 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 5 Oct 2018 17:43:31 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7682E11C052; Fri, 5 Oct 2018 20:43:07 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D306811C04A; Fri, 5 Oct 2018 20:43:04 +0100 (BST) Received: from swastik.in.ibm.com (unknown [9.124.221.60]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 5 Oct 2018 20:43:04 +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, kexec@lists.infradead.org, Nayna Jain Subject: [PATCH v5 2/5] ima: prevent kexec_load syscall based on runtime secureboot flag Date: Fri, 5 Oct 2018 23:10:12 +0530 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181005174015.21939-1-nayna@linux.vnet.ibm.com> References: <20181005174015.21939-1-nayna@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18100517-0020-0000-0000-000002D018B7 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18100517-0021-0000-0000-0000211E701D Message-Id: <20181005174015.21939-3-nayna@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-10-05_09:,, 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=967 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1810050174 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nayna Jain When CONFIG_KEXEC_VERIFY_SIG is enabled, the kexec_file_load syscall requires the kexec'd kernel image to be signed. Distros are concerned about totally disabling the kexec_load syscall. As a compromise, the kexec_load syscall will only be disabled when CONFIG_KEXEC_VERIFY_SIG is configured and the system is booted with secureboot enabled. This patch disables the kexec_load syscall only for systems booted with secureboot enabled. Signed-off-by: Nayna Jain --- security/integrity/ima/ima_main.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index dce0a8a217bb..bdb6e5563d05 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -505,20 +505,24 @@ int ima_post_read_file(struct file *file, void *buf, loff_t size, */ int ima_load_data(enum kernel_load_data_id id) { - bool sig_enforce; + bool ima_enforce, sig_enforce; - if ((ima_appraise & IMA_APPRAISE_ENFORCE) != IMA_APPRAISE_ENFORCE) - return 0; + ima_enforce = + (ima_appraise & IMA_APPRAISE_ENFORCE) == IMA_APPRAISE_ENFORCE; switch (id) { case LOADING_KEXEC_IMAGE: - if (ima_appraise & IMA_APPRAISE_KEXEC) { +#ifdef CONFIG_KEXEC_VERIFY_SIG + if (arch_ima_get_secureboot()) + return -EACCES; +#endif + if (ima_enforce && (ima_appraise & IMA_APPRAISE_KEXEC)) { pr_err("impossible to appraise a kernel image without a file descriptor; try using kexec_file_load syscall.\n"); return -EACCES; /* INTEGRITY_UNKNOWN */ } break; case LOADING_FIRMWARE: - if (ima_appraise & IMA_APPRAISE_FIRMWARE) { + if (ima_enforce && (ima_appraise & IMA_APPRAISE_FIRMWARE)) { pr_err("Prevent firmware sysfs fallback loading.\n"); return -EACCES; /* INTEGRITY_UNKNOWN */ } @@ -526,7 +530,8 @@ int ima_load_data(enum kernel_load_data_id id) case LOADING_MODULE: sig_enforce = is_module_sig_enforced(); - if (!sig_enforce && (ima_appraise & IMA_APPRAISE_MODULES)) { + if (ima_enforce && (!sig_enforce + && (ima_appraise & IMA_APPRAISE_MODULES))) { pr_err("impossible to appraise a module without a file descriptor. sig_enforce kernel parameter might help\n"); return -EACCES; /* INTEGRITY_UNKNOWN */ } -- 2.13.6