Received: by 10.192.165.156 with SMTP id m28csp107885imm; Thu, 12 Apr 2018 17:41:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx48rmLUb1c14InYqYMYH1PSi7Op0/+3y1OB1A/ALoZADa5MHUQafLk3d3qfyYDnK3Y8KgsMS X-Received: by 2002:a17:902:2ac3:: with SMTP id j61-v6mr3133012plb.224.1523580083460; Thu, 12 Apr 2018 17:41:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523580083; cv=none; d=google.com; s=arc-20160816; b=C9NNqTj6/puqEl2HHn+vtEnscgiRmr0ixqshaAgVMJUckMmAm74z9t5LGfnO5x55I0 xp/0HyMru9zkWPyR11+vJEfVeFRk04Q53Is4h7Pd81zp2M7XPRaQ6uTXiqSlzl4SSb0b rcywC9gIGpUhukT5HwYuKj7dwHH4BPlFBEA+dyYa0cxWALV/WVsfBK4n4zRpNLP0c+nH T3FU/y/ACcQ5W01zEF0Qz1RlaICYyuGzRZANY7+T9lr9gdSaNvVrDdv5o1BA5//MrqrA QiQth6a3Uy52Y1D3m1Qv7+lMBDsQp5CX5hYAgCbsNR1Og4391eRTZ4SNYxIwsOWT/KRW Q5IA== 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=NT4jaef5oWq363vzt/TB2tz5/dBn+IYHNvSGIAaG9H4=; b=OJzAlnk7Ppg+r6nI0Zt9qC49QeycB8wwa6xJlDRlZKlKMUG10R8AMZ8R6BVUZV0NVu cUOvCmApi4GMfTy4P+gcO9sir1O9ZP+ll3aUN8E2HU/G9YSZcAWAgQeNCjf3JJPXL2N+ kBhl4o3dzNZ1wl277gD/py0GCu/fuyB9J9htYbebduGVKt0bQdKFKA4VVVBIt1VrbKWS jL7lPsx4FKyS5b08j9q2gu8Qc75IrIMozVDz6uQLc3r4HumvGuomtfPFS6/UI9VvA1Y3 GTQHK2P0RmpWIp4WVnm+iFv+XariJ2N5pryE+twZQQMlhLhzVNE8pZjriJddd3q799qe XvLA== 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 x7si3594224pfk.311.2018.04.12.17.41.09; Thu, 12 Apr 2018 17:41:23 -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 S1753669AbeDLWmR (ORCPT + 99 others); Thu, 12 Apr 2018 18:42:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58334 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753499AbeDLWmL (ORCPT ); Thu, 12 Apr 2018 18:42:11 -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 w3CMgAAo040623 for ; Thu, 12 Apr 2018 18:42:10 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2haenk447f-1 (version=TLSv1.2 cipher=AES256-SHA256 bits=256 verify=NOT) for ; Thu, 12 Apr 2018 18:42:10 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 12 Apr 2018 23:42:07 +0100 Received: from b06cxnps4074.portsmouth.uk.ibm.com (9.149.109.196) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 12 Apr 2018 23:42:03 +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 w3CMg3OB55836870; Thu, 12 Apr 2018 22:42:03 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46DB0AE045; Thu, 12 Apr 2018 23:31:58 +0100 (BST) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E1DD5AE051; Thu, 12 Apr 2018 23:31:56 +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:31:56 +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 1/3] ima: based on the "secure_boot" policy limit syscalls Date: Thu, 12 Apr 2018 18:41:49 -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-0020-0000-0000-000004114B0C X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18041222-0021-0000-0000-000042A57B8E Message-Id: <1523572911-16363-2-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 builtin "secure_boot" policy adds IMA appraisal rules requiring kernel modules (finit_module syscall), direct firmware load, kexec kernel image (kexec_file_load syscall), and the IMA policy to be signed, but did not prevent the other syscalls/methods from working. Loading an equivalent custom policy containing these same rules would have prevented the other syscalls/methods from working. This patch refactors the code to load custom policies, defining a new function named ima_appraise_flag(). The new function is called either when loading the builtin "secure_boot" or custom policies. Fixes: 503ceaef8e2e ("ima: define a set of appraisal rules requiring file signatures") Signed-off-by: Mimi Zohar --- security/integrity/ima/ima_policy.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index d89bebf85421..1bdb5bc57568 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -435,6 +435,17 @@ void ima_update_policy_flag(void) ima_policy_flag &= ~IMA_APPRAISE; } +static int ima_appraise_flag(enum ima_hooks func) +{ + if (func == MODULE_CHECK) + return IMA_APPRAISE_MODULES; + else if (func == FIRMWARE_CHECK) + return IMA_APPRAISE_FIRMWARE; + else if (func == POLICY_CHECK) + return IMA_APPRAISE_POLICY; + return 0; +} + /** * ima_init_policy - initialize the default measure rules. * @@ -473,9 +484,12 @@ void __init ima_init_policy(void) * Insert the appraise rules requiring file signatures, prior to * any other appraise rules. */ - for (i = 0; i < secure_boot_entries; i++) + for (i = 0; i < secure_boot_entries; i++) { list_add_tail(&secure_boot_rules[i].list, &ima_default_rules); + temp_ima_appraise |= + ima_appraise_flag(secure_boot_rules[i].func); + } for (i = 0; i < appraise_entries; i++) { list_add_tail(&default_appraise_rules[i].list, @@ -917,12 +931,9 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) } if (!result && (entry->action == UNKNOWN)) result = -EINVAL; - else if (entry->func == MODULE_CHECK) - temp_ima_appraise |= IMA_APPRAISE_MODULES; - else if (entry->func == FIRMWARE_CHECK) - temp_ima_appraise |= IMA_APPRAISE_FIRMWARE; - else if (entry->func == POLICY_CHECK) - temp_ima_appraise |= IMA_APPRAISE_POLICY; + else if (entry->action == APPRAISE) + temp_ima_appraise |= ima_appraise_flag(entry->func); + audit_log_format(ab, "res=%d", !result); audit_log_end(ab); return result; -- 2.7.5