Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1994595imm; Thu, 24 May 2018 04:12:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpTTsmAb+GXAAPnCoc0WmnmkC4o3dg2DxotE6WONiCqk63/g5otBIhD72BKG+1C996RhG9V X-Received: by 2002:a17:902:b907:: with SMTP id bf7-v6mr6908250plb.331.1527160333031; Thu, 24 May 2018 04:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527160333; cv=none; d=google.com; s=arc-20160816; b=QDihrRsbzmRGRfmKzOKwntPcXtcrAEvf3Z63BYIUIuYFLiIlay2TpnuL1M5rB9Fscq YetfQY5LPNRfg7F5ATqVTsmDw2wV3HbwVjX0rNTYidSbpTpD96yNoR/VsNTORKYNP+d9 iVieYnhpeeQ18Cs/lYgiS3GFsF6WLzzOzu3IPDDHQxycsV1Vu3p3dCxN++IPsPTsdRsr r7Hp/rd9siosvkNSRl9juppUWSFzSW6C6ZTm1a1kyFy4jaGmGAbQgERZalMsvuKN1mGl Ml/gE5ERs+kmDRxib0NsX48vgptrcvxXO1BSAIkW0YwaVVdiNuGMIbzuQaI9xjuRtJ5/ 54Lg== 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=jWeYFlNSWEaEXXF1/ucNITuW4P5HA5Q0dPSkfTrMit8=; b=Oz1EsUFKN773CPqavZ6wP+43D2TtYst31sk7w/FcA8YUGzNfPWjdpCd45YR/af1Nd+ yEwd/XCKDFH0NceFRBj7Kc9QIaPlHvOA2keWcaQpF5UMtZmXveVPWQgoq5UPpcSdUZSR H1NSE0MEOOr9LsRnbO1yU9vRtxPu3yqe/dfv1e9wY0GTizI8RSwKTa387cA7wN+L/oKh 4Pwp6lu8kT0gBEF0k7W2+3VttGMuSwpwrVYs//1ejEt0yQBmBwmSSYVyaOFk3bnhT20Z uFokhdBlFqy/coYW9VvF3XMG3zGxU4R09xpbmIS9uDrLkcLyvAnF73317jfCv4/dE7xh oR3w== 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 z19-v6si20553667plo.174.2018.05.24.04.11.58; Thu, 24 May 2018 04:12:12 -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 S1033070AbeEXLKs (ORCPT + 99 others); Thu, 24 May 2018 07:10:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56818 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1033040AbeEXLKh (ORCPT ); Thu, 24 May 2018 07:10:37 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4OAxupo003875 for ; Thu, 24 May 2018 07:10:36 -0400 Received: from e06smtp12.uk.ibm.com (e06smtp12.uk.ibm.com [195.75.94.108]) by mx0b-001b2d01.pphosted.com with ESMTP id 2j5t4r5yka-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 24 May 2018 07:10:36 -0400 Received: from localhost by e06smtp12.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 24 May 2018 12:10:34 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (9.149.109.198) by e06smtp12.uk.ibm.com (192.168.101.142) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Thu, 24 May 2018 12:10:31 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4076.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4OBAUVp6095244 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 24 May 2018 11:10:30 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63E6511C04A; Thu, 24 May 2018 12:01:34 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EAC2911C054; Thu, 24 May 2018 12:01:32 +0100 (BST) Received: from localhost.ibm.com (unknown [9.80.85.225]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Thu, 24 May 2018 12:01:32 +0100 (BST) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Mimi Zohar , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, David Howells , "Luis R . Rodriguez" , Eric Biederman , kexec@lists.infradead.org, Andres Rodriguez , Greg Kroah-Hartman , Ard Biesheuvel , Kees Cook Subject: [PATCH v3 3/7] ima: based on policy require signed kexec kernel images Date: Thu, 24 May 2018 07:09:32 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1527160176-29269-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1527160176-29269-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18052411-0008-0000-0000-000004FAA7C3 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052411-0009-0000-0000-00001E8EAFD2 Message-Id: <1527160176-29269-4-git-send-email-zohar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-24_03:,, 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 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805240132 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 Cc: Eric Biederman Cc: Luis R. Rodriguez Cc: Kees Cook Cc: David Howells Changelog v3: - use switch/case --- security/integrity/ima/ima.h | 1 + security/integrity/ima/ima_main.c | 22 +++++++++++++++++----- security/integrity/ima/ima_policy.c | 2 ++ 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h index 354bb5716ce3..78c15264b17b 100644 --- a/security/integrity/ima/ima.h +++ b/security/integrity/ima/ima.h @@ -232,6 +232,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 eeb7075868db..fbbcc02a1380 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -432,15 +432,27 @@ void ima_post_path_mknod(struct dentry *dentry) */ int ima_read_data(struct file *file, enum kernel_read_file_id read_id) { - bool sig_enforce = is_module_sig_enforced(); + bool sig_enforce; - if (!file && read_id == READING_MODULE) { - if (!sig_enforce && (ima_appraise & IMA_APPRAISE_MODULES) && - (ima_appraise & IMA_APPRAISE_ENFORCE)) { + if ((ima_appraise & IMA_APPRAISE_ENFORCE) != IMA_APPRAISE_ENFORCE) + return 0; + + switch (read_id) { + case READING_MODULE: + sig_enforce = is_module_sig_enforced(); /* appended sig */ + if (!file && !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 */ } - return 0; /* We rely on module signature checking */ + break; + case READING_KEXEC_IMAGE: + if (!file && (ima_appraise & IMA_APPRAISE_KEXEC)) { + pr_err("impossible to appraise a kernel image without a file descriptor; try using kexec_file syscall.\n"); + return -EACCES; /* INTEGRITY_UNKNOWN */ + } + default: + break; } return 0; } diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 8bbc18eb07eb..c27f6993b07a 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -448,6 +448,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