Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp1908201imm; Thu, 27 Sep 2018 04:34:54 -0700 (PDT) X-Google-Smtp-Source: ACcGV63izN7spRYF+eirZ/6ccWCHliptIFcFeWvSw+ynSFdfnKB/V5Ztlsautr+3/oTptW2RgM1G X-Received: by 2002:aa7:850d:: with SMTP id v13-v6mr10910202pfn.83.1538048094872; Thu, 27 Sep 2018 04:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538048094; cv=none; d=google.com; s=arc-20160816; b=qOKxe4ByaobEDAzamv4jrDKkoNAZhGv3+7X8pTYpY89XdJvRD5Ijv9DfD9JzYe6WLC 3ez9gn1cESbgI/eTmylOqc5h00A9qvExlE6g96C2TmLD7PlkWyGtvRlurOsC2dIUt3bB SDAtUminnNbwNoqL356VW3pDStU0vSQObSepWR/9mIfiOiuPuZfIgyv4lvsefYGr/wMZ mekl6phRpLdyma2wUpTO4jS3U/FA/Ktz4jFdTrEywVbg2jVKEZOiAA+Tc+xxc9khkHvp q9DFABCkbAaeGmGdUY4ZfUdZIgk97X9On3PgymdgprFpXkSAoKfMdNLDzu5hZ54txz57 6bmw== 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=kgGefHVQ0d+YIDV7ONlKL3nApV9+r1dmiBBfn7QQmb0=; b=X51arxUAnjWb8g6fV4zbagxTRfIt0YMvzbVcSk0LS1YkSJv5z6L2qv1kdC2hXZxO7K zFXNoJTzgS8VHR37wpxcpbfITaMZB2U5H+x7WG2w0OU1NwgegDhr1DQQZIebKHMorYux kuUAcv8lemSmb/6LsKlWG9OCcIQdgdQyHceqJvF+g0oV2atDuWfa5nZGfstYg/IzHyIj KN0y16iEwKy4jzeUUwlIaFzhdyrFJAiwD5niFBmweDItqVwX2NNh0AXe+04T/Mn0bMRF ayrj6mE0fcowao8zacn/xpNoJ3zTlUDUozLfoXltarLil0TnyJpiny/rkdltiXMYOS2U jUgw== 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 f10-v6si1858618pfn.85.2018.09.27.04.34.38; Thu, 27 Sep 2018 04:34:54 -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 S1727292AbeI0Rvq (ORCPT + 99 others); Thu, 27 Sep 2018 13:51:46 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:46464 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727027AbeI0Rvq (ORCPT ); Thu, 27 Sep 2018 13:51:46 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w8RBOWLR092106 for ; Thu, 27 Sep 2018 07:33:54 -0400 Received: from e06smtp01.uk.ibm.com (e06smtp01.uk.ibm.com [195.75.94.97]) by mx0a-001b2d01.pphosted.com with ESMTP id 2mrx798nh2-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 27 Sep 2018 07:33:54 -0400 Received: from localhost by e06smtp01.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 27 Sep 2018 12:33:51 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp01.uk.ibm.com (192.168.101.131) 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 12:33:48 +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 w8RBXlGj60555432 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 27 Sep 2018 11:33:47 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A3667A404D; Thu, 27 Sep 2018 14:33:27 +0100 (BST) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8A0B2A405D; Thu, 27 Sep 2018 14:33:26 +0100 (BST) Received: from localhost.localdomain (unknown [9.80.85.160]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 27 Sep 2018 14:33:26 +0100 (BST) Subject: Re: [PATCH v4 2/6] ima: prevent kexec_load syscall based on runtime secureboot flag 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, Seth Forshee , kexec Date: Thu, 27 Sep 2018 07:33:35 -0400 In-Reply-To: <20180926122210.14642-3-nayna@linux.vnet.ibm.com> References: <20180926122210.14642-1-nayna@linux.vnet.ibm.com> <20180926122210.14642-3-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: 7bit X-TM-AS-GCONF: 00 x-cbid: 18092711-4275-0000-0000-000002C14823 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18092711-4276-0000-0000-000037CC4AF4 Message-Id: <1538048015.3459.76.camel@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-09-27_06:,, 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-1809270115 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [Cc'ing the kexec mailing list, and Seth] On Wed, 2018-09-26 at 17:52 +0530, Nayna Jain wrote: > 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 Nice! Mimi > --- > 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 */ > }