From mboxrd@z Thu Jan 1 00:00:00 1970 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 3350CC433FE for ; Wed, 4 May 2022 19:54:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377756AbiEDT6H (ORCPT ); Wed, 4 May 2022 15:58:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356315AbiEDT6C (ORCPT ); Wed, 4 May 2022 15:58:02 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A33574E3B4 for ; Wed, 4 May 2022 12:54:24 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id x52so1935905pfu.11 for ; Wed, 04 May 2022 12:54:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h3ETif9Foq2WWYlVvzrpzb/TRJhspVBRsqqlMfFf5RE=; b=bFEhgow2kthggDsRYWLjsBQ4oqoD9Yx8p7YoLuIFcg6vkGF5NKTVgGyZpwGKN6j9jQ +eCtLxowhfkljQHHR59zJXDVT8hHq4w54MuvBi6DL2GEsR19pG11rDyZ80nLiS9a3Gy2 tAO+XKAFFwijLwnlZFmqAIx6vIYSugE1RfQrM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h3ETif9Foq2WWYlVvzrpzb/TRJhspVBRsqqlMfFf5RE=; b=TKVQNun5YRiizNDchfnAEXbsTYi313h0oRKkI22fx8OxyE/v4VzqE9p41+nQ3lD3un u/utjSSV/ucphgLngRsvMxCpo44FS5EdMeln8yExBvInRTvpIWuaKlHzvJk6D6RG8FMK DhfvJIrxmCvyJywMqjoF8pYBF5rXQJkUEJcAmeAmFzp09U+FTJqkFMtl8CYjvUQ3Ybya r2ffeFJan9OUzp/scrgzhXUNUkNtLTVrC3huczD+0wey5Cg9lK9nZqPaKg/JcB3EsN3W 6G0gIVF2CP163RtC4hul0vVBR0Kv9Y7uQPhTBv5g/k9KKrTHFsORuzoNMrvB3OXiQdXl jLtQ== X-Gm-Message-State: AOAM5334uvpVGFMr2TcHDzLgN7KDRsvP3iJTWtaLKy6976pJSUf1lLdf PqhNwsE6gfOcbavH57XifBERMQ== X-Google-Smtp-Source: ABdhPJw3OEAXuCRHeeH+ekWBhlrlqMKIX2kvZ+3Yz7JTRDJfzJoF2x0zxnO0Fgykowymq6svm7lI3g== X-Received: by 2002:a65:6051:0:b0:39d:1b00:e473 with SMTP id a17-20020a656051000000b0039d1b00e473mr18737927pgp.578.1651694063968; Wed, 04 May 2022 12:54:23 -0700 (PDT) Received: from localhost ([2620:15c:202:201:35b6:c77b:be04:3bd5]) by smtp.gmail.com with UTF8SMTPSA id v13-20020aa7808d000000b0050dc762819esm8622355pff.120.2022.05.04.12.54.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 May 2022 12:54:23 -0700 (PDT) From: Matthias Kaehlcke To: Alasdair Kergon , Mike Snitzer , Kees Cook , James Morris , "Serge E . Hallyn" Cc: dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu , Douglas Anderson , linux-security-module@vger.kernel.org, Matthias Kaehlcke Subject: [PATCH v3 0/3] LoadPin: Enable loading from trusted dm-verity devices Date: Wed, 4 May 2022 12:54:16 -0700 Message-Id: <20220504195419.1143099-1-mka@chromium.org> X-Mailer: git-send-email 2.36.0.464.gb9c8b46e94-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-raid@vger.kernel.org As of now LoadPin restricts loading of kernel files to a single pinned filesystem, typically the rootfs. This works for many systems, however it can result in a bloated rootfs (and OTA updates) on platforms where multiple boards with different hardware configurations use the same rootfs image. Especially when 'optional' files are large it may be preferable to download/install them only when they are actually needed by a given board. Chrome OS uses Downloadable Content (DLC) [1] to deploy certain 'packages' at runtime. As an example a DLC package could contain firmware for a peripheral that is not present on all boards. DLCs use dm-verity [2] to verify the integrity of the DLC content. This series extends LoadPin to allow loading of kernel files from trusted dm-verity devices. LoadPin maintains a list of root digests of verity devices it considers trusted. Userspace can populate this list through an ioctl on the new LoadPin securityfs entry 'dm-verity'. The ioctl receives a file descriptor of a file with verity digests as parameter. Verity reads the digests from this file after confirming that the file is located on the pinned root. The list of trusted digests can only be set up once, which is typically done at boot time. When a kernel file is read LoadPin first checks (as usual) whether the file is located on the pinned root, if so the file can be loaded. Otherwise, if the verity extension is enabled, LoadPin determines whether the file is located on a verity backed device and whether the root digest of that device is in the list of trusted digests. The file can be loaded if the verity device has a trusted root digest. [1] https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/dlcservice/docs/developer.md [2] https://www.kernel.org/doc/html/latest/admin-guide/device-mapper/verity.html Changes in v3: - added securityfs for LoadPin (currently only populated when CONFIG_SECURITY_LOADPIN_VERITY=y) - added uapi include for LoadPin - changed the interface for setting up the list of trusted digests from sysctl to ioctl on securityfs entry - added stub for loadpin_is_fs_trusted() to be used CONFIG_SECURITY_LOADPIN_VERITY is not select - depend on CONFIG_SECURITYFS instead of CONFIG_SYSTCL - updated Kconfig help - minor changes in read_trusted_verity_root_digests() - updated commit message Changes in v2: - userspace now passes the path of the file with the verity digests via systcl, instead of the digests themselves - renamed sysctl file to 'trusted_verity_root_digests_path' - have CONFIG_SECURITY_LOADPIN_VERITY depend on CONFIG_SYSCTL - updated Kconfig doc - updated commit message Matthias Kaehlcke (3): dm: Add verity helpers for LoadPin LoadPin: Enable loading from trusted dm-verity devices dm: verity-loadpin: Use CONFIG_SECURITY_LOADPIN_VERITY for conditional compilation drivers/md/Makefile | 1 + drivers/md/dm-verity-loadpin.c | 80 +++++++++++++ drivers/md/dm-verity-target.c | 33 ++++++ drivers/md/dm-verity.h | 4 + include/linux/dm-verity-loadpin.h | 27 +++++ include/uapi/linux/loadpin.h | 19 +++ security/loadpin/Kconfig | 16 +++ security/loadpin/loadpin.c | 184 +++++++++++++++++++++++++++++- 8 files changed, 363 insertions(+), 1 deletion(-) create mode 100644 drivers/md/dm-verity-loadpin.c create mode 100644 include/linux/dm-verity-loadpin.h create mode 100644 include/uapi/linux/loadpin.h -- 2.36.0.464.gb9c8b46e94-goog From mboxrd@z Thu Jan 1 00:00:00 1970 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B09AC4332F for ; Wed, 4 May 2022 21:23:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-283-g_azVD7xMEeQTnJD5_CsGw-1; Wed, 04 May 2022 17:23:32 -0400 X-MC-Unique: g_azVD7xMEeQTnJD5_CsGw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 179B529ABA05; Wed, 4 May 2022 21:23:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01231C28117; Wed, 4 May 2022 21:23:30 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id C19481947047; Wed, 4 May 2022 21:23:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 3F8E31947043 for ; Wed, 4 May 2022 19:54:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1C3FDC27EBD; Wed, 4 May 2022 19:54:27 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast08.extmail.prod.ext.rdu2.redhat.com [10.11.55.24]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 184BDC27EB0 for ; Wed, 4 May 2022 19:54:27 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id F17E93AF42A8 for ; Wed, 4 May 2022 19:54:26 +0000 (UTC) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-255-oY0Fnh3NMVqmR3Pzkg_EuQ-1; Wed, 04 May 2022 15:54:25 -0400 X-MC-Unique: oY0Fnh3NMVqmR3Pzkg_EuQ-1 Received: by mail-pf1-f177.google.com with SMTP id h1so1934626pfv.12 for ; Wed, 04 May 2022 12:54:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=h3ETif9Foq2WWYlVvzrpzb/TRJhspVBRsqqlMfFf5RE=; b=0AGxWdCuYrt5QXwDQx79NDRuRd7wYVpBEBqumzeJmzJsnANg4wed21VAZDdPEHedOV q7Ahbi+mK8kq3JAA7joCCAFAw/SeXTYMZFDTiNAmLkZyDM9I383drJshAgU0wfom/TRH hxci9iJITqAoOz6nZWxk1LaPiOM2PO8Boee3WMHyWnnqwCMOP03TTs35vMJC21v7zruJ z0vMMibS4lyA7umxAkLcNeuAKwisihcZttaxsW9ao6b3LFszMs6KozJN2FGkqo/VkIVq 4atKNFhh2kVc5nazw3zAySy/eJIIRKWctb9AU1Zdugld2P+mM3te6YULuWmALiSdg9bx It2A== X-Gm-Message-State: AOAM530JZsMX13nFBC2rDrIzLtkk3tOBD9JCKVI5cDRvE14YmdSLzp/x MM37zjKCkQ1n91RF5GSlpg3K5Q== X-Google-Smtp-Source: ABdhPJw3OEAXuCRHeeH+ekWBhlrlqMKIX2kvZ+3Yz7JTRDJfzJoF2x0zxnO0Fgykowymq6svm7lI3g== X-Received: by 2002:a65:6051:0:b0:39d:1b00:e473 with SMTP id a17-20020a656051000000b0039d1b00e473mr18737927pgp.578.1651694063968; Wed, 04 May 2022 12:54:23 -0700 (PDT) Received: from localhost ([2620:15c:202:201:35b6:c77b:be04:3bd5]) by smtp.gmail.com with UTF8SMTPSA id v13-20020aa7808d000000b0050dc762819esm8622355pff.120.2022.05.04.12.54.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 04 May 2022 12:54:23 -0700 (PDT) From: Matthias Kaehlcke To: Alasdair Kergon , Mike Snitzer , Kees Cook , James Morris , "Serge E . Hallyn" Date: Wed, 4 May 2022 12:54:16 -0700 Message-Id: <20220504195419.1143099-1-mka@chromium.org> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 X-Mailman-Approved-At: Wed, 04 May 2022 21:23:25 +0000 Subject: [dm-devel] [PATCH v3 0/3] LoadPin: Enable loading from trusted dm-verity devices X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Douglas Anderson , linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu , dm-devel@redhat.com, Matthias Kaehlcke Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit As of now LoadPin restricts loading of kernel files to a single pinned filesystem, typically the rootfs. This works for many systems, however it can result in a bloated rootfs (and OTA updates) on platforms where multiple boards with different hardware configurations use the same rootfs image. Especially when 'optional' files are large it may be preferable to download/install them only when they are actually needed by a given board. Chrome OS uses Downloadable Content (DLC) [1] to deploy certain 'packages' at runtime. As an example a DLC package could contain firmware for a peripheral that is not present on all boards. DLCs use dm-verity [2] to verify the integrity of the DLC content. This series extends LoadPin to allow loading of kernel files from trusted dm-verity devices. LoadPin maintains a list of root digests of verity devices it considers trusted. Userspace can populate this list through an ioctl on the new LoadPin securityfs entry 'dm-verity'. The ioctl receives a file descriptor of a file with verity digests as parameter. Verity reads the digests from this file after confirming that the file is located on the pinned root. The list of trusted digests can only be set up once, which is typically done at boot time. When a kernel file is read LoadPin first checks (as usual) whether the file is located on the pinned root, if so the file can be loaded. Otherwise, if the verity extension is enabled, LoadPin determines whether the file is located on a verity backed device and whether the root digest of that device is in the list of trusted digests. The file can be loaded if the verity device has a trusted root digest. [1] https://chromium.googlesource.com/chromiumos/platform2/+/HEAD/dlcservice/docs/developer.md [2] https://www.kernel.org/doc/html/latest/admin-guide/device-mapper/verity.html Changes in v3: - added securityfs for LoadPin (currently only populated when CONFIG_SECURITY_LOADPIN_VERITY=y) - added uapi include for LoadPin - changed the interface for setting up the list of trusted digests from sysctl to ioctl on securityfs entry - added stub for loadpin_is_fs_trusted() to be used CONFIG_SECURITY_LOADPIN_VERITY is not select - depend on CONFIG_SECURITYFS instead of CONFIG_SYSTCL - updated Kconfig help - minor changes in read_trusted_verity_root_digests() - updated commit message Changes in v2: - userspace now passes the path of the file with the verity digests via systcl, instead of the digests themselves - renamed sysctl file to 'trusted_verity_root_digests_path' - have CONFIG_SECURITY_LOADPIN_VERITY depend on CONFIG_SYSCTL - updated Kconfig doc - updated commit message Matthias Kaehlcke (3): dm: Add verity helpers for LoadPin LoadPin: Enable loading from trusted dm-verity devices dm: verity-loadpin: Use CONFIG_SECURITY_LOADPIN_VERITY for conditional compilation drivers/md/Makefile | 1 + drivers/md/dm-verity-loadpin.c | 80 +++++++++++++ drivers/md/dm-verity-target.c | 33 ++++++ drivers/md/dm-verity.h | 4 + include/linux/dm-verity-loadpin.h | 27 +++++ include/uapi/linux/loadpin.h | 19 +++ security/loadpin/Kconfig | 16 +++ security/loadpin/loadpin.c | 184 +++++++++++++++++++++++++++++- 8 files changed, 363 insertions(+), 1 deletion(-) create mode 100644 drivers/md/dm-verity-loadpin.c create mode 100644 include/linux/dm-verity-loadpin.h create mode 100644 include/uapi/linux/loadpin.h -- 2.36.0.464.gb9c8b46e94-goog -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel