Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp5162174imm; Tue, 9 Oct 2018 10:35:25 -0700 (PDT) X-Google-Smtp-Source: ACcGV63gtCHQQzkYZRFb8C+PZpxSJcsxv8QCBvMeezDk5Li5SX+lVZo291ccNKnlwIGwOEgcdijV X-Received: by 2002:a63:7419:: with SMTP id p25-v6mr26530756pgc.395.1539106525332; Tue, 09 Oct 2018 10:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539106525; cv=none; d=google.com; s=arc-20160816; b=Yr1KMTvgXxHIkbC6VnFq0RpFKDwmACr5OO7MNKcHZ0edFiFdENdbs68rxlgZli345u z+FKRcOV0MIIaR4aaxRxwmtOZhmVIz0GdVXLGBNd9BA4HB5fHq50+wIEmca7lUbRFe9K UwvZhq0LfLckgz0GYLAJVFpKlULmQwRhGun5i9MArRAnvPT7urqjCfygAfxf8x3qGz/U uyOntk48VsBkmUoRZsIv2d7NPWWeJ5syvVAppnRyfClV+rBbKgHL7BMqU3/nCUf9U232 8DC81jK/+iB5BQtF3S9dVc6/sFPq4A2DW7HGJgBe5kTsK20mljts7AFoS4/ISQeQt4SN m0Aw== 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=/H26H1hdbekKs+ZY24wmiToYU+6vjNx2yWMYUNFvCk8=; b=skqEsy62eftHIIpwllxZnwGWTlgknYItJr+uxaOgy/3M5UVOVfbcOUNdzqeljrbJaD bUVkZdNC5ItGYSjizYBU8/17qyaiKdfgzEXHwNem6/EcWprTnH8Bl6moaQunL6JNU487 wwDjrr8m47OWMii9aMac+GFhZhrcgEwID7cl5o9x/Fc7UoFJjUgEP/2OkejbT8zlmIzN iAn8BiBLrdpub02UNUmZH6Cx+f15DihE4HTheJpYJt5cP5yYE4gwkZMO3ohD78c9JTck aQm6dfk1GO38qkPSMlSUvEvg1K4u3i/W9y0qpfG/NTU/SAizyK1k57UPs/OTU6jtsBRV L9/Q== 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 s18-v6si20502966pgg.538.2018.10.09.10.35.10; Tue, 09 Oct 2018 10:35:25 -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 S1727374AbeJJAwU (ORCPT + 99 others); Tue, 9 Oct 2018 20:52:20 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57846 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726468AbeJJAwT (ORCPT ); Tue, 9 Oct 2018 20:52:19 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w99HTfdq128167 for ; Tue, 9 Oct 2018 13:34:16 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0a-001b2d01.pphosted.com with ESMTP id 2n0wtf0ys9-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 09 Oct 2018 13:34:15 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 9 Oct 2018 18:34:13 +0100 Received: from b06cxnps3074.portsmouth.uk.ibm.com (9.149.109.194) by e06smtp07.uk.ibm.com (192.168.101.137) 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:34:08 +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 w99HY6GA8651218 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 9 Oct 2018 17:34:06 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 91F9052050; Tue, 9 Oct 2018 20:33:40 +0100 (BST) Received: from swastik.in.ibm.com (unknown [9.195.38.245]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 8D8D85204E; Tue, 9 Oct 2018 20:33:35 +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 2/5] ima: prevent kexec_load syscall based on runtime secureboot flag Date: Tue, 9 Oct 2018 23:00:34 +0530 X-Mailer: git-send-email 2.13.6 In-Reply-To: <20181009173037.32630-1-nayna@linux.vnet.ibm.com> References: <20181009173037.32630-1-nayna@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18100917-0028-0000-0000-00000304B2DC X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18100917-0029-0000-0000-000023BF05F5 Message-Id: <20181009173037.32630-3-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=999 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 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 Cc: David Howells Cc: Eric Biederman Cc: Peter Jones Cc: Vivek Goyal Cc: Dave Young --- 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..9031c99e37a6 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) { + if (IS_ENABLED(CONFIG_KEXEC_VERIFY_SIG) + && arch_ima_get_secureboot()) + return -EACCES; + + 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