Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp200490imm; Thu, 10 May 2018 18:38:47 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoNLlYMTicVRXzo93Jg1BQOGITHWjkzEGKlVdcZuGwCI1mnsYfvtwObIpSDo6GzM0FspmIf X-Received: by 2002:a17:902:7b97:: with SMTP id w23-v6mr3557548pll.116.1526002727796; Thu, 10 May 2018 18:38:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526002727; cv=none; d=google.com; s=arc-20160816; b=X+Jp4St8kIJgNjVuPsvM20uWjjps5wC+h4Qn/CQBe3ZGHuJwQvh4vLoPn00XfVr8Co SlM1VxS3+dZmF3b97UwkrL4mMvic089fNQpJ2Sf2KnkeiOjfGpI6J/LnbY8tTYPFvyPC GSYthyG40iZkRdwGLKX3kHXrNn3Z8lYVFRkgyHzVtFjBUzcMmaRjI1AWTvtt0RKaJ9WO pU7mDXJvEGrZvB9phoNqG4ZiAYjz/WwGDKL5/ZS9SL4YlMW99zueSDGQnCsbDqppeXYu yLwl8iDjC8qxAYadQG/D4KavZ8zhUPt5i0kzRTXOIZd/QorVeRoOQdsdE2sP7PoFYMv/ Fdcw== 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=hdm8FeqUNdTOxTACqR3T54cuu92UtOSBsn2VOcn1OsY=; b=m78KD02OkTJToniBzo2Pzk7osptZQ6sHl88jmqLrDUOmjyLHyWKmQm9YnPWLfHYrcG LYfNP4gTo4y7CggEQ5A++W8OVHVMc4+p+Dnf+QZ1itiRPAuYdRiIG/83QzOSJsHOukVo pLzuHTiA9LlAvLI0rwL6IgIRgpsuBBC9q+2mw3ygsdZuBn7xSBYx5nbvO07ggUreWsPO 0F11enNMFmC9AlPDEVHvffjbnCOTBSTvEDXCLYikqO1/E1AK1Ab/9bUsny5N50YAhuuU vHRpZKRIliOWRVxMrCpr60Cj3ZnHPHvsVX/9gSoHDJJkBgx49NuXDxgVGEwLU583JDvg aTjw== 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 k185-v6si2008867pfc.361.2018.05.10.18.38.33; Thu, 10 May 2018 18:38:47 -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 S1752207AbeEKBhr (ORCPT + 99 others); Thu, 10 May 2018 21:37:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48308 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752049AbeEKBhF (ORCPT ); Thu, 10 May 2018 21:37:05 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4B1YoGB031542 for ; Thu, 10 May 2018 21:37:04 -0400 Received: from e06smtp15.uk.ibm.com (e06smtp15.uk.ibm.com [195.75.94.111]) by mx0a-001b2d01.pphosted.com with ESMTP id 2hvum756fv-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 10 May 2018 21:37:04 -0400 Received: from localhost by e06smtp15.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 May 2018 02:37:02 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp15.uk.ibm.com (192.168.101.145) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 11 May 2018 02:36:57 +0100 Received: from d06av25.portsmouth.uk.ibm.com (d06av25.portsmouth.uk.ibm.com [9.149.105.61]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4B1avCi7733608; Fri, 11 May 2018 01:36:57 GMT Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9492B11C054; Fri, 11 May 2018 02:28:20 +0100 (BST) Received: from d06av25.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7A18511C04A; Fri, 11 May 2018 02:28:19 +0100 (BST) Received: from localhost.ibm.com (unknown [9.80.104.201]) by d06av25.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 11 May 2018 02:28:19 +0100 (BST) From: Mimi Zohar To: linux-integrity@vger.kernel.org Cc: Eric Biederman , David Howells , Mimi Zohar , linux-security-module@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] ima: based on the "secure_boot" policy limit syscalls Date: Thu, 10 May 2018 21:36:46 -0400 X-Mailer: git-send-email 2.7.5 In-Reply-To: <1526002608-27474-1-git-send-email-zohar@linux.vnet.ibm.com> References: <1526002608-27474-1-git-send-email-zohar@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 18051101-0020-0000-0000-0000041C145A X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051101-0021-0000-0000-000042B114E5 Message-Id: <1526002608-27474-2-git-send-email-zohar@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-11_01:,, 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-1805110009 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 03cbba423e59..df3e45878a87 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -440,6 +440,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. * @@ -478,9 +489,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, @@ -934,12 +948,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