From patchwork Fri Jun 30 16:57:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 13298558 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 909EDEB64DA for ; Fri, 30 Jun 2023 17:04:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232799AbjF3REM (ORCPT ); Fri, 30 Jun 2023 13:04:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232943AbjF3RDt (ORCPT ); Fri, 30 Jun 2023 13:03:49 -0400 Received: from mx0a-00069f02.pphosted.com (mx0a-00069f02.pphosted.com [205.220.165.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8ABED448E; Fri, 30 Jun 2023 10:03:12 -0700 (PDT) Received: from pps.filterd (m0246627.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 35UGiViq026956; Fri, 30 Jun 2023 17:01:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : content-transfer-encoding : content-type : mime-version; s=corp-2023-03-30; bh=8JzkDI3sHDCA5AX4xETJsUXcl27Cx8n9BQjDvKJKCWU=; b=0FQsxwDNkKPaJnx3PG/aoM9ZoO0hgdAhjIuEZOiz2dgVAjvE43CmgO/jus+LWuxaiRkC HegFivycC/ksaQUq/1t2Wg02pERN4ry/yGyedDIKHxyNw506raGYALPQvssFx48Vui8X eOMpxRX9BwfSbkURO1rwuqLIM5pZC7QZBOUFMt7aPQU1FvrjzYM9ivr+fo/lXJBf9rqk qdfS7hUj2p0q5kpJIoiBFfgVTkDfVYHemT5oOBXEfzOH+baBKBPaV5NuGGaIgDswtL2h VSYKTAh9IhmhNCzSYmSpgUyeGuj6nMNyM3wSQ4uM6+3N6gOlSR59uWM/GwCf1q+xI95j rw== Received: from iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (iadpaimrmta03.appoci.oracle.com [130.35.103.27]) by mx0b-00069f02.pphosted.com (PPS) with ESMTPS id 3rdq319phf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Jun 2023 17:01:57 +0000 Received: from pps.filterd (iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com [127.0.0.1]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (8.17.1.19/8.17.1.19) with ESMTP id 35UGwke9038173; Fri, 30 Jun 2023 17:01:56 GMT Received: from nam10-bn7-obe.outbound.protection.outlook.com (mail-bn7nam10lp2102.outbound.protection.outlook.com [104.47.70.102]) by iadpaimrmta03.imrmtpd1.prodappiadaev1.oraclevcn.com (PPS) with ESMTPS id 3rdpxfmxk4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 30 Jun 2023 17:01:55 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OaEkPAlO0zXS3hI5dTUOk+6pkvBuyFDa6Qo7T94j7EiwAcIBfYwPBVstPcLrIDO0cGcCTrPLs+whiNgPKI2B3fT0Ul4C5dIZkjBKljwTyutC1B1ZyB0Jmyhyzpu/nAmu2AeBBxluICsK+0VEU9S6eG70fOYjahAqIYpdcjuYZRe63MnbxX49BONEtE0L3Jbb8aS/Y3LctTTjdjmGKxa+v6iTm13gVKpV6eokZxikvdLw2DhdjadZJKGQAzsd2cEIHuSXpT1cBXmIYi7mfF+v86EXnN36M1WHADj+Jjdk2nYcrTNxrQITYT0DfnMAo8GKQ4WRqGvTXsGmvgmnkse9Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8JzkDI3sHDCA5AX4xETJsUXcl27Cx8n9BQjDvKJKCWU=; b=gy1QLYrDqpCt0wsV2/3lfI4ohuYOpofi1sfG9LQTwvhRgLvfCCZgAXjvSkrJpD7IOs1BVFZJdUXWlV/O4K1hx/ySOALScLXYw2eTCFqQKkOVHJGGjDiwsFC8DdK0KUlz5tOdBPTZR3s9jCoMmz5VXoSS4XGVQRUhbuthv4xpLxSA0uEA0D8KFEkbEq2xp0JvDex8T+hP8if4OT6WFQD6qa5DX6G9mVwPQngk5fy8tLNh8DdeoS5+TRhEnoH/A22mC+8acyQm82R632Ur7R0Ke9sZb6QqPmyYKgQehTXmh+tU5P632hS8zeQUog/fXOR6Z+Ots0S+2grB9RcHN9RSFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8JzkDI3sHDCA5AX4xETJsUXcl27Cx8n9BQjDvKJKCWU=; b=Ifjbp+4iB1ETQGkHkv6mrZ/s6hQx9o4i3yGoQwVen6HL9WufKQi8l2QJtRo0xFqqG/mbJJC1NYpsYLCYZ76AxH/PwHSsADMdSVaJvksFsTE0s73e8xPQ0Je12+Y5WAl6HlJi2DiXUs51J5EZBr9o817v+2lpOImYsfonz4Zmymo= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by CY5PR10MB6214.namprd10.prod.outlook.com (2603:10b6:930:31::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6521.26; Fri, 30 Jun 2023 17:01:53 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::6fe7:599d:4540:5ec1]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::6fe7:599d:4540:5ec1%4]) with mapi id 15.20.6521.026; Fri, 30 Jun 2023 17:01:53 +0000 From: Eric Snowberg To: zohar@linux.ibm.com Cc: dmitry.kasatkin@gmail.com, paul@paul-moore.com, jmorris@namei.org, serge@hallyn.com, roberto.sassu@huawei.com, eric.snowberg@oracle.com, kanth.ghatraju@oracle.com, konrad.wilk@oracle.com, linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH] integrity: Always reference the blacklist keyring with apprasial Date: Fri, 30 Jun 2023 12:57:12 -0400 Message-Id: <20230630165712.909767-1-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.39.3 X-ClientProxiedBy: SA9PR13CA0144.namprd13.prod.outlook.com (2603:10b6:806:27::29) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PR10MB4150:EE_|CY5PR10MB6214:EE_ X-MS-Office365-Filtering-Correlation-Id: f339ea44-611e-469b-f6c7-08db798bb448 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yORgfG/2jJbETvQTrsSjEj4GGypmCAW8F5qGf7xXGB1rYySpkcxPsgHEdv0+uUTVHO7c63H0lTGK2uaxZwoYuFsCligLp2f0tRuV23AVVb9B/T8IwatWQqFC+axSiMMJu3Q57RRbMbWhJINiovfNZ3qb88kXliObeaiygCuk/IiByXPxL52iwbp2OqAPo1BRaRzTC04XgnAUHUAOSslc5huQGL084Rl7hXCBM5uj38k4Q/oHxt8zFKcsE4mq97F2ikwPPRRYB6+oB5pkiTyF/MybCKiBazCpcPxwrpCN4e2ea+9nxVkBPXwu9JeYJ9XYTnc1emwJV27g/BLEmqAG3B9tPiVKcSDV9jGCO5X1LgyXoFZY6QzLu1sUHnSc0dd0ISVHhRJE/1yCWMfP5rLAucof+weDqtOgzQeJu5blI50kPtLsHkMoqkXON7X/U+0rJBuQZ/p4aMfUA8rzsKFvV4NfQkFSYGQ8Tn9XhQQec+jZVZSUz9rJEBxtWq4CvjQcbTfkS8zGI0zxyHAo4Xrh3xZ3iryz8oAJ1bK9O1/eOyv03J45USMON+UksJzm4KHh X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH2PR10MB4150.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(396003)(366004)(39860400002)(346002)(136003)(376002)(451199021)(41300700001)(186003)(6512007)(36756003)(66476007)(6916009)(66556008)(4326008)(66946007)(86362001)(8676002)(5660300002)(38100700002)(316002)(44832011)(8936002)(6666004)(1076003)(6506007)(2906002)(6486002)(83380400001)(2616005)(478600001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /1dRcnWtx4dFVCf4bnWRKl9J+arYRcb5hqiYcKbGwqXeP4XWKRvo59U5x9SHnbnSuCrheqqHhIYSjJLooKSPsUl5G/eDfOrcosapKUhuZuJqvjPvDBYVGmzzGutgV8IWbVWqBWyCwYYUE6FQ05adMfiiuHC6iswMRQOgROXMTWcC8CXuECHOeDpWH6o+mG1s7XwKn8g717OEPHg57mWwoiXjXD9oeWQvBUVZHEpmCyOAF0FAjLFpv8KoPKpaNjD4vLTNEe/wyL/v17jBtONJ7Fubb7qDZKSi1uWtomjNdaOgwVdKUqMfZC1a1K3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+OGYV3UDgcwu8D2oLwnc8W2hkjuFkv9X8FZVN3FIErZT6kJF1DvmD6ybHyBZAdD27twVJ99cTseOvQDMiJZAMQ5A2fYxoJsfYvurPOB9xbyAWUd0mB6RoQVHKIzUqP20rIAtJ9YgBLFKkTMGFKRSlhoSDDtBUcFYaB2+7V3RYM727SreNit8CTK5K12cJX2+O+2WpPTUIikS X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: f339ea44-611e-469b-f6c7-08db798bb448 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Jun 2023 17:01:53.6833 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PqA6if3HIEagg8qGNuS4Nlag5SrLXzfp47YM2bs9jrSQ74KPUpYvDr7i8T8z/3PamWxT4M/astosVW4ZfnY5a6hBb8IeAJEoOSN3teRwm3A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY5PR10MB6214 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.591,FMLib:17.11.176.26 definitions=2023-06-30_09,2023-06-30_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 spamscore=0 mlxlogscore=999 malwarescore=0 phishscore=0 bulkscore=0 suspectscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2305260000 definitions=main-2306300146 X-Proofpoint-ORIG-GUID: urGeiPCiyzMhR8jjYf4p9KdnqREN2AdO X-Proofpoint-GUID: urGeiPCiyzMhR8jjYf4p9KdnqREN2AdO Precedence: bulk List-ID: Commit 273df864cf746 ("ima: Check against blacklisted hashes for files with modsig") introduced an appraise_flag option for referencing the blacklist keyring. Any matching binary found on this keyring fails signature validation. This flag only works with module appended signatures. An important part of a PKI infrastructure is to have the ability to do revocation at a later time should a vulnerability be found. Expand the revocation flag usage to all appraisal functions. The flag is now enabled by default. Setting the flag with an IMA policy has been deprecated. Without a revocation capability like this in place, only authenticity can be maintained. With this change, integrity can now be achieved with digital signature based IMA appraisal. Signed-off-by: Eric Snowberg --- Documentation/ABI/testing/ima_policy | 6 +++--- security/integrity/ima/ima_appraise.c | 12 +++++++----- security/integrity/ima/ima_policy.c | 10 +++++----- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/Documentation/ABI/testing/ima_policy b/Documentation/ABI/testing/ima_policy index 49db0ff288e5..a712c396f6e9 100644 --- a/Documentation/ABI/testing/ima_policy +++ b/Documentation/ABI/testing/ima_policy @@ -57,9 +57,9 @@ Description: stored in security.ima xattr. Requires specifying "digest_type=verity" first.) - appraise_flag:= [check_blacklist] - Currently, blacklist check is only for files signed with appended - signature. + appraise_flag:= [check_blacklist] (deprecated) + Setting the check_blacklist flag is no longer necessary. + All apprasial functions set it by default. digest_type:= verity Require fs-verity's file digest instead of the regular IMA file hash. diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c index 491c1aca0b1c..870dde67707b 100644 --- a/security/integrity/ima/ima_appraise.c +++ b/security/integrity/ima/ima_appraise.c @@ -458,11 +458,13 @@ int ima_check_blacklist(struct integrity_iint_cache *iint, ima_get_modsig_digest(modsig, &hash_algo, &digest, &digestsize); rc = is_binary_blacklisted(digest, digestsize); - if ((rc == -EPERM) && (iint->flags & IMA_MEASURE)) - process_buffer_measurement(&nop_mnt_idmap, NULL, digest, digestsize, - "blacklisted-hash", NONE, - pcr, NULL, false, NULL, 0); - } + } else if (iint->flags & IMA_DIGSIG_REQUIRED && iint->ima_hash) + rc = is_binary_blacklisted(iint->ima_hash->digest, iint->ima_hash->length); + + if ((rc == -EPERM) && (iint->flags & IMA_MEASURE)) + process_buffer_measurement(&nop_mnt_idmap, NULL, digest, digestsize, + "blacklisted-hash", NONE, + pcr, NULL, false, NULL, 0); return rc; } diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index 3ca8b7348c2e..71e270141101 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -1279,7 +1279,7 @@ static bool ima_validate_rule(struct ima_rule_entry *entry) IMA_FSNAME | IMA_GID | IMA_EGID | IMA_FGROUP | IMA_DIGSIG_REQUIRED | IMA_PERMIT_DIRECTIO | IMA_VALIDATE_ALGOS | - IMA_VERITY_REQUIRED)) + IMA_CHECK_BLACKLIST | IMA_VERITY_REQUIRED)) return false; break; @@ -1354,7 +1354,7 @@ static bool ima_validate_rule(struct ima_rule_entry *entry) /* Ensure that combinations of flags are compatible with each other */ if (entry->flags & IMA_CHECK_BLACKLIST && - !(entry->flags & IMA_MODSIG_ALLOWED)) + !(entry->flags & IMA_DIGSIG_REQUIRED)) return false; /* @@ -1802,11 +1802,11 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) if (entry->flags & IMA_VERITY_REQUIRED) result = -EINVAL; else - entry->flags |= IMA_DIGSIG_REQUIRED; + entry->flags |= IMA_DIGSIG_REQUIRED | IMA_CHECK_BLACKLIST; } else if (strcmp(args[0].from, "sigv3") == 0) { /* Only fsverity supports sigv3 for now */ if (entry->flags & IMA_VERITY_REQUIRED) - entry->flags |= IMA_DIGSIG_REQUIRED; + entry->flags |= IMA_DIGSIG_REQUIRED | IMA_CHECK_BLACKLIST; else result = -EINVAL; } else if (IS_ENABLED(CONFIG_IMA_APPRAISE_MODSIG) && @@ -1815,7 +1815,7 @@ static int ima_parse_rule(char *rule, struct ima_rule_entry *entry) result = -EINVAL; else entry->flags |= IMA_DIGSIG_REQUIRED | - IMA_MODSIG_ALLOWED; + IMA_MODSIG_ALLOWED | IMA_CHECK_BLACKLIST; } else { result = -EINVAL; }