From patchwork Wed Jan 5 23:50:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 12704870 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 3A646C433F5 for ; Wed, 5 Jan 2022 23:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245663AbiAEXvu (ORCPT ); Wed, 5 Jan 2022 18:51:50 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:43462 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245574AbiAEXvG (ORCPT ); Wed, 5 Jan 2022 18:51:06 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 205N513Q032380; Wed, 5 Jan 2022 23:50:34 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=qhaiuoscMrCdKDZ5kfEtc647pOV6jruwyhnlcfy+kxg=; b=OpaZ6kufQ3BaPONm9NzSmvspjAoTeF835VO5u442lECPjkRnCFfp8NsUCP320f8Lsu1u mFxCfSRR2atINY9zQJZ2inl0T/8Qyc8VThDjIFy8UKSGvdZLaioPXxfGLgcn7MhRLno5 Xe4ERKYu+Wvyc+AfuzOVaImg95UmI82d3b1MPW9nCPzizeiOp3paAryCNDSTUPym5A0E FSGDaxrsEst+xmpwZh7emUnxXJuKs6BlDLcOSnzN0CJrabdjTq+ABBE0rNXbvQ/RVLv9 JSbHrmo/spJay/LP/xhq5FRfFKeVd50/N30X8oz+NkOBdVS55q4iZSaPQcwawn2KIoVg 3A== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ddmpjr228-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:34 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 205NjfZ3150022; Wed, 5 Jan 2022 23:50:33 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2170.outbound.protection.outlook.com [104.47.56.170]) by aserp3020.oracle.com with ESMTP id 3ddmqa1j7v-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:33 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M67h9JTd2dtEsoFj1knCDYNalp6jYBtou2mXYRtYnSQZGVxKC4cQq3ccBMLFGbpQAYgMikbh7ptdEpe6S5VVkakp6VXpxYMUsS3UajfljHKPREHwaQ/hmTAawh4zuoHeEeeyiUbSKYrY0FArr9yvejvGZ8qr1HOvFoNAjtWpLCTqK6OPOulLiDG3N+Zev/f588wUTmBPc2dqHoVWA07qm0rIC3ffyt8vAs4FeqkDOufez/cwdPMXhue5vbYIQA4FZf/dbcL7NawZC5XEIWURlpFYqP4+AEFbbJQ6A7jCeLTKpsqNstmxwa2h4b6XVDFItp45UArNbUFfk+QRFVW7tQ== 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=qhaiuoscMrCdKDZ5kfEtc647pOV6jruwyhnlcfy+kxg=; b=NYCf4XPU9th/yDFAvLuDSWU4gPplUil4S1awnMevz+pJK8HqN6HQEhRBhR0Uc3DwPA4AtG/AzJucwzRmSTj2H1P2PhE3VhNdrP/p9Xdy0tAxsJaCIq7/EmEkO1P3rQllcA6yP1VRHrGskCA+JpOD7GzEkgpegLudiw4IgPLjEsbvwJRsixXrh5LMgPoASgNGsLrFrmTM1MhP1yZfAEqMi6mriZalz5Deuxg92NSBeff0k3+bllpeTpHthJFNbD9NRy1vkK/GcdxhihiRLF6LxQTiKkS7+JJG0xzGJrGLFqCMQgKjiX0yI/ROfC6FPK3Z9FP5hQRIbighA9CUfa0k6A== 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=qhaiuoscMrCdKDZ5kfEtc647pOV6jruwyhnlcfy+kxg=; b=aSYzXYvls/woRL65AD1lA9NUsQqPFJZbctS2e+bk+4fXDu8A87dWcZWBXFilj2DVrZSskLFN8x24sguA0LwqWgUzQaRRMkkypiar21slfQE4Pat2Inw5EcLoKZRvEDDUmsAjqFsgKoaAs7AY1sB28fYVj+mPHNidN6se/k15bmo= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by CH0PR10MB5034.namprd10.prod.outlook.com (2603:10b6:610:c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Wed, 5 Jan 2022 23:50:32 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a%4]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 23:50:32 +0000 From: Eric Snowberg To: dhowells@redhat.com, dwmw2@infradead.org, ardb@kernel.org, jarkko@kernel.org Cc: jmorris@namei.org, serge@hallyn.com, eric.snowberg@oracle.com, nayna@linux.ibm.com, zohar@linux.ibm.com, keescook@chromium.org, torvalds@linux-foundation.org, weiyongjun1@huawei.com, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, pjones@redhat.com, konrad.wilk@oracle.com Subject: [PATCH v9 1/8] integrity: Fix warning about missing prototypes Date: Wed, 5 Jan 2022 18:50:05 -0500 Message-Id: <20220105235012.2497118-2-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220105235012.2497118-1-eric.snowberg@oracle.com> References: <20220105235012.2497118-1-eric.snowberg@oracle.com> X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 81dd07da-55c5-4faa-79c4-08d9d0a628f4 X-MS-TrafficTypeDiagnostic: CH0PR10MB5034:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:115; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Q5cgA3eYW9AgKOesWTDr4O7uV2S7WwSXX9k/D05H5yNxfpU6cXrlF+YPbzz9k/9Hh1KgK9oVfcjkhikuiUbJZx2HxqU3O1XES0kTyhWCkZ9U/Rgt/EOEUE0NAk4gvVCf8K5cpqgyBDgoDdEwyE507Ox+SkhOiPSgPRwNchYzJ0Hz+BX1RYrr2yjds1iELZqA3C2JALgQflpsL3ejkzgcAObUhLjfzvNYNQ1b1VE1FGFuczMa6Wj2wtTAHx2sUVpH05O119PorRxqlZvWu6z/sL8ThKTEnhs3YCroL6mwKCZ3u4q3CYsIEZqkACoguzJa0vfIkBiA8LuQkRlsk7bjsW2HYXvCh52w/DL5eDg6zSwAtaUCxa9yaERFW+7F+NEPJdjbHrtsIx87C2KvUqm8qGp/NFSCrQ4fgADDdFXpzVcoceZ5a8eI/sONN4H+Eksuk9VGXf54he6LsBzjLaxpRUfMUP0yGwgCEN8ZGsbQRJhzQNrdEaF+6CDSneZosO0D9hZkz2RoJuIjng+U8wYfQ6MEazrZ6uBUfzB1ctuZN/8n2fh3yRpLcOp7fHvUGBLbLuDNP8NJUTISuu7x3p48I/WGhl9nK4+De9J7nS0SAaFdf6qKtL3Bt342YtHB5xGfAyFLxhSjB/ayXPk2dNIpx6rWQpmKlWlyyM/+/9UtfHHlqSPAkr1o5lAf6TtT9LcvjnP3lhCdZDG3znSu/Eb0SA== 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:(366004)(186003)(6512007)(8676002)(316002)(2906002)(66556008)(6506007)(508600001)(8936002)(66476007)(52116002)(2616005)(86362001)(66946007)(4326008)(7416002)(36756003)(38100700002)(107886003)(6666004)(44832011)(26005)(6486002)(5660300002)(83380400001)(1076003)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2RmgVBnts3JAWLbKkC3CYGYK2Sxgjy4a0Zpfi1n0LaXTcEfsRL0FIrUJFJDc7anfwW0kHjz+fV5ccFU4ovSW3s5vvgMz+SAM19PuLa845wkhGBM55WnQean4AlpHvHcaE4HSb8FMulvg8PxiSvtQABtVzsbvtO7eC+vsel4My1nqSFoT6LXB4Lu9SOE2cgwGU6x9PO2rf0pWIbeMThhDQyVQ0hhwKONgzfRS831P+QrsSGQW9ygP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Uu9+16LfOQ91cB7G6H/gaSz2rlP0VxcwQC4Ub0RqypN6ae5OuFcR8JHf5jqcKjeBr/K1ZlUdVq8fkLOC8CqbxzgKPgVmZR+2fBEUqh51lF4ItlFeuIu4EdRVGnX443ySG3cdSgzJhdExKq40xdSWdgI4s7kPoCxsY9fzrP/sctasvX+Cj9H3K2LV6DSH4KgZgYK2cyzbfpSRHJM/05sLaR/+YC36SEgaMn2DQw7L5DOH5T7Y5PFLbywCpnCcKNSCS0B8AP9+Ozqkfzq0Tn25bOsiY8nYyEFtSWOEDPBSkEuIA5UPgNGQ0V4YsRtzXe+t3oG4cfXjzAIm3FJNC68oarqw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81dd07da-55c5-4faa-79c4-08d9d0a628f4 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 23:50:32.0987 (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: Zk/jPpS8+6E0vLfstfN9jkUH0b6orpOc/nkcr2q7DIME6H2R5LFyUGoJOhI0SrNeAzEEaygH9rKWjSltlOUXDae8Cwex9N2XDOj/3b+Fn+A= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5034 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10218 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2112160000 definitions=main-2201050150 X-Proofpoint-ORIG-GUID: K-YdHiGYpLdAEuftd6HeGCBRoH3JxaGu X-Proofpoint-GUID: K-YdHiGYpLdAEuftd6HeGCBRoH3JxaGu Precedence: bulk List-ID: make W=1 generates the following warning in keyring_handler.c security/integrity/platform_certs/keyring_handler.c:71:30: warning: no previous prototype for get_handler_for_db [-Wmissing-prototypes] __init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type) ^~~~~~~~~~~~~~~~~~ security/integrity/platform_certs/keyring_handler.c:82:30: warning: no previous prototype for get_handler_for_dbx [-Wmissing-prototypes] __init efi_element_handler_t get_handler_for_dbx(const efi_guid_t *sig_type) ^~~~~~~~~~~~~~~~~~~ Add the missing prototypes by including keyring_handler.h. Reported-by: kernel test robot Signed-off-by: Eric Snowberg Reviewed-by: Mimi Zohar Reviewed-by: Jarkko Sakkinen --- v7: Initial version v8: Code unmodified from v7 added Mimi's Reviewed-by v9: Unmodified from v8 --- security/integrity/platform_certs/keyring_handler.c | 1 + 1 file changed, 1 insertion(+) diff --git a/security/integrity/platform_certs/keyring_handler.c b/security/integrity/platform_certs/keyring_handler.c index 5604bd57c990..e9791be98fd9 100644 --- a/security/integrity/platform_certs/keyring_handler.c +++ b/security/integrity/platform_certs/keyring_handler.c @@ -9,6 +9,7 @@ #include #include #include "../integrity.h" +#include "keyring_handler.h" static efi_guid_t efi_cert_x509_guid __initdata = EFI_CERT_X509_GUID; static efi_guid_t efi_cert_x509_sha256_guid __initdata = From patchwork Wed Jan 5 23:50:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 12704872 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 2A799C4321E for ; Wed, 5 Jan 2022 23:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245688AbiAEXvz (ORCPT ); Wed, 5 Jan 2022 18:51:55 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:44396 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245577AbiAEXvG (ORCPT ); Wed, 5 Jan 2022 18:51:06 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 205N4xkU009805; Wed, 5 Jan 2022 23:50:38 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=QMEi5O3Jl5Afjymh1AR4uk3WdVIfSf7Sv5iPeWL0JkQ=; b=YUDQFF0pO8LsmJevMQ+lRMfcjGLk8+YtQm4l7FIodg3uykmV+phm3EVrgM0V9xRAwzu9 MXSsyGm0yBqoOuG/eAwS4+1AeXF889GCVWMgxmocKMD8oSFtuLpbQxX2sQSzrdCJT5EW H90idhtdQ0uqpNM6fFH0iAUgcmlCBgkTTtLlAE5fu15MPurHTcv9qzGi6f1oeeStvVYk MD9UdLqWW01mFtL6GVdat2qAMPqARsyaEODDyjk/GLkqQ/clDgzjGH9CulEWUthx17ZQ K8JQqozzsgaJEu2eVEe06ycO0VL0KGouS4N88z7uPa+F9KLPef2Ay1y3YYAPa+kow6iC Ew== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ddmpp81yt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:37 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 205NjHnR177004; Wed, 5 Jan 2022 23:50:36 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2044.outbound.protection.outlook.com [104.47.74.44]) by userp3020.oracle.com with ESMTP id 3ddmq5shb6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:36 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jwjr84a5/PlYxQ92ahUB9ilmDypAEK1XUb0JoYEKMFjs6tCvFZ3mzW9kllwBUlB2uYqOIIbF2TMKBpVSF2zv2zPeJL3OBRPk/FBktaVyw3jpUVg6IkIhi3gDDweJ2O99MXwgdJHIrnebcZIJQ0w+nkNthjxsuhUpOuZoqWrQFhS0L1U5re/jFXPd6AqUcVteMw2FcOR9iogKAmdwQ1bxmYa6cP4zt296jhAgD/eMOeM6voSLicpqi9TFO8K/W11Q2Deppp55RCwZ9i0R/OFO7vSw8lpheU5qW7Egz1Og+PW7R//uNIwKiudDkRZJv4GOgEx5oGbf2vgpu5IdET21JQ== 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=QMEi5O3Jl5Afjymh1AR4uk3WdVIfSf7Sv5iPeWL0JkQ=; b=JIRS5t6JfL7fQpNK1AryL1yJIg4BHWmI7iTXW6IALJqdVUbrpIFnFb/Cm2pgdQlYzDHdxavEhFTPr/FSwq2Efa69OyQ7059ykN5v/KZU+aIKAS75MQUNTcvCy5B20Ygo7u8VRqkdPYA9AL8QlGTC0YvHUcGDeYItIJEdWonyK6TSmAaA3hxGiqdD6tY6zzB6TMOBpb5ERecrsRjc+wNMRO4L2HS5JvV0nt/I0jjci38gAKDSd8jGS+zv8vxdY7OBA7R4MhcbDjq2lXjy4AZKzb8hD4z6nbLg0+oVsXhThWAf0dmIgK2UCmpAeEuj+5ZpIBnHyqpB1t5PpVN4Wgq9Gw== 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=QMEi5O3Jl5Afjymh1AR4uk3WdVIfSf7Sv5iPeWL0JkQ=; b=hxZy+vM2gsOrmyQ2EMYQKYbhOr6qNzAcgKkTQPd1zh10cXYrahIq3c6X/NLRita2Mg7RY0Ee4Tg4W39fUrh9JdNT1wsWbgVbBX6t248ozuqkhYfo8ehmOE72aLQqBBK5tn8T8D3R75eUpmyrgVxcZ3wr9OU89oq4otICiTegLrs= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by CH0PR10MB5034.namprd10.prod.outlook.com (2603:10b6:610:c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Wed, 5 Jan 2022 23:50:34 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a%4]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 23:50:34 +0000 From: Eric Snowberg To: dhowells@redhat.com, dwmw2@infradead.org, ardb@kernel.org, jarkko@kernel.org Cc: jmorris@namei.org, serge@hallyn.com, eric.snowberg@oracle.com, nayna@linux.ibm.com, zohar@linux.ibm.com, keescook@chromium.org, torvalds@linux-foundation.org, weiyongjun1@huawei.com, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, pjones@redhat.com, konrad.wilk@oracle.com Subject: [PATCH v9 2/8] integrity: Introduce a Linux keyring called machine Date: Wed, 5 Jan 2022 18:50:06 -0500 Message-Id: <20220105235012.2497118-3-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220105235012.2497118-1-eric.snowberg@oracle.com> References: <20220105235012.2497118-1-eric.snowberg@oracle.com> X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4cf19a74-817c-4b4a-043b-08d9d0a62a26 X-MS-TrafficTypeDiagnostic: CH0PR10MB5034:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6790; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oD7gbShQI75/HawdJXm0cZQH3zSSxO7WE+9uPz7mOwodBwrqQCcms/z7o247VVGahthhDQae8+2HhDT9bGXV0sgfVTOuxQkVm6aXEIOhjsOYHjQBXvr06QEdla2QA9Zen1tMkk1ZPYp9YfKgeDZBeJESniqacE44LnpzyCmsrF3ZE4RR7NZdrjvZ54h0FeJYocfHzXsO8hqTWjdg5v3mFNrxrydwYpuykCaL34QXOpV4ffQt7RN+Q3do93MQjYfX8VPgzp5JDkPTL3R6Dt8pqrtWeO1AYkk5SgMUniKhiDxLGahaUI7SICJ2G0H7Ym+EzRQ7Sa8xpPvIkN0kq+WwWFP3fEClcd4ozG9WqBYdA89bqAl2z207EM2s6L0LY4rnmoJKcFCmwLjIgiSN23yNdvDtBtDWNCvroN21UieCu/ZZJ7IYerl30jkt0D+OO6plW7nj49dQkO2P6KZutboIUhZ7esp7o8WruC7c4nVX7tD60N37tITcCTzEWHYkHBW0Zqmb+UgAKWA3qN/Gxk2gt92Gd3LsZFnjTg1FGtybHzZbxqwxRTNqdVYJtEfTcXGTbRakSmnMffaog8DFdHLc9DeY7UfyuSB8fVEeIAUwx82PucbiFWThZvwvqc4qzdkyuLWIe6+kyYdlJtY4ySluVQfJFzwNYAVYjGmjQFMVXX4rYao9Qs3uB6ZUht/KVVUSj2HvnVVT9Ttc3L/HaMD5PQ== 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:(366004)(186003)(6512007)(8676002)(316002)(2906002)(66556008)(6506007)(508600001)(8936002)(66476007)(52116002)(2616005)(86362001)(66946007)(4326008)(7416002)(36756003)(38100700002)(107886003)(6666004)(44832011)(26005)(6486002)(5660300002)(83380400001)(1076003)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: UEcPBf8x38qO6zvTBQyKx4hjAh1yluTTTST0yh7xM/TFxVLeSOyKKNtAKaa6UFtggCPSNob0mcKnYsrXl69hlloABlQYhW/2OglfsTbT8/JeDxe10XW64AHVkHL1gRb9kpbVdd9RMlwNUpVpLrgbGGi/UPxkNiEkLV8+W+XE2tgyNjKif8iXWufdycBjwzZWhvKiIQJeunJcmLuUv3AYPatLJ289GqZ2ExTGtYgKBfRpjqJ27H8UHmx1Z+QnLaSO0lBEgbNaO6Z+55HNy3/6E9GJB23BsQdMM5pPhNdukHpIEt/GbyElNooAWF+gByQ3eJkvjLrTGAtwQOMhcEpmQQHl9gfqGcx2w17rNxNVU0+OWyJFC+RY2S2fvWDc7tlHVNwdSaJLmmoVS/CNctyXkW5cPj07Jr47hKqLyycIx1GLSsP00zzdJLhenlqODFD+yAF7iSGQw4sZ86uuNridgpHve1Wu6La9TINet/XPoajCwCWEzDiuDWXoL9AGpB7UMPzNTc50X8Rxz1ecO/PDMZEZUgpB9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4lfHXwYG7/z8Mem+hMq4Bn+w9jGgxMRgWGH+1Zqlwf7prN1EN7JW2+esulcA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4cf19a74-817c-4b4a-043b-08d9d0a62a26 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 23:50:34.2105 (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: 63ExE4Lj9hxCb7pVKJOsJHORu79CMUkqGod1pGqaQlAiP92DBl8lQwDPeBrfYmyHLwK9rZA8PxP+/K7csNvQ7pSGJEmhyQY8pBGYXg5JXaA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5034 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10218 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=730 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2112160000 definitions=main-2201050150 X-Proofpoint-ORIG-GUID: _G7SDdvkmCFLEdSrAsfR0wWBY89J13q0 X-Proofpoint-GUID: _G7SDdvkmCFLEdSrAsfR0wWBY89J13q0 Precedence: bulk List-ID: Many UEFI Linux distributions boot using shim. The UEFI shim provides what is called Machine Owner Keys (MOK). Shim uses both the UEFI Secure Boot DB and MOK keys to validate the next step in the boot chain. The MOK facility can be used to import user generated keys. These keys can be used to sign an end-users development kernel build. When Linux boots, both UEFI Secure Boot DB and MOK keys get loaded in the Linux .platform keyring. Define a new Linux keyring called machine. This keyring shall contain just MOK CA keys and not the remaining keys in the platform keyring. This new machine keyring will be used in follow on patches. Unlike keys in the platform keyring, keys contained in the machine keyring will be trusted within the kernel if the end-user has chosen to do so. Signed-off-by: Eric Snowberg Tested-by: Jarkko Sakkinen --- v1: Initial version v2: Removed destory keyring code v3: Unmodified from v2 v4: Add Kconfig, merged in "integrity: add add_to_mok_keyring" v5: Rename to machine keyring v6: Depend on EFI in kconfig (suggested by Mimi) Test to see if ".platform" keyring is configured in add_to_machine_keyring (suggested by Mimi) v7: Depend on LOAD_UEFI_KEYS instead EFI for mokvar code v8: Code unmodified from v7 added Mimi's Reviewed-by v9: Removed Reviewed-by. Prevent IMA from being able to use the machine keyring since the CA restrictions have been removed. --- security/integrity/Kconfig | 13 ++++++ security/integrity/Makefile | 1 + security/integrity/digsig.c | 13 +++++- security/integrity/integrity.h | 12 +++++- .../platform_certs/machine_keyring.c | 42 +++++++++++++++++++ 5 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 security/integrity/platform_certs/machine_keyring.c diff --git a/security/integrity/Kconfig b/security/integrity/Kconfig index 71f0177e8716..de02964dd421 100644 --- a/security/integrity/Kconfig +++ b/security/integrity/Kconfig @@ -62,6 +62,19 @@ config INTEGRITY_PLATFORM_KEYRING provided by the platform for verifying the kexec'ed kerned image and, possibly, the initramfs signature. +config INTEGRITY_MACHINE_KEYRING + bool "Provide a keyring to which CA Machine Owner Keys may be added" + depends on SECONDARY_TRUSTED_KEYRING + depends on INTEGRITY_ASYMMETRIC_KEYS + depends on SYSTEM_BLACKLIST_KEYRING + depends on LOAD_UEFI_KEYS + depends on !IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY + help + If set, provide a keyring to which CA Machine Owner Keys (MOK) may + be added. This keyring shall contain just CA MOK keys. Unlike keys + in the platform keyring, keys contained in the .machine keyring will + be trusted within the kernel. + config LOAD_UEFI_KEYS depends on INTEGRITY_PLATFORM_KEYRING depends on EFI diff --git a/security/integrity/Makefile b/security/integrity/Makefile index 7ee39d66cf16..d0ffe37dc1d6 100644 --- a/security/integrity/Makefile +++ b/security/integrity/Makefile @@ -10,6 +10,7 @@ integrity-$(CONFIG_INTEGRITY_AUDIT) += integrity_audit.o integrity-$(CONFIG_INTEGRITY_SIGNATURE) += digsig.o integrity-$(CONFIG_INTEGRITY_ASYMMETRIC_KEYS) += digsig_asymmetric.o integrity-$(CONFIG_INTEGRITY_PLATFORM_KEYRING) += platform_certs/platform_keyring.o +integrity-$(CONFIG_INTEGRITY_MACHINE_KEYRING) += platform_certs/machine_keyring.o integrity-$(CONFIG_LOAD_UEFI_KEYS) += platform_certs/efi_parser.o \ platform_certs/load_uefi.o \ platform_certs/keyring_handler.o diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c index 3b06a01bd0fd..2b7fa85613c0 100644 --- a/security/integrity/digsig.c +++ b/security/integrity/digsig.c @@ -30,6 +30,7 @@ static const char * const keyring_name[INTEGRITY_KEYRING_MAX] = { ".ima", #endif ".platform", + ".machine", }; #ifdef CONFIG_IMA_KEYRINGS_PERMIT_SIGNED_BY_BUILTIN_OR_SECONDARY @@ -126,7 +127,8 @@ int __init integrity_init_keyring(const unsigned int id) perm = (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW | KEY_USR_READ | KEY_USR_SEARCH; - if (id == INTEGRITY_KEYRING_PLATFORM) { + if (id == INTEGRITY_KEYRING_PLATFORM || + id == INTEGRITY_KEYRING_MACHINE) { restriction = NULL; goto out; } @@ -139,7 +141,14 @@ int __init integrity_init_keyring(const unsigned int id) return -ENOMEM; restriction->check = restrict_link_to_ima; - perm |= KEY_USR_WRITE; + + /* + * MOK keys can only be added through a read-only runtime services + * UEFI variable during boot. No additional keys shall be allowed to + * load into the machine keyring following init from userspace. + */ + if (id != INTEGRITY_KEYRING_MACHINE) + perm |= KEY_USR_WRITE; out: return __integrity_init_keyring(id, perm, restriction); diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h index 547425c20e11..730771eececd 100644 --- a/security/integrity/integrity.h +++ b/security/integrity/integrity.h @@ -151,7 +151,8 @@ int integrity_kernel_read(struct file *file, loff_t offset, #define INTEGRITY_KEYRING_EVM 0 #define INTEGRITY_KEYRING_IMA 1 #define INTEGRITY_KEYRING_PLATFORM 2 -#define INTEGRITY_KEYRING_MAX 3 +#define INTEGRITY_KEYRING_MACHINE 3 +#define INTEGRITY_KEYRING_MAX 4 extern struct dentry *integrity_dir; @@ -283,3 +284,12 @@ static inline void __init add_to_platform_keyring(const char *source, { } #endif + +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +void __init add_to_machine_keyring(const char *source, const void *data, size_t len); +#else +static inline void __init add_to_machine_keyring(const char *source, + const void *data, size_t len) +{ +} +#endif diff --git a/security/integrity/platform_certs/machine_keyring.c b/security/integrity/platform_certs/machine_keyring.c new file mode 100644 index 000000000000..ea2ac2f9f2b5 --- /dev/null +++ b/security/integrity/platform_certs/machine_keyring.c @@ -0,0 +1,42 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Machine keyring routines. + * + * Copyright (c) 2021, Oracle and/or its affiliates. + */ + +#include "../integrity.h" + +static __init int machine_keyring_init(void) +{ + int rc; + + rc = integrity_init_keyring(INTEGRITY_KEYRING_MACHINE); + if (rc) + return rc; + + pr_notice("Machine keyring initialized\n"); + return 0; +} +device_initcall(machine_keyring_init); + +void __init add_to_machine_keyring(const char *source, const void *data, size_t len) +{ + key_perm_t perm; + int rc; + + perm = (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_VIEW; + rc = integrity_load_cert(INTEGRITY_KEYRING_MACHINE, source, data, len, perm); + + /* + * Some MOKList keys may not pass the machine keyring restrictions. + * If the restriction check does not pass and the platform keyring + * is configured, try to add it into that keyring instead. + */ + if (rc && IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING)) + rc = integrity_load_cert(INTEGRITY_KEYRING_PLATFORM, source, + data, len, perm); + + if (rc) + pr_info("Error adding keys to machine keyring %s\n", source); +} From patchwork Wed Jan 5 23:50:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 12704874 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 9BFB0C433F5 for ; Wed, 5 Jan 2022 23:52:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245710AbiAEXwE (ORCPT ); Wed, 5 Jan 2022 18:52:04 -0500 Received: from mx0a-00069f02.pphosted.com ([205.220.165.32]:21086 "EHLO mx0a-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245546AbiAEXvK (ORCPT ); Wed, 5 Jan 2022 18:51:10 -0500 Received: from pps.filterd (m0246629.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 205N58RZ007603; Wed, 5 Jan 2022 23:50:39 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=85t9lE45oZAdWhOwZN7c5wL/sqiZsyYbYkitWW+aeUA=; b=ZDWeV8Q2Hnra/ot4wy9w3SjWpNvRZ+SZaXiA6Lku1RQBlUOHWunBe6kfMARDIOZ1bAKX ojinFbjO7MBWTJ8NnOJmU1QpCK5boSHAdi4zgVYw3uictWGhdT9qJwjXnfCIhjbMchpC adCdi7JQcxGryuqwi4h9jggy5ssN/BLpOd3Qoqx4yQzMYMzd9rEMkKK7o+/wPVvnuRmw DXk7+wBLiAtPgA3nIsd6YotciFFjG64opVhDDSkVhiWlQ2FWf67Srb4T2Xco5EtgXfjf 8Im7NEf7KUoGTDiKZiR+XzbWfqTcrvAcJ3w4MA7V39CoCINnPF3rMgE65sGACvnQOeqE wQ== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ddmpm0203-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:39 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 205NjfZ6150022; Wed, 5 Jan 2022 23:50:38 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2042.outbound.protection.outlook.com [104.47.74.42]) by aserp3020.oracle.com with ESMTP id 3ddmqa1jc8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SLft5uXKecdY2z6IXzdstBu7uwPHOM104T/yqbOh6lbZiv7K8yzINP4+ww0MBsayjdbl2SFlFHJmz0olSNP10duHdqRtp8iwqaC8IEyUErnwzX9dmYMKfjycwJmXieq3mrMm0Lbl0rl1HVGuhJ3TsvT3eccD27+You2qpO07DMk1K96pm0Srb6QVI2fieXTrWh9Lfr93IsQPbvxfvd6MNmvQ59FChPZhVhAy6S6foUK4VtgOcTCQz7Jsb2ZppDSSUvEWi33vb1EuguFscN5NU06nAO2CwxkfSc+bN1plYuEo2U+7Vg3j1PJyVDZx9wN/wXILh0WHEfhuLcQXW0tX+A== 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=85t9lE45oZAdWhOwZN7c5wL/sqiZsyYbYkitWW+aeUA=; b=YjRRhzcVzoggVyxf3d/8liX9/MO++uv/F31Py8wfsEgZd5nUgIfJseJCoJGo2afpvPWan6pTdE/5IItdYaSogE/HAvVULRrJeNaCHB3vz/jvwvxNyehMRIk20pQa22KFG2M1gNvqAdgsP0kyWlmJiSTTT0wbjgT3GyBIlRKZqqL1vfsXHdfDxft4IOCdiqBwwqOgqybh+1pr2rRICjxvGPEtfi6dY/BOBOcfCh/d1lTqeCAS7W+8f7VP3yiBXQj+tRl18suVkE7WjYlV5STqtVtJct3ZYrViVbWLBSoB+SQE0T9Kflob4tTBEQ1UMp+kFE5jfK/rjnYmuGjdqPB4Cg== 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=85t9lE45oZAdWhOwZN7c5wL/sqiZsyYbYkitWW+aeUA=; b=oiaJPBlWa2sZEVOCEsApksxOZKrc7LktBk6GF6xGcDQGLKysjs7ITpxGr8d4xZpmk6G9n0AfSV2hZDV6hTrduXvAvr+IxDGtCPqCB8S26aYJD3TGjfWtQl1vwVQkL8tXYVvQlf8txp2YXoOl95NsRYvAeXIg5cEPrXVp3mh5ffg= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by CH0PR10MB5034.namprd10.prod.outlook.com (2603:10b6:610:c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Wed, 5 Jan 2022 23:50:36 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a%4]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 23:50:36 +0000 From: Eric Snowberg To: dhowells@redhat.com, dwmw2@infradead.org, ardb@kernel.org, jarkko@kernel.org Cc: jmorris@namei.org, serge@hallyn.com, eric.snowberg@oracle.com, nayna@linux.ibm.com, zohar@linux.ibm.com, keescook@chromium.org, torvalds@linux-foundation.org, weiyongjun1@huawei.com, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, pjones@redhat.com, konrad.wilk@oracle.com Subject: [PATCH v9 3/8] integrity: add new keyring handler for mok keys Date: Wed, 5 Jan 2022 18:50:07 -0500 Message-Id: <20220105235012.2497118-4-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220105235012.2497118-1-eric.snowberg@oracle.com> References: <20220105235012.2497118-1-eric.snowberg@oracle.com> X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 903d22aa-4355-4c40-4ab6-08d9d0a62b76 X-MS-TrafficTypeDiagnostic: CH0PR10MB5034:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7RVa7+gISnrQSomBnnCWhwgZ+B9HJolyOFoQUJaAHvrvMJXVywYWJb1MC+fC70w7FHSXPl6KjXYfYYuTyyNPNqUGJbcLSesGzT176sXz3nZIeOOI1YU/KalP4YGNCJcu1RZsjoIrtXZtjo/MXK8PaPzs2C5XI+UMLyL+eTtWdBmlv+xd6AeN9TD4hF62OtmmnNuvDhdwOwMmqDfQRcTcBcj8B8MISGd5x1IHHDKUzTAeHMSBjrPK9VycF8od18tVLBVDIukBI7ETmZye1fZWel2XijGrPIC4u8NhPYEDSwMN3vWIp5P3u4shYbwd+DVQLpzuwY61cZszXdtkDsRf525qu2RjaZBVjHjrkzqLF5Eosk6pc/sGW4wAarliF1XOCpuNlHGCJEp94CwcBzdL81sIlv7ZS31ZXDBkFAqFptnpXUoNbEND9PY2T6f/xSCCBVUvOovGwf01nW3JagYgccUkJJ9UONPmt6tw3vkhZOI8YF2ViomFCI/VZwO6H7CBeb4AEeM344dagE24JbSLBSCqZFFqaaM2wCBA/4Yd3CwFo1cViVqRlHkUGYKEneGEmfVpSbONMxjzeaJgu1djM3rSPvXi7Y7wZ2ktY2OJVRUL8AYyCF6qtboZHmMrmeZOcOC+GHqzLk++SlP37o/o1TciVQhoTQ4EQEmXeavtuOqHVKBlpF/b6v7yVMgzsuGUuAHtsusmLdiIrjYVlMGY7Q== 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:(366004)(186003)(6512007)(8676002)(316002)(2906002)(66556008)(6506007)(508600001)(8936002)(66476007)(52116002)(2616005)(86362001)(66946007)(4326008)(7416002)(36756003)(38100700002)(107886003)(6666004)(44832011)(26005)(6486002)(5660300002)(83380400001)(1076003)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0GByRbHJ7gjJgu0ULA5LPqdM9adGJMK7qrbcOZ+jO1Uor8oM24bEAH3VQ+7ues8xHWjBqtsjWLjgNj5SbV84V0Ve9WtdlpoXQR/fX4iTDruWJ5AsycptnYVIkbju4RmBxGbdH2xif51gcOLfVma1ZPItVHePAVvqZdMULFKSmlD738pr02jA3RnV40tG0M7EYfxbMTnUFm6u/pWbXL9Hnfv00l/y6qigTyB6bNQ259OHxoAs1GzLvyPy3tD03/EMYPTJmmjNPpWtA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BzJymcK9+QTMutEguf/8B7ieEicfHWg6YHisqxI/D4Q8spKj6Th+cRVJ3iqkhKlux2iKZRXyc51BarG/1X7/vQ6pD5LN+vySCmhpL8fBcV4LfRGWQrI5sg5MxJDq07B2tSE7UOKx9UINAiuS/+ZGAtQDleOJblMSAEpNT642NjMsCsfdmrnsaZlARXhtn4JCf/muVgyi0XPNF9SOR9IBErZZnRd12hI5ApKFsvrgzJP6nioL5htN35v2oBJvJT7NMgJaUkP9+NznINbrATLRNpnooOluJ1UaUVJoapUlnNaYVAaPKr7q3RTezbKpnhbr34+YIa9lKEmwUXN84FXw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 903d22aa-4355-4c40-4ab6-08d9d0a62b76 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 23:50:36.3363 (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: rSAOTmj5RqjxGt14nwmUEWOnDBGrevngQmAVnXShAu8wER/WcXgmTcElc6QqQpB1wuPNv6fuxJK6QWC4qJ9VKcT61rbbBYTfUJ+tnIGKOyw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5034 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10218 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=687 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2112160000 definitions=main-2201050150 X-Proofpoint-ORIG-GUID: i-y_TEd-lIPWUFQip77lv0sAyt_GRKHB X-Proofpoint-GUID: i-y_TEd-lIPWUFQip77lv0sAyt_GRKHB Precedence: bulk List-ID: Currently both Secure Boot DB and Machine Owner Keys (MOK) go through the same keyring handler (get_handler_for_db). With the addition of the new machine keyring, the end-user may choose to trust MOK keys. Introduce a new keyring handler specific for MOK keys. If MOK keys are trusted by the end-user, use the new keyring handler instead. Signed-off-by: Eric Snowberg Reviewed-by: Mimi Zohar Reviewed-by: Jarkko Sakkinen --- v1: Initial version v3: Only change the keyring handler if the secondary is enabled v4: Removed trust_moklist check v5: Rename to machine keyring v7: Unmodified from v5 v8: Code unmodified from v7 added Mimi's Reviewed-by v9: Unmodified from v8 --- .../integrity/platform_certs/keyring_handler.c | 17 ++++++++++++++++- .../integrity/platform_certs/keyring_handler.h | 5 +++++ security/integrity/platform_certs/load_uefi.c | 4 ++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/security/integrity/platform_certs/keyring_handler.c b/security/integrity/platform_certs/keyring_handler.c index e9791be98fd9..4872850d081f 100644 --- a/security/integrity/platform_certs/keyring_handler.c +++ b/security/integrity/platform_certs/keyring_handler.c @@ -67,7 +67,7 @@ static __init void uefi_revocation_list_x509(const char *source, /* * Return the appropriate handler for particular signature list types found in - * the UEFI db and MokListRT tables. + * the UEFI db tables. */ __init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type) { @@ -76,6 +76,21 @@ __init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type) return 0; } +/* + * Return the appropriate handler for particular signature list types found in + * the MokListRT tables. + */ +__init efi_element_handler_t get_handler_for_mok(const efi_guid_t *sig_type) +{ + if (efi_guidcmp(*sig_type, efi_cert_x509_guid) == 0) { + if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING)) + return add_to_machine_keyring; + else + return add_to_platform_keyring; + } + return 0; +} + /* * Return the appropriate handler for particular signature list types found in * the UEFI dbx and MokListXRT tables. diff --git a/security/integrity/platform_certs/keyring_handler.h b/security/integrity/platform_certs/keyring_handler.h index 2462bfa08fe3..284558f30411 100644 --- a/security/integrity/platform_certs/keyring_handler.h +++ b/security/integrity/platform_certs/keyring_handler.h @@ -24,6 +24,11 @@ void blacklist_binary(const char *source, const void *data, size_t len); */ efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type); +/* + * Return the handler for particular signature list types found in the mok. + */ +efi_element_handler_t get_handler_for_mok(const efi_guid_t *sig_type); + /* * Return the handler for particular signature list types found in the dbx. */ diff --git a/security/integrity/platform_certs/load_uefi.c b/security/integrity/platform_certs/load_uefi.c index f290f78c3f30..c1bfd1cd7cc3 100644 --- a/security/integrity/platform_certs/load_uefi.c +++ b/security/integrity/platform_certs/load_uefi.c @@ -94,7 +94,7 @@ static int __init load_moklist_certs(void) rc = parse_efi_signature_list("UEFI:MokListRT (MOKvar table)", mokvar_entry->data, mokvar_entry->data_size, - get_handler_for_db); + get_handler_for_mok); /* All done if that worked. */ if (!rc) return rc; @@ -109,7 +109,7 @@ static int __init load_moklist_certs(void) mok = get_cert_list(L"MokListRT", &mok_var, &moksize, &status); if (mok) { rc = parse_efi_signature_list("UEFI:MokListRT", - mok, moksize, get_handler_for_db); + mok, moksize, get_handler_for_mok); kfree(mok); if (rc) pr_err("Couldn't parse MokListRT signatures: %d\n", rc); From patchwork Wed Jan 5 23:50:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 12704868 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 5F5E1C433EF for ; Wed, 5 Jan 2022 23:51:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245642AbiAEXvo (ORCPT ); Wed, 5 Jan 2022 18:51:44 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:40994 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245573AbiAEXvG (ORCPT ); Wed, 5 Jan 2022 18:51:06 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 205N50uP026084; Wed, 5 Jan 2022 23:50:41 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=FNOc3EZPudjSqWJajjAI5Xe/ScJLWHq6HO14BAVi8g8=; b=cLS4ImK+CtTq7h9R3TJQhKlfBmxB+Dmp61JeSY0dgWFN1+r+KgRajFa5J8E/yO2Ly2Wd BQksJDbzvf/TRYp6JyPb/A04eiPTNDI/R3LFt6PyGz1fXRwFmbp8C+cw05UMpjjG3BmU aoJj6zhAn+o2i7uTVpD7FJYXYDNqGB+5S2uuhn9e+4foCC+a9R2kg361jpXoGOddFIsd 78nJLWTUQrlLnLorUwTM75zO1QaBOxhmW5U2pXb3uPT4di4xVfGkmTkL/rkIYOiIeNfb KqAqHDFclXNt+7LCAQiRaVOgFyYG2xZvV7alzGuGWI5+QKynYJzPhPqEZHEwHQm0crO+ eQ== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by mx0b-00069f02.pphosted.com with ESMTP id 3ddmpmg202-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:41 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 205No7Kc191080; Wed, 5 Jan 2022 23:50:40 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2047.outbound.protection.outlook.com [104.47.74.47]) by aserp3030.oracle.com with ESMTP id 3ddmqgsh94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bqGhNtg0T4PWVErVBX0ICR2VODCqyrYJ9yuAB4f1+RlQSvOEMjAFWz3PeP+UkSpLc6FYZvNmzNw6vqxabiJkWeAHU87z3iMYeWyn7hL4BZJegQ3kgtyGJFBKbeivTGMtaEFu8I/VzT480C3PRTAq/NTUSeX4jfy+VdBYlZ9Cf1sDIOiqnjH8GkRAHLi7QILeF5MlKIJIOOjQUAmuGK8Jd8/RWP9QXsnTdzDDkAWU3Wt5Vbfd1Zao+CCpKgHVlSSXd1w1EnwndkB7ci3E5EJvkmW0AHJvuak/2VtVmbM/UC4MAwMErtdTO3aYTneX5rxotgCQAHDCmrMHzg+cWQFVCg== 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=FNOc3EZPudjSqWJajjAI5Xe/ScJLWHq6HO14BAVi8g8=; b=JZrD/XWMS1HTrbowqidlJmzL4wCovt5/zrcjJE22RQHdL71GrezhVAUdQFGo4+MVeM28m2R6lxiFlPZLWLJieHKKFyL9VC+n3hwgigxuR6qkjkQNGPNN8929k3JaBpXRD2uerHWYzX4YC1ZzkElNueigmpafH6wmlVNKsksv3jh9Xap0ashncnJADsKazOLjiPvFUCLe6h5055D0vGcDE17U7D1FwlEBYgaQJTzUlQl0ZY7tXNrb8YdOtPiyoMoCk4u99NC2EoYQo1tAdUQj9myMMr+VdePl01Sfrq/dnQpQ94bGwG2FbL/OIsTMSkXJZVEerTCcVBTyEwyTHxlGew== 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=FNOc3EZPudjSqWJajjAI5Xe/ScJLWHq6HO14BAVi8g8=; b=U4cxlmlmOy90QQohzozYaNnvJXYPgDBIWzK1LKEl5tSosCnHJk/hxRqyYPT/5U+mIiHMH03Lw272YLs5aOnV0C+FVgBpc736vRNIdthiVywuZHQ/KREdsn1rN/czQo0hEH3elg922mr6SYJ91V99WkQxfGb5NPEBwKCB5wjRmDY= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by CH0PR10MB5034.namprd10.prod.outlook.com (2603:10b6:610:c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Wed, 5 Jan 2022 23:50:38 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a%4]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 23:50:38 +0000 From: Eric Snowberg To: dhowells@redhat.com, dwmw2@infradead.org, ardb@kernel.org, jarkko@kernel.org Cc: jmorris@namei.org, serge@hallyn.com, eric.snowberg@oracle.com, nayna@linux.ibm.com, zohar@linux.ibm.com, keescook@chromium.org, torvalds@linux-foundation.org, weiyongjun1@huawei.com, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, pjones@redhat.com, konrad.wilk@oracle.com Subject: [PATCH v9 4/8] KEYS: store reference to machine keyring Date: Wed, 5 Jan 2022 18:50:08 -0500 Message-Id: <20220105235012.2497118-5-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220105235012.2497118-1-eric.snowberg@oracle.com> References: <20220105235012.2497118-1-eric.snowberg@oracle.com> X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: d409cbba-bbcb-4225-8e00-08d9d0a62cb3 X-MS-TrafficTypeDiagnostic: CH0PR10MB5034:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sEyc214tP8BeRcYmLeUUHQ8ntXTDs62Xu0tRdsaX16CE1MFLktaBDBwCqPr5eY7NUeEuLzNTfDBAJewYnhMZ7nRxXu/qcgzJk2Ixqo48bAFVmUNoRG0ooVmC5Prraz/6cPO43EdYHqx3Qx+al8BiXuE5sKXesYExJ0mPl4U7VHFlhDDqd01939SmWngFjv1mJGj6Cnj2xVC+SodmdgZzPPcRx5tjtZtmYFeg2NhNco3IhXzn9mtpUABcMrv9Xj6VpN9xjjU5okhNHD/E/LsSvNrCAHpJASrdC+9juFnPg+fIJdxywYyMxDkPNkOVnnYTrQmoCCfZlyooDW9Yjx376MXHpM7Pvlc5cbGK90s4KNpJFgRW8Yy2y6ytA7LdE8Yj3PYz1v0mBQeyPINsh9/S2QDHkV15heAK2zkUFXeSd7IIOXsjGrZxOBThkhGZMBqI3L/8xz1AdOI/II49ml15b2YdNhsCr78lG5EftHndVZahQdug8BhkD0qLTSIrCE+J0yoK0wU9D0AAOYIsU+lEgBNB9nNOSWWqFc8lucaS+dorGL6tFWEtcG1ZXMCmPTWO4NmtwsS/EbtR4yP55oKqQ8t5jonDL9OAexm0LnNJvwew4DtsfBPcqCL9uprm8ZRGYa7k4VF3LT3M4RPDN35VgzufAhANHqYA3RgBiUNwn8iUJ3SGO6sICEhs3G/4S1qxFqy0lpdF0G5J7preZOVMLQ== 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:(366004)(186003)(6512007)(8676002)(316002)(2906002)(66556008)(6506007)(508600001)(8936002)(66476007)(52116002)(2616005)(86362001)(66946007)(4326008)(7416002)(36756003)(38100700002)(107886003)(6666004)(44832011)(26005)(6486002)(5660300002)(83380400001)(1076003)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3Bcz0dvZxqiprp9H4iFxI95LRx8Uv7UOYjdJXt+Ppg8GFGFpwcFg6kpKhFPVXgMC6ca6pKvI6Cfm4L2MNHFRJPCNa41123J1pfL20EUIE3ybIX3qv/6i2VmSCoQgZ/R957KaCdhHtnSCbQB0EQSfGGmIyJa7Oqcimips4XuslseCKkyEnccGit26NLt3aZpnAHTaTvNnqYmWXVl+kUdY2xOyHp8iucl8MtOcbKUHI6ELxEOnVE909NK7dCKzxfqPe7HiSlke+El/v8MYdoA8zHhammi2+Frg6dqjpEQc+gYJ5PlfWOJQZxWnyrYEiyD7NWeEoXyNjXtCpSigB7g5PVW2+V6O1A9ztP8PvatBipfwRV6G3ebeTGc7rc5Yjp/nwz5z7ywKb/ez3mduRH/SMWpGPOa+PMUzuxmeWVCeSHQUIGrhlOgSDwha34QxjUIClWXBQLuAzugKK+jm5sN0ygy1AUU6lFejaZ7Nn3Hah/k/nLp2cWpUhjeTiS/Lh4r0eMA8XbsSFVYuDHeSbDRBKzLrXqRanf8yRk2TxuU717NLpF8JbxZ8lRa5uxm09sNdF+v7tbORJmwvw2PT7xOO1ISBLTInJOlXPUpCqB+bNG2OvBpdSGRN9Jh7TJxws/N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ant-Network-Message-Id: d409cbba-bbcb-4225-8e00-08d9d0a62cb3 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 23:50:38.4155 (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: kgqlVLpohiMtgzQ8qb2eSJ/JUsGK0fkFRWy3tAspjTjOWp8YvBwrujSB9qAW01zntLIbSljCCAay1rByLDqQhgp9ItH4grjNlG/I3wpLyCs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5034 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10218 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 adultscore=0 mlxlogscore=712 phishscore=0 malwarescore=0 mlxscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2112160000 definitions=main-2201050151 X-Proofpoint-GUID: 2XHDKSBV2hcy2p6roZyCXLaXc9fZVVP- X-Proofpoint-ORIG-GUID: 2XHDKSBV2hcy2p6roZyCXLaXc9fZVVP- Precedence: bulk List-ID: Expose the .machine keyring created in integrity code by adding a reference. Store a reference to the machine keyring in system keyring code. The system keyring code needs this to complete the keyring link to the machine keyring. Signed-off-by: Eric Snowberg Reviewed-by: Jarkko Sakkinen --- v2: Initial version v3: Unmodified from v2 v4: Removed trust_moklist check v5: Rename to machine keyring v8: Unmodified from v5 v9: Combine with "add reference to machine keyring" patch --- certs/system_keyring.c | 9 +++++++++ include/keys/system_keyring.h | 8 ++++++++ security/integrity/digsig.c | 2 ++ 3 files changed, 19 insertions(+) diff --git a/certs/system_keyring.c b/certs/system_keyring.c index 692365dee2bd..08ea542c8096 100644 --- a/certs/system_keyring.c +++ b/certs/system_keyring.c @@ -22,6 +22,9 @@ static struct key *builtin_trusted_keys; #ifdef CONFIG_SECONDARY_TRUSTED_KEYRING static struct key *secondary_trusted_keys; #endif +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +static struct key *machine_trusted_keys; +#endif #ifdef CONFIG_INTEGRITY_PLATFORM_KEYRING static struct key *platform_trusted_keys; #endif @@ -91,6 +94,12 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(void return restriction; } #endif +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +void __init set_machine_trusted_keys(struct key *keyring) +{ + machine_trusted_keys = keyring; +} +#endif /* * Create the trusted keyrings diff --git a/include/keys/system_keyring.h b/include/keys/system_keyring.h index 6acd3cf13a18..98c9b10cdc17 100644 --- a/include/keys/system_keyring.h +++ b/include/keys/system_keyring.h @@ -38,6 +38,14 @@ extern int restrict_link_by_builtin_and_secondary_trusted( #define restrict_link_by_builtin_and_secondary_trusted restrict_link_by_builtin_trusted #endif +#ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +extern void __init set_machine_trusted_keys(struct key *keyring); +#else +static inline void __init set_machine_trusted_keys(struct key *keyring) +{ +} +#endif + extern struct pkcs7_message *pkcs7; #ifdef CONFIG_SYSTEM_BLACKLIST_KEYRING extern int mark_hash_blacklisted(const char *hash); diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c index 2b7fa85613c0..7b719aa76188 100644 --- a/security/integrity/digsig.c +++ b/security/integrity/digsig.c @@ -112,6 +112,8 @@ static int __init __integrity_init_keyring(const unsigned int id, } else { if (id == INTEGRITY_KEYRING_PLATFORM) set_platform_trusted_keys(keyring[id]); + if (id == INTEGRITY_KEYRING_MACHINE) + set_machine_trusted_keys(keyring[id]); if (id == INTEGRITY_KEYRING_IMA) load_module_cert(keyring[id]); } From patchwork Wed Jan 5 23:50:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 12704869 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 CDA67C4332F for ; Wed, 5 Jan 2022 23:51:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245651AbiAEXvq (ORCPT ); Wed, 5 Jan 2022 18:51:46 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:42442 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245572AbiAEXvG (ORCPT ); Wed, 5 Jan 2022 18:51:06 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 205N4t9X025707; Wed, 5 Jan 2022 23:50:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=iw0HknLHxTV5r4HSvMPxOZfsqdTeRLp2egs62YY91mk=; b=UxxUVbc70l1NW+S9N/Rmw4lY6fJ0bsVfM2F2vYnB7S+Ez6kcqqlQ1KxxkRYT5J28ADlq EROHC8Uw14MoionGZNsdPT9o0m8tYJjPYSTHUwULw3TQMYNeSxgHGxlsxXZozHGp1CGd QwqR7R2WV9clWKORpZeI+rwxxlPXBzlxRt2/ZStbiuWCWPXOVcQuN7baCVIr8yDZ/8QK ld+UIUf+3YEzjft4+I+EJg4cano0MuqVsxFFqYyO0JU+H11SujnladXripJHtZWniSad Wc3Fyp7sFdYlNMJqCvMCsG+VO+hyO7XEQfxR7tNfwCMQww80k6kM1W56Vqpz8mGe6dYR IA== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by mx0b-00069f02.pphosted.com with ESMTP id 3ddmpmg206-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:43 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 205NjevO149961; Wed, 5 Jan 2022 23:50:42 GMT Received: from nam04-bn8-obe.outbound.protection.outlook.com (mail-bn8nam08lp2040.outbound.protection.outlook.com [104.47.74.40]) by aserp3020.oracle.com with ESMTP id 3ddmqa1jfp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M4h98pNDwGzAtKItgWyio56L1yolbvyLYWbgUtXUkIjsKb8zeWr+9booOJYy68kPrKJbUuef741Z2aM3vpLqtixZYgSF5zTAAnCnpWWkySrouvNBxaPlb6m7hu4A4K/5dmDG7FINB5c/zciGHubDhUju50Rrvh3bIV+pTJg3rPUthLaHIvnuD/PKvf6M33WTIgSHxuVz4+V3PVbKbSC0ORYZ+FebBUribMnrwlES6Uh4VsnnD4m5fQMjZOml5jnsAdq3acCepU+VNCiuDf0akuWVRMsFtfxPrYgqTaJsYHfqLayfDE0ftMLNNAmQQFdmArLGAdBXNHuyuePGNYj2Tg== 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=iw0HknLHxTV5r4HSvMPxOZfsqdTeRLp2egs62YY91mk=; b=fySb8RO+c8IygmWk4+Kvsnx7Bz5b4MarojdD9YhkTZSPuSA16xm8qEb3vaLJtwSJ2edVPpnjOO0eWeiO5qrS0gokalizUCuwjL21uFll2SK4EvgWC4i+sU/l32nX5wv03vG1w8iR5cFw37OBFM553ANR3+fw91b+HS9zuU4P80wpJZLMotd55GalGBRdwwT0U6MzX9iu4lZ77TQx2A0Z7waUZjcDtYUfFjS/F8UKdC+DZs6jdpX/6oZtP8Ju3wOqQY0vym/AWT/4NzbRDhMezRHlRiNJ0dcct3MvlN0seegJXkGHc3JUbXtkmAZWSRJUNjUAANXc/7g1c40V7v6EPQ== 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=iw0HknLHxTV5r4HSvMPxOZfsqdTeRLp2egs62YY91mk=; b=HjjlcaaA0XpHETOsWsRckJ5edAkN/2MTkQZ4AD/th3riDVqSMq5VQ8wrqFhgCC0l15T27cfPHXuHkJim3lbtr/yEM6jcxHuQ7Kzn6vUPtnH/uDH40IwOYaIOmFnJHBAKJRFXfRhlJxUIxFumo8YNwk93hkCT+0Iq9ZI79NrVdgE= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by CH0PR10MB5034.namprd10.prod.outlook.com (2603:10b6:610:c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Wed, 5 Jan 2022 23:50:40 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a%4]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 23:50:40 +0000 From: Eric Snowberg To: dhowells@redhat.com, dwmw2@infradead.org, ardb@kernel.org, jarkko@kernel.org Cc: jmorris@namei.org, serge@hallyn.com, eric.snowberg@oracle.com, nayna@linux.ibm.com, zohar@linux.ibm.com, keescook@chromium.org, torvalds@linux-foundation.org, weiyongjun1@huawei.com, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, pjones@redhat.com, konrad.wilk@oracle.com Subject: [PATCH v9 5/8] KEYS: Introduce link restriction for machine keys Date: Wed, 5 Jan 2022 18:50:09 -0500 Message-Id: <20220105235012.2497118-6-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220105235012.2497118-1-eric.snowberg@oracle.com> References: <20220105235012.2497118-1-eric.snowberg@oracle.com> X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3598c9ef-39b0-4400-ca4a-08d9d0a62df0 X-MS-TrafficTypeDiagnostic: CH0PR10MB5034:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TCjQo+4w8bHYhu4s9c6sCxrMNOaGt9Y4CU0zyBner/Kx2jFi/VMBKuuuDy/W8U7UHIifpcRjTW4j6u900ixEq/j4A0zjNpeZe/otfk+KCEm5i/0HnSbkfqYZd1pX9hBRhwciTy4WflSZ42PjhLrhxsIIjVX8Q0DpwppWYmgh/tZTpg+NEr0w7DjZx1g1AiK/gXj/1fX/UqwSTlAcI/rINqWaOajptfPrGKZZ6FEpJNp39VmIS+gS2AHoYWheoXOo4Tnm+3aYqctpAqcZ+YqAGavbgu8mE7CwcouNU8wJN99TdUlIOCeN1Bjv1YsAJGOCNecVT/pBEChkbXR1jTDOAIx7jrgoy3gIR6rSuaM/Vs+tfJ1Nc1s7fcX+WZrtJ4BTo11G/tOeJ78te3Z1vPYolJHUBRJ/Xe5yxZuG+/65PJ5RXV0PEzw2Rax64jQ7QRUHRdhkFVGJyEC4s8KoB3q7uq8XOlnDvgq57EXMltcs+T8irx2Em6gRjs29BxC2GVvlGrA178L+gFRCCXs9v6jgJEI8/P6ULvn/JGXdVwfXtF6/7uvRetMKy2qVlGw2zvVs/QEG1/tJ+1gKpPM90NPKpDa1o9wYnvzoDx0z1r9XiHMlAREeQLH4YDI4CISGfWWHIxi3kFVJjzjH0GBzpjlhpwTsYWS6gNwaYg6mhTt8WM5rTJz4KZHCCDXu0RDHDOWou1rWw7U1oL7UeuSJ24fz7Q== 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:(366004)(186003)(6512007)(8676002)(316002)(2906002)(66556008)(6506007)(508600001)(8936002)(66476007)(52116002)(2616005)(86362001)(66946007)(4326008)(7416002)(36756003)(38100700002)(107886003)(6666004)(44832011)(26005)(6486002)(5660300002)(83380400001)(1076003)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: AwtpY4MBn8bv9pmo8/TBCCA1LN/0mn1IquKAdXYJGykJPSrTw1sa1pW7fCQ/6slt/e4gPEtyc8pym2+hxHT5QDgczS0lJNRKB8CRH9rLQVq8gEX5ehACgGOxJ126DtykFBNEwr/041TqtpeZzJjY+1Ugr9lmYQqVbEMnPlJ5mTtsiZLd874TAWAqhX1KJLDEaZJq7CsKZX8PZc51KVQRHwfkhRuZ9Y9snzQ90PI0VmYO9Xiatvw8dWh0UTmXA6rlegCckjdZJ7smuvAhj7lVkI+n+HgAQP70krujmMmtHeyXx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TgjaZo7WhoWQ9InlBB0IQoNTDjs8chQEv125eiw5qgdd0qVWvzWDxq/QI1qC8uk5yaTeP/a/MbljJFeFvEqjClmEfUKRjzJ532VIlZBNcE4joUCS+Luk4TBDIqTyy1trFYmh/OUzDcu06B8IysIcISlXODH5gHhdmG+lUQf6+28CX2RFg2uBcVCUJ/JfysWG59zP9pD0rSTh0FEY8fSOHZdkiqWmEAKr7MwYNXOMeLaSQ6MoNu+IFThXurHwCTPS0pOTjPaYhz+vMCHmurBgHr+G5i+0p3mg== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3598c9ef-39b0-4400-ca4a-08d9d0a62df0 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 23:50:40.4958 (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: /qKPWKbUhOF/jB+zakLjoFFvv0xhCcE0cVmEyBqnhm5pQlxLuUfkNtCvs8qmZzsHJStLQJf4cvoMRvdHAwoEFPvDDXrztmqnAWu6AnSFDLY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5034 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10218 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 adultscore=0 suspectscore=0 bulkscore=0 mlxlogscore=667 phishscore=0 mlxscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2112160000 definitions=main-2201050150 X-Proofpoint-GUID: NenaduIauftrxUhIkcc7vDJZrDTate5i X-Proofpoint-ORIG-GUID: NenaduIauftrxUhIkcc7vDJZrDTate5i Precedence: bulk List-ID: Introduce a new link restriction that includes the trusted builtin, secondary and machine keys. The restriction is based on the key to be added being vouched for by a key in any of these three keyrings. With the introduction of the machine keyring, the end-user may choose to trust Machine Owner Keys (MOK) within the kernel. If they have chosen to trust them, the .machine keyring will contain these keys. If not, the machine keyring will always be empty. Update the restriction check to allow the secondary trusted keyring and ima keyring to also trust machine keys. Allow the .machine keyring to be linked to the secondary_trusted_keys. After the link is created, keys contained in the .machine keyring will automatically be searched when searching secondary_trusted_keys. Suggested-by: Mimi Zohar Signed-off-by: Eric Snowberg Reviewed-by: Jarkko Sakkinen --- v3: Initial version v4: moved code under CONFIG_INTEGRITY_MOK_KEYRING v5: Rename to machine keyring v6: Change subject name (suggested by Mimi) Rename restrict_link_by_builtin_secondary_and_ca_trusted to restrict_link_by_builtin_secondary_and_machine (suggested by Mimi) v7: Unmodified from v6 v8: Add missing parameter definitions (suggested by Mimi) v9: Combine with "change link restriction to trust the machine keyring" patch --- certs/system_keyring.c | 35 ++++++++++++++++++++++++++++++++++- include/keys/system_keyring.h | 6 ++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/certs/system_keyring.c b/certs/system_keyring.c index 08ea542c8096..05b66ce9d1c9 100644 --- a/certs/system_keyring.c +++ b/certs/system_keyring.c @@ -89,7 +89,10 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(void if (!restriction) panic("Can't allocate secondary trusted keyring restriction\n"); - restriction->check = restrict_link_by_builtin_and_secondary_trusted; + if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING)) + restriction->check = restrict_link_by_builtin_secondary_and_machine; + else + restriction->check = restrict_link_by_builtin_and_secondary_trusted; return restriction; } @@ -98,6 +101,36 @@ static __init struct key_restriction *get_builtin_and_secondary_restriction(void void __init set_machine_trusted_keys(struct key *keyring) { machine_trusted_keys = keyring; + + if (key_link(secondary_trusted_keys, machine_trusted_keys) < 0) + panic("Can't link (machine) trusted keyrings\n"); +} + +/** + * restrict_link_by_builtin_secondary_and_machine - Restrict keyring addition. + * @dest_keyring: Keyring being linked to. + * @type: The type of key being added. + * @payload: The payload of the new key. + * @restrict_key: A ring of keys that can be used to vouch for the new cert. + * + * Restrict the addition of keys into a keyring based on the key-to-be-added + * being vouched for by a key in either the built-in, the secondary, or + * the machine keyrings. + */ +int restrict_link_by_builtin_secondary_and_machine( + struct key *dest_keyring, + const struct key_type *type, + const union key_payload *payload, + struct key *restrict_key) +{ + if (machine_trusted_keys && type == &key_type_keyring && + dest_keyring == secondary_trusted_keys && + payload == &machine_trusted_keys->payload) + /* Allow the machine keyring to be added to the secondary */ + return 0; + + return restrict_link_by_builtin_and_secondary_trusted(dest_keyring, type, + payload, restrict_key); } #endif diff --git a/include/keys/system_keyring.h b/include/keys/system_keyring.h index 98c9b10cdc17..2419a735420f 100644 --- a/include/keys/system_keyring.h +++ b/include/keys/system_keyring.h @@ -39,8 +39,14 @@ extern int restrict_link_by_builtin_and_secondary_trusted( #endif #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING +extern int restrict_link_by_builtin_secondary_and_machine( + struct key *dest_keyring, + const struct key_type *type, + const union key_payload *payload, + struct key *restrict_key); extern void __init set_machine_trusted_keys(struct key *keyring); #else +#define restrict_link_by_builtin_secondary_and_machine restrict_link_by_builtin_trusted static inline void __init set_machine_trusted_keys(struct key *keyring) { } From patchwork Wed Jan 5 23:50:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 12704866 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 E3A41C4332F for ; Wed, 5 Jan 2022 23:51:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245634AbiAEXvm (ORCPT ); Wed, 5 Jan 2022 18:51:42 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:39982 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245569AbiAEXvF (ORCPT ); Wed, 5 Jan 2022 18:51:05 -0500 Received: from pps.filterd (m0246632.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 205N4rFv025697; Wed, 5 Jan 2022 23:50:46 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=moN0N9AohXo6kI25Abl/whL3aL6xWbMk0+iw4AQavBA=; b=cEuTjykI1umvhjReQrGFnJUfG4UPtWbarCrKBx7CZi5gG9B7ot1vmpX6Tc61DZdZt85e zDHsBmqegeUW3YL7MqzzHZd5hULPYGsSVBk9FZem9+Oc31sJY94ljaRoW3hpl1dgxlu4 Eg1bPhbgcx3VbUCTRXrTuK1RzAhGVktdxpF14yYVGWod4MT7cbjFwahqRekvRoWQfmTg A6cdDBqHnLTG07P+nu+HQCR5majCyn6IwtmklPAMEaXz+sJk3VeLa0iQ35xGZazbYQwp atb1BlRDFsV/OeRtAuBeHrbCgwUkMul05Eew+6tLibz6XEpiWyzhuVqLHs/llvPIv4+E Ug== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ddmpmg209-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:46 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 205NjHlX177030; Wed, 5 Jan 2022 23:50:45 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by userp3020.oracle.com with ESMTP id 3ddmq5shfg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:44 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ktsOn+QcRWJWxTfywr8YBNRiFDEJ17xmklwrXVJmfBxzurfRQdrbJntAbrjKg4rx8HyLQSNDHNH3H+4PefJQJYo0ECP6EnkV/xCbjn9w5VaGUnyDdB9zg1R2pXXiEn4Ng0K9x5Hdn0C4U306rEmmvn02W4RDgmpjwqGHDdRYNrndX+J3uZVsYvAH2QAiYg12Md+qyS6J23rW1wpQ+MMXsqoXNxZAqi9zlABrcK84jv4FT0wjHNIqDTpJyIhkay1mxUAFiUkkErdvQ5KCOtoRrMNyfYOvCsLEAASf8wIQe6ZUCaBo9smC9HbKWjPXcMIyvpxktExNo4XzA5N+TiSwMg== 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=moN0N9AohXo6kI25Abl/whL3aL6xWbMk0+iw4AQavBA=; b=WOnIWTi0D+baL9TKf/u4lYtsk5hL8+UMBlPbtjYEpU3UCknpZ/691k5896uYeu2ABftAtdEj6lzbCpcFtTs35j6TzVwUvZcHxeIPlJMgR9hBYaIICE8A6uYZO8Gu/lGChbmEVtSJe8fc5DEC6W90nRBdC1JECEOlRJG3voeNq2SSJjaZgRpy5xfL52WNurPklKaN9oI+S+kwmDdp4+F0wrVvrmRr8j931erzZahI2nKWaHYxZIxgA2NqwXgfTGj3Ts/wcgwmEP1r0Ozs3XX7xtbwoani7hpGjx8G5TvDvCyWpzFoV9lLdsAxFydoaEQD+kPYk3E6CLE9q0lc8/Tauw== 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=moN0N9AohXo6kI25Abl/whL3aL6xWbMk0+iw4AQavBA=; b=mk2Xg5M+12K0fpGJ8/uxCuvkcE94CV2pxXuBQjBCCXAPcyUQ/9VwDY5ZL47CMB1z7Qg0XetpJpigwFinCYRZkcTmpmMHSzbif8I7+avAB7DuBhIJtJ7CLBbJtfxrIcp9OVTSF78raslhXvFDsPls/Ysie7pR7fIhaQWHfyKNVqw= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by CH0PR10MB5034.namprd10.prod.outlook.com (2603:10b6:610:c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Wed, 5 Jan 2022 23:50:42 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a%4]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 23:50:42 +0000 From: Eric Snowberg To: dhowells@redhat.com, dwmw2@infradead.org, ardb@kernel.org, jarkko@kernel.org Cc: jmorris@namei.org, serge@hallyn.com, eric.snowberg@oracle.com, nayna@linux.ibm.com, zohar@linux.ibm.com, keescook@chromium.org, torvalds@linux-foundation.org, weiyongjun1@huawei.com, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, pjones@redhat.com, konrad.wilk@oracle.com Subject: [PATCH v9 6/8] efi/mokvar: move up init order Date: Wed, 5 Jan 2022 18:50:10 -0500 Message-Id: <20220105235012.2497118-7-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220105235012.2497118-1-eric.snowberg@oracle.com> References: <20220105235012.2497118-1-eric.snowberg@oracle.com> X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 529425aa-4282-4166-4488-08d9d0a62f27 X-MS-TrafficTypeDiagnostic: CH0PR10MB5034:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1443; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d6pCyBKg7TZMV4kC2kVehoAH04dMRIFtQ7yyKGCjbgsEKz8JQWbsdhBvIgPUM30utHTmWb1yokCJN7piqggnQVP2lAAu+ixhAv+2rgA7mDHAZbxVxpGxYNOL2sVktQLWdFLq5t8Xjometmt9PEuPw0DdFGBQn8KfEjAlpWzRUucTXnmxnsfbi1M5o5oHFrNR6ICmg91SFDIUOerJNhVp4FbUboI1RwgDWsuazcRLXUG7z88CnS7RkFnAZJNtyujO+q+YD+xBCN53qgi5wtBm69H1DuOhAl6LZDhomnHq1A/Y22+q68o2wJdZArzajrC2ox8JDtjvYPrQORw29CTclZkdUk+F47oVvIsFOu8Nm1cliiXSqcuznmaZPU0oVjnoju0wTggc0J6hKzlmknVJevdQXpLJieUUbUPWQhI/kyNNf8epvWcaoZ6b1EuclAFEetS5eYGQ/prvyDhQq/TgmmYEHeS56IurTrHf+pMCSv741+WKZJsGbAe5czwaJc5HNnJPbUHOwqLXRQ1fLHCQ9D6wyREBhv58ASIaDSohgqgRL54HzX2ockHTt+85PWS+Oypd5Y+zIx9g9gy9EbXi4fn7oDxJojjznTYd3SLZaG0kM7CrOOyWo614I4h0GQcTn9BjONR5rk+pISJsh7uJugHDtHU0GkSpd6aYe1FTjnmz+lwhYcqQwFA9I4EMu9s09So0O9AiwCp/gwtINrWMXQ== 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:(366004)(186003)(6512007)(8676002)(316002)(2906002)(66556008)(6506007)(508600001)(8936002)(66476007)(52116002)(2616005)(86362001)(4744005)(66946007)(4326008)(7416002)(36756003)(38100700002)(107886003)(6666004)(44832011)(26005)(6486002)(5660300002)(83380400001)(1076003)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gtaFpKpdlrX3FZibBANviyAgrsqQlZfKF5RMo/2hsosfyGRa7XJnB2k5DXqnAVi8RkkisPBIEuCXy6fjW6l/CwfAFfiICynJ5TejujF8uYQDu5xMemErWzy3wkirSlG8LH8XvaBojJNOOZHMqKV8kkIwl2Bp/EfiXNKopHCCXEUa8V8KHdMuY7dKaeKIIcRbIoiMHsvAk7guVqXRbYDnCDdorwpPYy/odCgXaGjwIMuYrLwpRBFaOjuuPVI3z/GreJB//kBuRsxBFnoEf9QpPgaJbjPlE0d+fAXquCpjq/oBi6NXlrcX5hGZbH+FcQusKX30namftNJ59yBD8qN5wyREg2r5TQ+pb+iOLZ0NROk4OAq+4F39jkGxlZC8+dSaVjqNZoILdeanS+TQqgygFQQOSh5arvZ5bBm58qNB9LyB/L1xpZL+GKvFThVbaXDqKAAKVuLPdwEjGFWzeHWbROKcPCWrLwHFNB80bGwvnMQ5g0JIAFWw6TgwQlQuCV7kZJyp69pQMqzRhcMosXY/AARO4JffutgroGtQv6lo4hCMD1ul+VRmHg7AGq+zISafYx+lV4pXSTZE0bZue/+YND6o8p9XtPFMZd+ZQ9gmuMMjptw4tAa4QYlFrftqzBfwXJdPG09B4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aa-4282-4166-4488-08d9d0a62f27 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 23:50:42.5775 (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: AUqR/EgvoJlquu4Xg2iu7YEv9kqA/+wrCpxvRfZjh1ugjI3ltBtuTWFsaRMJoijB2/4TXanBI2GwP2kOCVcf4APbYhnh4GvNgeWaXzb0h7c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5034 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10218 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2112160000 definitions=main-2201050150 X-Proofpoint-GUID: 6_ceHJItPutMruteO1WAwVdJHeZj1qc3 X-Proofpoint-ORIG-GUID: 6_ceHJItPutMruteO1WAwVdJHeZj1qc3 Precedence: bulk List-ID: Move up the init order so it can be used by the new machine keyring. Signed-off-by: Eric Snowberg Reviewed-by: Jarkko Sakkinen --- v7: Initial version v9: Unmodified from v7 --- drivers/firmware/efi/mokvar-table.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/firmware/efi/mokvar-table.c b/drivers/firmware/efi/mokvar-table.c index 38722d2009e2..5ed0602c2f75 100644 --- a/drivers/firmware/efi/mokvar-table.c +++ b/drivers/firmware/efi/mokvar-table.c @@ -359,4 +359,4 @@ static int __init efi_mokvar_sysfs_init(void) } return err; } -device_initcall(efi_mokvar_sysfs_init); +fs_initcall(efi_mokvar_sysfs_init); From patchwork Wed Jan 5 23:50:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 12704867 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 7C0BEC433EF for ; Wed, 5 Jan 2022 23:51:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245636AbiAEXvn (ORCPT ); Wed, 5 Jan 2022 18:51:43 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:40488 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245570AbiAEXvF (ORCPT ); Wed, 5 Jan 2022 18:51:05 -0500 Received: from pps.filterd (m0246630.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 205N51vo032378; Wed, 5 Jan 2022 23:50:47 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=bNw5T2SnzPzUMDoAeYYwoxugAs6OA0EbabISVE09Nro=; b=tStS2LZJellguQ000YGdch80wVurjrUAe/E5OLHtzTv0GaqhRPCpplsewC1XgwNJHFzd XTs5qJBRJjggj59lojYC/ukrmXe0RFZuSTh9ynb4pqqo4nUJ5E0pBb3gem9tGzeAvzh6 1/GXwSKsWEvxM3b+akbPLGIK4VYD5yNMXUf5h1FWwki5hrWK5GUgfnRXU8FNGIE9e4MC Q+2zukPRuEezaLGfl81Wqs3D12GwkBl1YjgltAN/H5fWGga2TjMtMJiO9TSK0EAZtY4V RKL2/Y06QVzzYofuBvNMXGzYbctAE/W9VyWiRd0i9/HiePwUwB7SbGlroQ0D75hbELNt Tw== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ddmpjr22t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:47 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 205NjHlY177030; Wed, 5 Jan 2022 23:50:45 GMT Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2175.outbound.protection.outlook.com [104.47.56.175]) by userp3020.oracle.com with ESMTP id 3ddmq5shfg-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VoL9akT20ockzu1n6SXGjfcQZlRFcvUidJSCnMfzKvgglg0JmaOuUTgu1i64pfZYg1M4zcmpPAESSAokc3iBWA2zyoC7qlltO7BTtl0GQjxzYsCRqz+cV0s2NcClqWWdYHkcN5fuUv3iNexUnraxV3TMHBHzgbQIwc7IpQFvzl1HjtBEwzk3OFHBGYHVd04nQjht4qS5hC8VSLR/vAtHjyYveHNkWgzQEwv6yM0U9SzU0eL6NiXT16mVV6rpefKK3Vv+/k5TzY8V33xsOfuRTJss9g+FlPygeLFyIF/JXT8uIuSGtQp82mzvIWs1Cp38Ho7e47KbdkqYT2qjyh4KZA== 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=bNw5T2SnzPzUMDoAeYYwoxugAs6OA0EbabISVE09Nro=; b=Wt8sGFdarxsYxXoC+cqX9Zl6bx+FMydCsj0go3rkOW7kJZN6ZPFEzaQjbhGq6KPIze9onlb/3l69gRTEBWl53LgGQYJOSxyVa9HcSQZEhe+FFpouPxLtJ3naP5xnafBor0wASa+j+votBFb5Gg3n6Gjdjuge58BiqKVnf8SEQKsQ3Oorj+LcgXMq0fFOLk1DIAoUwkBypzZdCWxmbKF9q9izs2xHsEzWKVRkU5rdWFRABkm6rL25c5oc1JM50M9ZunNCkkSuTvqSGWPbdRs2TEsQXMY989StrcR366+RBv1xc1FZG16ipaw4yhPPtkpduOWtNsyGRaS6rNIt6bE0oA== 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=bNw5T2SnzPzUMDoAeYYwoxugAs6OA0EbabISVE09Nro=; b=tstO6O3+Lf7UBK/K36p4V6xcwnRq0DPslPsVniDCstr/AFtUhNhkPBgNJL96JPZh/Njwgq8PbVsPYG6pcMxiQonTPhG8B11as4UmMbMtiYm8YLaX7M8IUMfydlFxI7MMzSaETTPtf2HR95xQrcu/LRSwEpsH4ajxRynjfYLRSac= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by CH0PR10MB5034.namprd10.prod.outlook.com (2603:10b6:610:c9::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4844.15; Wed, 5 Jan 2022 23:50:44 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a%4]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 23:50:44 +0000 From: Eric Snowberg To: dhowells@redhat.com, dwmw2@infradead.org, ardb@kernel.org, jarkko@kernel.org Cc: jmorris@namei.org, serge@hallyn.com, eric.snowberg@oracle.com, nayna@linux.ibm.com, zohar@linux.ibm.com, keescook@chromium.org, torvalds@linux-foundation.org, weiyongjun1@huawei.com, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, pjones@redhat.com, konrad.wilk@oracle.com Subject: [PATCH v9 7/8] integrity: Trust MOK keys if MokListTrustedRT found Date: Wed, 5 Jan 2022 18:50:11 -0500 Message-Id: <20220105235012.2497118-8-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220105235012.2497118-1-eric.snowberg@oracle.com> References: <20220105235012.2497118-1-eric.snowberg@oracle.com> X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18b43839-f972-44b1-44b6-08d9d0a63067 X-MS-TrafficTypeDiagnostic: CH0PR10MB5034:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IhqzKZ8Bf7tGsZz6BuM5dLuDXhnJM0T8beRTGp553iwC5ElcfCfJlv9ixxTnErAdn2la0Akj167qBmGTY189NsCcc8KZsNi4ZsPiQ3VVjWF2ZWoywl0dm6Kxcjz3oi/RIYcv7Uq1C8U2qpmxxavIuD83+NSrrxQp9pOyXQHBpdUH4sqrzi9XelWJfwovmgcvn6PU88Snmm6fXPuL/8h86pHb34R8IoOwCUyRtMZ/aMieAAl7h2jdhqXacsk9OzPuNG3TGGC5+ZOqlxXfZ7glwl6TJ6dXPBW/QsMjbfxA7QrDR9xU2i9Gczt8QkYoILj1xIaePFoaGYtzedD22oNDPlgqxj68xzLP6gJW7HvJ3Dyabod44BoCZJOhY5RQPBjjzKayjR3PJtlV/DTV7R8UtgucQ6qIee7iae/GD9RFtadbg/0U7tGL0kAl3b5DjlFgsBQkpZyIAbulOC9f6A9NZJMLKBCGeQLmR8OIiYYVolylbOseVeUNeBMHckacXSpvQmsRcWP1nmfpKm9w07CMVXG0nXJcif1YZ9gSWqZk9aAQUJo/EjJXHmoB4/JkioUSWksfJaSSODeuvneUgmhoUm+P9cpOSWAJYtSAtAnUlL0DmPTCexJyjmAgOmUtkCWIK0TCaFVkJiwOx3k/V2DK4/OV38SK4sE6HBTcCkuD1ukTLlEuj0oVBzkIgRqGrkFaLRLizDzByX+Oa0xBzH//zg== 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:(366004)(186003)(6512007)(8676002)(316002)(2906002)(66556008)(6506007)(508600001)(8936002)(66476007)(52116002)(2616005)(86362001)(66946007)(4326008)(7416002)(36756003)(38100700002)(107886003)(6666004)(44832011)(26005)(6486002)(5660300002)(83380400001)(1076003)(38350700002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: em962W3d1M1vKALmj3HdRsQL5rsStZih0p5WWZBLGoL43CFltPrVP+99Lt+M7N9ILJpnaanEjXck2/nukik+0IHJJmWTojHC61Ot5pyFApNxbH9L/8thndyyQ9bMuxryttTgfEsoFNC9liQTxJdnmtcIXtZq/SyhDMwKxE0Fi3h2LuJ68ehQJRHOPsHlmYUoc9WDrvyO52kKk1FjNzMGF0evP81uuPMoqeca+7gkEX5ahuH5sJoIlhgaZec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vu111hnesvNs794a3alqLaf1QEiIHWh3LJ6e1rOsU6s6NfO7/HUOdplqXpOfZey89iqNGhKDor+Z0MZPIuTqI7CU5xtYUDHe1EXIBtw2u4dBSI6zxn4npmj/Wq/80LX92odo/NcY1LBGwfl3YATOGc/w3RDusxJCyNZ6tuzjkmg0xOmO0Bd1SCJ96Xk0Ld3WT0Y1OpISix6t3GkT8CSZZ9Z1CniDR/J+mB9CdenQtdbfUD/Re25gDobSl7/XLw6g5LWFVt4ll5fNWAUPNu+R+2MMjcm/boZ42gYj8TYzybmOsGuovRa5ao2ht77d+7MWEKHFT06I5SbakTWKNvNK/awRSckcODhzf9PnPyVlVl9Jw== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18b43839-f972-44b1-44b6-08d9d0a63067 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 23:50:44.6277 (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: Yi3UFU1l8eAuwm8GHXSE+b3uhHuWXeSDuqyyOPrWdaEMRP9qh9j+eMununFwgdn6OcDkcHwbi1VlcGBwetwP/wkuc/WjZw0H84IFvnlHkX0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR10MB5034 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10218 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=999 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2112160000 definitions=main-2201050150 X-Proofpoint-ORIG-GUID: 1I6LxVyovOFrrbmOWOH6w6ORNESiX47E X-Proofpoint-GUID: 1I6LxVyovOFrrbmOWOH6w6ORNESiX47E Precedence: bulk List-ID: A new Machine Owner Key (MOK) variable called MokListTrustedRT has been introduced in shim. When this UEFI variable is set, it indicates the end-user has made the decision themselves that they wish to trust MOK keys within the Linux trust boundary. It is not an error if this variable does not exist. If it does not exist, the MOK keys should not be trusted within the kernel. Signed-off-by: Eric Snowberg Reviewed-by: Jarkko Sakkinen --- v1: Initial version v2: Removed mok_keyring_trust_setup function v4: Unmodified from v2 v5: Rename to machine keyring v6: Unmodified from v5 v7: Use mokvar table instead of EFI var (suggested by Peter Jones) v9: Unmodified from v7 --- .../platform_certs/machine_keyring.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/security/integrity/platform_certs/machine_keyring.c b/security/integrity/platform_certs/machine_keyring.c index ea2ac2f9f2b5..09fd8f20c756 100644 --- a/security/integrity/platform_certs/machine_keyring.c +++ b/security/integrity/platform_certs/machine_keyring.c @@ -5,6 +5,7 @@ * Copyright (c) 2021, Oracle and/or its affiliates. */ +#include #include "../integrity.h" static __init int machine_keyring_init(void) @@ -40,3 +41,21 @@ void __init add_to_machine_keyring(const char *source, const void *data, size_t if (rc) pr_info("Error adding keys to machine keyring %s\n", source); } + +/* + * Try to load the MokListTrustedRT MOK variable to see if we should trust + * the MOK keys within the kernel. It is not an error if this variable + * does not exist. If it does not exist, MOK keys should not be trusted + * within the machine keyring. + */ +static __init bool uefi_check_trust_mok_keys(void) +{ + struct efi_mokvar_table_entry *mokvar_entry; + + mokvar_entry = efi_mokvar_entry_find("MokListTrustedRT"); + + if (mokvar_entry) + return true; + + return false; +} From patchwork Wed Jan 5 23:50:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Snowberg X-Patchwork-Id: 12704871 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 3E964C433F5 for ; Wed, 5 Jan 2022 23:51:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245671AbiAEXvw (ORCPT ); Wed, 5 Jan 2022 18:51:52 -0500 Received: from mx0b-00069f02.pphosted.com ([205.220.177.32]:44084 "EHLO mx0b-00069f02.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245576AbiAEXvG (ORCPT ); Wed, 5 Jan 2022 18:51:06 -0500 Received: from pps.filterd (m0246631.ppops.net [127.0.0.1]) by mx0b-00069f02.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 205N5G1n009916; Wed, 5 Jan 2022 23:50:51 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-type : mime-version; s=corp-2021-07-09; bh=AfBdTLyp+eCgXsJVPdns1cBm8q0VATTcj3tqV/Tzetc=; b=rqYr38IWXsvdeutoV/R3hM6BtG6q2Fh9BeYASDdCAWUWz9RPX9ja3TIVvQFz8S8abP4P ZKi8cc1ZnB+JnCXYvsI3FI3QiVepQQJbOOFLTps40soDSxcv79CeLSVheLjbPtUwtJ1q jByQsGL0qgQ7qGmw/uA3TGYX7swzXs2rYGJweU0wL1KVlvSKuNoLKtPTdFIjfyoh8/xH x9rkF1S6Ra8L0OtLhqxCQ1j0A67FlYwhu6FW0eUIaC0/sAPuE9khqfX0feGX7YFrbkIm 1at+ZBSFKwAEjB4FtV0zWwuAhRBWv4vZZcA63FsCGZ0c6L4/s0z0OirOsVKq8mJ5IEf7 UQ== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by mx0b-00069f02.pphosted.com with ESMTP id 3ddmpp820a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:50 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.1.2/8.16.1.2) with SMTP id 205NjIhC177103; Wed, 5 Jan 2022 23:50:49 GMT Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2104.outbound.protection.outlook.com [104.47.58.104]) by userp3020.oracle.com with ESMTP id 3ddmq5shhg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Jan 2022 23:50:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fq2uiKJ4e4f9CV/na77arhEpN7CMiMyWEIPO+beISdsGkE47FPo92zIauQetnp9CLI2J6IjFS7wGxl/GBVgEACEIoAflw+HBqwqECC5QgnjT1Ef3d9TdH6kbhZVCqBzx2nLJA9gIBt5TWySh1c22SNm2BIhUmL5rpFdWyEpR1eMECuoqRE2pc53U+WuuxpjaXbqSQbjIHJPfthdeopBAIKI7JK9YOGMoXhbOxeC91OPnpNC9Tgxx74249fjLwjmUvjRDV6tzoCCeDAASQWethXeG5eGCvzwvknN2yDRjU5p5AG52I+3PBuIsBpj++H90LUvDtXB11W6lXXL3juIj6A== 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=AfBdTLyp+eCgXsJVPdns1cBm8q0VATTcj3tqV/Tzetc=; b=mRz6c9maZlb59OEUzNtrxdfu1HPebfVQKAEzN8MnNx196c+uOEo0TO+jFs2tbOe767IT8F/2SieVI9p89AujnQPnX1QbxNIWXeHqH+I4DoVZZPDCgPzr/YldCE4zAa1UleAVjPeN2sVTOFXm5YXrbeOsWDspFizt423q6iY5xvGrsoohs8Pw6WpdPry+zUQt4hzmi0JW6CQKT87nMrbgGj37RvryHxZFFP9sqIhbYAetY13y6MmSpnMG4NXIFaZIe8mYLcOpOV5wrwQAnfSTWot187oKSWawpNIaDrZbEmtmk1H9m7CrCN37RcHWnyraJCTjXHnCxSxnwFrLUOUiGw== 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=AfBdTLyp+eCgXsJVPdns1cBm8q0VATTcj3tqV/Tzetc=; b=dzjXt7GpBhlyyb5Lg6I7O7YuPzblSKgSRnTT7z9V8FnCIINmebLm9w8+HFTJnSS2KCE7Y5jVWRN2KtTMsa8SnSWCvNWVPSYfUvD9zsFpHAnddJQ9ial2rm4bDmxSfTsloU0UMDV2NIHIXcdm9oIflIK1/KEWW8busuG+mPm9RGU= Received: from CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) by CH2PR10MB4261.namprd10.prod.outlook.com (2603:10b6:610:7d::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4867.9; Wed, 5 Jan 2022 23:50:46 +0000 Received: from CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a]) by CH2PR10MB4150.namprd10.prod.outlook.com ([fe80::cc63:ba5d:5d87:579a%4]) with mapi id 15.20.4867.009; Wed, 5 Jan 2022 23:50:46 +0000 From: Eric Snowberg To: dhowells@redhat.com, dwmw2@infradead.org, ardb@kernel.org, jarkko@kernel.org Cc: jmorris@namei.org, serge@hallyn.com, eric.snowberg@oracle.com, nayna@linux.ibm.com, zohar@linux.ibm.com, keescook@chromium.org, torvalds@linux-foundation.org, weiyongjun1@huawei.com, keyrings@vger.kernel.org, linux-kernel@vger.kernel.org, linux-efi@vger.kernel.org, linux-security-module@vger.kernel.org, James.Bottomley@HansenPartnership.com, pjones@redhat.com, konrad.wilk@oracle.com Subject: [PATCH v9 8/8] integrity: Only use machine keyring when uefi_check_trust_mok_keys is true Date: Wed, 5 Jan 2022 18:50:12 -0500 Message-Id: <20220105235012.2497118-9-eric.snowberg@oracle.com> X-Mailer: git-send-email 2.18.4 In-Reply-To: <20220105235012.2497118-1-eric.snowberg@oracle.com> References: <20220105235012.2497118-1-eric.snowberg@oracle.com> X-ClientProxiedBy: SN4PR0501CA0095.namprd05.prod.outlook.com (2603:10b6:803:22::33) To CH2PR10MB4150.namprd10.prod.outlook.com (2603:10b6:610:ac::13) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5935e9ea-2f11-45a0-3965-08d9d0a631a0 X-MS-TrafficTypeDiagnostic: CH2PR10MB4261:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rI70nQ+8XDbb8t+6IFhYKZ9qv4Po+lbXU+iKg15BZ2f6Llj5819njuKF2SONfCBaFJ3VDCdkF5ZZKyNQo2Omb5Tfa58usqL1Yu7cXxpJ7cSIPrf36/ReaWrwrjP2rGkiUNFdzRbn0iOCVmc8y5FiLAyXqSzoBSYWdqSyvdXaaXSaK6yO5G7J6IbT6moFe82ETumguf8CezFhOPMyMNs0uavge6wIrtoYZPuXLmzMIO7s6hm6GEDe3JPFBd7/tfRmHvMwjnzQl2w7LS+PPTP9MZLyKuEaDTwZvLqqBs01YuWfUrWg7MGVph3E30OECq5bFg3oSCevU349iLGRsxNaypKCsLA8TvakTg9/91z1NBUxAEBtc/X6z0lja4MF5Uy/IGYNY8SW46hriEYRMQcjU9atfwpaM5qG7whhAoANnCpQR5whjX1k2XtZHM0D/jtn2Mg3IatVQzyvuqWT6tKJqPGebdvX89om7pl+vi5yTdNJ9eBpJP1arPmWud1iKx8CXt2pNoo+2xMmQniygEPo1PaRvx/2YeEfEGu06rrIQBIdqet0/7SWvj4pZWcZ959WXTeUCaIamh3BbFLoukmIyN5M641gmVkn1XFnw6AkzubTVEUETSkDXNQbgckZ/xJJ3KConVj+xPICquiF2zVMzszSjYYpWMQOjBamKB7mbS3qr7zyPOm96AaGtoJopaQmAsEoSgVJ0BlBp5ZWrp6/3w== 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:(366004)(38350700002)(316002)(6512007)(38100700002)(86362001)(6506007)(107886003)(6666004)(66946007)(7416002)(8676002)(2616005)(66556008)(1076003)(2906002)(508600001)(4326008)(83380400001)(5660300002)(186003)(6486002)(26005)(8936002)(44832011)(52116002)(66476007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /7Yr9DIMBzv60RjiK4MHBpY3M8K3qMMclbru+WWRx1GGD1kFHEb81bh0cMYVv1ILUE+MeYtg7MAiNcyYGddtLXsA100ReeZ3HLBkKxI/N9Ws+QDdxZV9i1cGu5TH8890rxHrIMFsKKaNR6YCwFLDouL7x8qIDlTu3WsolF6pja+mmbUTZWjFZxYVjyHJjWnjWhR80XIfA+uxKDANHCprE7cWtwgzPlK9z1bq1zW6Xh6gJrPOUFgFDBCASx5ilP1jnEID25amZqtGj7ABVQvmD2Pyoc3Qxs1Kt1/FZ2l8DllX5JEoAmiAH7sBfCYHfDci8ZGvO+VNl+paOpXK+WHS2z/8/J/7qrQFWrFvB/F7Y0KJ/cQRuL0SUHFE/u8uQIYyMnreDRApdSa6PEUd4xdNx+aeUW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w67nJVWu6aIpmmMiRkT8HtlEMWB37OYhh3T5ULJLXahivgtn9nJHPyzNPE2GqyTb0bRZ7cxzHXxzINxnj2evJofOHpIzMUPWTSB5ZC3LG+iIbovDZE1xP26SCMT0fq1UYqGNv7lngk0uERdhtRGk41Ye/GX0cUsHyomin4NwV73j/zGcIYLO4LA== X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5935e9ea-2f11-45a0-3965-08d9d0a631a0 X-MS-Exchange-CrossTenant-AuthSource: CH2PR10MB4150.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Jan 2022 23:50:46.6930 (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: J9/y3O0Rllr0KPSCdw7DoZf8y/gg9WEdg1VIlA9spFZlUByM19ee9uIUEnshG/gDMISVsJ19WwZcPL2OEbmHSFLqKYBCLgZ6TkNwLric7eI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR10MB4261 X-Proofpoint-Virus-Version: vendor=nai engine=6300 definitions=10218 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 malwarescore=0 mlxscore=0 spamscore=0 suspectscore=0 mlxlogscore=662 phishscore=0 bulkscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2112160000 definitions=main-2201050150 X-Proofpoint-ORIG-GUID: uC3muoxp4Ud5NqZkrJE5lydhP346tQ0s X-Proofpoint-GUID: uC3muoxp4Ud5NqZkrJE5lydhP346tQ0s Precedence: bulk List-ID: With the introduction of uefi_check_trust_mok_keys, it signifies the end- user wants to trust the machine keyring as trusted keys. If they have chosen to trust the machine keyring, load the qualifying keys into it during boot, then link it to the secondary keyring . If the user has not chosen to trust the machine keyring, it will be empty and not linked to the secondary keyring. Signed-off-by: Eric Snowberg Reviewed-by: Jarkko Sakkinen --- v4: Initial version v5: Rename to machine keyring v6: Unmodified from v5 v7: Made trust_mok static v8: Unmodified from v7 --- security/integrity/digsig.c | 2 +- security/integrity/integrity.h | 5 +++++ .../integrity/platform_certs/keyring_handler.c | 2 +- .../integrity/platform_certs/machine_keyring.c | 16 ++++++++++++++++ 4 files changed, 23 insertions(+), 2 deletions(-) diff --git a/security/integrity/digsig.c b/security/integrity/digsig.c index 7b719aa76188..c8c8a4a4e7a0 100644 --- a/security/integrity/digsig.c +++ b/security/integrity/digsig.c @@ -112,7 +112,7 @@ static int __init __integrity_init_keyring(const unsigned int id, } else { if (id == INTEGRITY_KEYRING_PLATFORM) set_platform_trusted_keys(keyring[id]); - if (id == INTEGRITY_KEYRING_MACHINE) + if (id == INTEGRITY_KEYRING_MACHINE && trust_moklist()) set_machine_trusted_keys(keyring[id]); if (id == INTEGRITY_KEYRING_IMA) load_module_cert(keyring[id]); diff --git a/security/integrity/integrity.h b/security/integrity/integrity.h index 730771eececd..2e214c761158 100644 --- a/security/integrity/integrity.h +++ b/security/integrity/integrity.h @@ -287,9 +287,14 @@ static inline void __init add_to_platform_keyring(const char *source, #ifdef CONFIG_INTEGRITY_MACHINE_KEYRING void __init add_to_machine_keyring(const char *source, const void *data, size_t len); +bool __init trust_moklist(void); #else static inline void __init add_to_machine_keyring(const char *source, const void *data, size_t len) { } +static inline bool __init trust_moklist(void) +{ + return false; +} #endif diff --git a/security/integrity/platform_certs/keyring_handler.c b/security/integrity/platform_certs/keyring_handler.c index 4872850d081f..1db4d3b4356d 100644 --- a/security/integrity/platform_certs/keyring_handler.c +++ b/security/integrity/platform_certs/keyring_handler.c @@ -83,7 +83,7 @@ __init efi_element_handler_t get_handler_for_db(const efi_guid_t *sig_type) __init efi_element_handler_t get_handler_for_mok(const efi_guid_t *sig_type) { if (efi_guidcmp(*sig_type, efi_cert_x509_guid) == 0) { - if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING)) + if (IS_ENABLED(CONFIG_INTEGRITY_MACHINE_KEYRING) && trust_moklist()) return add_to_machine_keyring; else return add_to_platform_keyring; diff --git a/security/integrity/platform_certs/machine_keyring.c b/security/integrity/platform_certs/machine_keyring.c index 09fd8f20c756..7aaed7950b6e 100644 --- a/security/integrity/platform_certs/machine_keyring.c +++ b/security/integrity/platform_certs/machine_keyring.c @@ -8,6 +8,8 @@ #include #include "../integrity.h" +static bool trust_mok; + static __init int machine_keyring_init(void) { int rc; @@ -59,3 +61,17 @@ static __init bool uefi_check_trust_mok_keys(void) return false; } + +bool __init trust_moklist(void) +{ + static bool initialized; + + if (!initialized) { + initialized = true; + + if (uefi_check_trust_mok_keys()) + trust_mok = true; + } + + return trust_mok; +}