Received: by 10.192.165.156 with SMTP id m28csp108907imm; Thu, 12 Apr 2018 17:42:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/pL06QDIy1VgziSW4LMNwLkSxWNMOyv8Y1lPFiOgYELhwsUEdumj6XIyu5jW33NV32yg+s X-Received: by 2002:a17:902:846:: with SMTP id 64-v6mr3160496plk.216.1523580178960; Thu, 12 Apr 2018 17:42:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523580178; cv=none; d=google.com; s=arc-20160816; b=xS04FNj0py9n0q5aLdjRbdCH2t4E4o0TQduIwHGjoypLzU0BLEpsD51+aiX0rL9AuN MYrxnsIuGTeZKE5sHyeOyvdjB8SFlmASevZMFJjZP31EtI7bldEic0n4CTjbxBA666TT 5dQ6l0isyHhtWtC0S19cSRv0CIqyL8itzYHixURN1VulyM7ZJMOGcOGeSGDW+NjZQ5SS 00b71C0Q9y434QAgCW+efE1yQ/3/sLFYTNwRAgilRjT9BsE/fzQpmRTkTbNBWsEtwUdV a28RUR5sdn9kJ6IQkNPorO6jafwBVL/tu9fqFKULFEo3mZ3hO+2utROVj1ErBj+5/aLX qWDA== 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:arc-authentication-results; bh=9Srw8K+QtLDXZgL8GcViialzeDHaUxKwizrZBEPVTOE=; b=Pe/o7eKbfHPj7OwuB0rXYFP+ET3T1UwFTodo9hLX/MfnmtlUw5lJi79fCfgehZnP1C BdJVvzZ2c7d2Y59KM0B4xqVOLia9OdhIWgH7QVsYXgZfTBILE1lGKB3rUAZM92hKcjM8 eTaudw7Betu3F3tUuZnnQyWzsMUzjZzg8nQyVQE6sMAAqT3zia8sfaTyFEdtli3ZUyZE AoAMl25mmr+GS5cZfHekAiPmbTaSrkPKq8RMX6p7okV67NpMozW9SyHcGCjMwxzbp9x7 Q2xL4JAuppof8xxFPIy7vKRPevskM86XBOgCAixIsyD7FmSPqAxcmKevQRKwAIJIEWCv qohA== 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 c184si3399260pfc.367.2018.04.12.17.42.44; Thu, 12 Apr 2018 17:42:58 -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 S1753279AbeDLWmc (ORCPT + 99 others); Thu, 12 Apr 2018 18:42:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:39242 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753611AbeDLWmP (ORCPT ); Thu, 12 Apr 2018 18:42:15 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w3CMdFLD108800 for ; Thu, 12 Apr 2018 18:42:14 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hacaw1wts-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 12 Apr 2018 18:42:14 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Apr 2018 23:42:12 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Apr 2018 23:42:08 +0100 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w3CMg8m557999420; Thu, 12 Apr 2018 22:42:08 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 123D9AE045; Thu, 12 Apr 2018 23:32:03 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C16ECAE053; Thu, 12 Apr 2018 23:32:01 +0100 (BST) Received: from localhost.ibm.com (unknown [9.80.84.218]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 12 Apr 2018 23:32:01 +0100 (BST) From: Mimi Zohar To: David Howells Cc: Matthew Garrett , Mimi Zohar , linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, Eric Biederman , kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] ima: based on policy require signed kexec kernel images Date: Thu, 12 Apr 2018 18:41:51 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1523572911-16363-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1523572911-16363-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18041222-0040-0000-0000-0000044CF105 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041222-0041-0000-0000-000020F126C6 Message-Id: <1523572911-16363-4-git-send-email-zohar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-04-12_13:,, 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 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1804120213 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The original kexec_load syscall can not verify file signatures. This patch differentiates between the kexec_load and kexec_file_load syscalls. Signed-off-by: Mimi Zohar --- security/integrity/ima/ima.h | 1 + security/integrity/ima/ima_main.c | 9 +++++++++ security/integrity/ima/ima_policy.c | 2 ++ 3 files changed, 12 insertions(+) diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h index 35fe91aa1fc9..03c9c37ee345 100644 --- a/security/integrity/ima/ima.h +++ b/security/integrity/ima/ima.h @@ -233,6 +233,7 @@ int ima_policy_show(struct seq_file *m, void *v); #define IMA_APPRAISE_MODULES 0x08 #define IMA_APPRAISE_FIRMWARE 0x10 #define IMA_APPRAISE_POLICY 0x20 +#define IMA_APPRAISE_KEXEC 0x40 #ifdef CONFIG_IMA_APPRAISE int ima_appraise_measurement(enum ima_hooks func, diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 74d0bd7e76d7..754ece08e1c6 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -444,6 +444,15 @@ int ima_read_file(struct file *file, enum kernel_read_file_id read_id) } return 0; /* We rely on module signature checking */ } + + if (!file && read_id == READING_KEXEC_IMAGE) { + if ((ima_appraise & IMA_APPRAISE_KEXEC) && + (ima_appraise & IMA_APPRAISE_ENFORCE)) { + pr_err("impossible to appraise a kernel image without a file descriptor; try using kexec_file syscall.\n"); + return -EACCES; /* INTEGRITY_UNKNOWN */ + } + return 0; + } return 0; } diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 1bdb5bc57568..3444352caf80 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -443,6 +443,8 @@ static int ima_appraise_flag(enum ima_hooks func) return IMA_APPRAISE_FIRMWARE; else if (func == POLICY_CHECK) return IMA_APPRAISE_POLICY; + else if (func == KEXEC_KERNEL_CHECK) + return IMA_APPRAISE_KEXEC; return 0; } -- 2.7.5