Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp245150iob; Wed, 18 May 2022 01:00:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxdkNRoM+hdc+5IG0/O9kD166AS6EZsCCgqpfEw6cvtHRwVOgDehU5fjuC5oTZZ6FBgqTCS X-Received: by 2002:a17:902:aa4b:b0:15f:b2c:73c7 with SMTP id c11-20020a170902aa4b00b0015f0b2c73c7mr26204131plr.164.1652860820216; Wed, 18 May 2022 01:00:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652860820; cv=none; d=google.com; s=arc-20160816; b=r/H8a0dW4T4oCaHCGV+t8z6QXomqPMz/YB/CRgfxbLJ1Umxt8XFDX+rgPJiJ8/K+SO rudvn6HRby3UqB4NCC4bL7QRngvuci4eudtkuzt8agPZgwpP+SGMRLuGUZJFCFHbM0Ed 6TeGc6T6a2y9ZqAYfBnZRKhl0eT6fSIP8jywYV25n09GPzD0IgjdUEDjbz+dbhOj1qFU wn+PjzEdnUAppA/6n7WpPOmhGXhBqDuoePDI1RXkT+q0XlVgV0DD0IaPBd0d3SrTbWNw SBEEM4WT0Ni0esriGFzbyp9wGm56vIRo2myzoLhZ9n6GFJefYIuZr5ostLtqe/rp/RQ4 8dag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=7ktjmA9lbYY+r3k7Xl4dUBOmRn/WA+0dOC0w53gvyVI=; b=gqru7OTAtSXr/0TwxCRVMtH1bw6T2RcPhEOsJ0Mvf1xTFqUjupExrsnwJ3cYt2NMad uQY4HRDEBIkoCFvUdg74zKp8ssy/OOzoGt9tNaeWHRrD6+eJk/o9ywXBy6OMRwV2+E5V fJ9JoLDIMyWHbsVvhC2QOp6VyvWruvJpZqCXmmAEcNHGLPxJbtUyokOGIP1y6JOhK9Ib YTjZwCbyj1nWgq/4kWfBEdigDms2kqUp2g0QuFWzDhvgJTDv/jcKqxtweqMbQ40/1OM5 KjkBAKTkP8MoVPhIIaw7hRQXo5ZjOetxXGyen4ts6K3oNUMWn/M0lIPLsqPwZrFXPzkP mycQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X0zcqKIT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id r1-20020aa79ec1000000b00517cafbba6csi2033000pfq.145.2022.05.18.01.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 01:00:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X0zcqKIT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7A6CF1207CE; Wed, 18 May 2022 00:58:26 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232789AbiERH5t (ORCPT + 99 others); Wed, 18 May 2022 03:57:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232769AbiERH5s (ORCPT ); Wed, 18 May 2022 03:57:48 -0400 Received: from mail-ej1-x636.google.com (mail-ej1-x636.google.com [IPv6:2a00:1450:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ACCC118007; Wed, 18 May 2022 00:57:47 -0700 (PDT) Received: by mail-ej1-x636.google.com with SMTP id i19so2126166eja.11; Wed, 18 May 2022 00:57:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=7ktjmA9lbYY+r3k7Xl4dUBOmRn/WA+0dOC0w53gvyVI=; b=X0zcqKITNYv1TLoj7hswq47oFfYJ7vnsmf3gLIsQ7si/uX69O69xbpuznQyl96N2KR 6xl+3NoBa6wa9trbSHLKUdcI/doQHK8unsfCuQHXKvz9oYTQKR+RV31uM75p30dYaQu8 EAkBrThXrZJusSX8iicfNV1vRQQnBc81rGVtDvJdIa5EITWBcbnKBsEtPPJ1jV3MD8bU XQEp3gdMeslcQY8gcRFIY5A+LH35hlhCVRdPv3WIF06Kyfyzazkti9tdidslDYjaxYva 2L1uTNvWeoRBrq3ohGmn4BKzSLH4n6Xc3T7NX1v1HrUjgoTAglis9mleel6rzIWqN5E+ 4edg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=7ktjmA9lbYY+r3k7Xl4dUBOmRn/WA+0dOC0w53gvyVI=; b=LfsSVB0MEIMk7pGtSiEbvhsgkYxGwxroA7nFtmNUTPCrUYZsAgspKAafMrtaZ/iP1K 6DxVcp8r5otFu4It6GkKS3bNcAYBnrydrM/umiWB5Ey+PMZlCCNwECZwZy2xyas7K3xd l+EO9b29QV9nNFb/hphQN9fjrd5ELCH4uzgJSC2wGqlXJ2ykLGuL1Rlk/ZfZuf04WX9G allNgTLLHDW+W9osh5Tb7uk2IOX+/6f+BKdOuPa4zhHYowYgM7mD4czvnwHtDCFT++j4 ybV/+9cndx/G7R90gki46SK6Ez5qLcLMq9RHVAq9MPICeiYX2+EFQn/mX5sVpCjBbENB S/Sg== X-Gm-Message-State: AOAM533SqgPGR5jV8Pq9nTs5HqM+lsiSBMpehxeaS4aGAqhIBpjDspeR ceyrYaFmFwVP3XINjDZRNec= X-Received: by 2002:a17:907:7216:b0:6f4:70d4:a3c4 with SMTP id dr22-20020a170907721600b006f470d4a3c4mr22754545ejc.529.1652860665411; Wed, 18 May 2022 00:57:45 -0700 (PDT) Received: from [192.168.2.27] (85-70-151-113.rcd.o2.cz. [85.70.151.113]) by smtp.gmail.com with ESMTPSA id ee46-20020a056402292e00b0042617ba63aesm928060edb.56.2022.05.18.00.57.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 May 2022 00:57:44 -0700 (PDT) Message-ID: <19149028-ec94-8f64-aed4-1e58f29942a8@gmail.com> Date: Wed, 18 May 2022 09:57:43 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Subject: Re: [dm-devel] [PATCH v4 1/3] dm: Add verity helpers for LoadPin Content-Language: en-US To: Matthias Kaehlcke , Alasdair Kergon , Mike Snitzer , Kees Cook , James Morris , "Serge E . Hallyn" Cc: dm-devel@redhat.com, Douglas Anderson , linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu , linux-security-module@vger.kernel.org References: <20220517233457.1123309-1-mka@chromium.org> <20220517163437.v4.1.I3e928575a23481121e73286874c4c2bdb403355d@changeid> From: Milan Broz In-Reply-To: <20220517163437.v4.1.I3e928575a23481121e73286874c4c2bdb403355d@changeid> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/05/2022 01:34, Matthias Kaehlcke wrote: > LoadPin limits loading of kernel modules, firmware and certain > other files to a 'pinned' file system (typically a read-only > rootfs). To provide more flexibility LoadPin is being extended > to also allow loading these files from trusted dm-verity > devices. For that purpose LoadPin can be provided with a list > of verity root digests that it should consider as trusted. > > Add a bunch of helpers to allow LoadPin to check whether a DM > device is a trusted verity device. The new functions broadly > fall in two categories: those that need access to verity > internals (like the root digest), and the 'glue' between > LoadPin and verity. The new file dm-verity-loadpin.c contains > the glue functions. > > Signed-off-by: Matthias Kaehlcke ... > + > + if (dm_verity_get_root_digest(ti, &root_digest, &digest_size)) > + return false; Almost unrelated note, but as there are more and more situations that checks verity root digest, shouldn't we export this as read-only sysfs attribute for DM verity devices? Attacker can always calculate (but not change) Merkle tree, so this is not something that need to be hidden. It would allow userspace to easily enumerate trusted DM devices without calling kernel ioctls... ... > + > + table = dm_get_live_table(md, &srcu_idx); > + > + if (dm_table_get_num_targets(table) != 1) > + goto out; > + > + ti = dm_table_get_target(table, 0); > + > + if (is_trusted_verity_target(ti)) > + trusted = true; What happens is someone reloads verity table later with a different content (or even different target type)? Does LoadPin even care here? ... > static struct target_type verity_target = { > .name = "verity", > .version = {1, 8, 0}, Please increase the minor version, it is very useful to detect (in logs) that the target driver has compatible extensions. I guess this change does not affect userspace veristysetup (as it is used handled by different tooling), right? Thanks, Milan