Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp942151iob; Fri, 13 May 2022 17:13:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy3JEZhaBR3/eLKpBGu+vSCJwdPT6k0FiD+dx8uC8ooFsjzat46UFWVyJ9LfswbRd6qOXwk X-Received: by 2002:a05:6000:1a44:b0:20a:ccde:c139 with SMTP id t4-20020a0560001a4400b0020accdec139mr5698428wry.320.1652487237506; Fri, 13 May 2022 17:13:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652487237; cv=none; d=google.com; s=arc-20160816; b=FB511AWnI3rN/YscdnvAOuXvyfANWsl7N6L/HJVwOwAgwGy9giSCZr1pfZX6GZQiXr 72B7Tu8Ko29ohPhFcmJXsQhFObSCB3/vC9qn6s4c1JgFI8FQNoI70R0s/coopbH8H9kJ OJP/kFnKHkOCw2BbwJ6KKNXGiimbvlhpHbt5nY5bUjHtqRWU7X6xCxy5FX8I2wfnIP0k dL4fuP0uEZUB2iqOIaEKeDhey+msk+5hxWrWMqvuja43WhA854RT1Sam4LU5Hbl/sEiP zGMMNjIm33TU9VqHuvrfjxUBAzk439lQwvh49Ct86slAXS+j3l/C3gTqtYBkYdJeMtK4 K0kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=AUV1xEazjWXY63tfW7HNmR3TtmSUkdVdBcreZvOq/Dw=; b=Ddli7LVapwtPbv7UfSxkNrVXFolaIqyq4hoxydSkW8qqFMlTec6L2YxTV0q2l2TwGM 68Ez3Uy5dQDHgXKzW7cV4ybfpap/OevVJdqFDigCiY0r3pgAwVxjE4z1UrXVwG57Old1 FoayqPv8Yq6qHV9I0u/nqG4RxwXEto31sOx5nRQ2eJMUNsMRB91c/A4lrNSAfbmUX/O2 1aEdWhr9BrBENJn+UHBfhHsvBaRAhNq8upz3tyxp2qonk7MLZvjmbtkNeUn4xXoUbr6q SLVYmAM7MIdcjLi1CDQn7Y8C0An4brQsmifjYiUYHw5FXKkVSpJZM+YuE7NwsGrknC2I xWhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SU1Y5UeY; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id v12-20020a05600c214c00b0038ebbdaa671si3307563wml.79.2022.05.13.17.13.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 17:13:57 -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=@chromium.org header.s=google header.b=SU1Y5UeY; 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=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 89640321D5F; Fri, 13 May 2022 16:14:36 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382578AbiEMQyb (ORCPT + 99 others); Fri, 13 May 2022 12:54:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382704AbiEMQyU (ORCPT ); Fri, 13 May 2022 12:54:20 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7000E56C2E for ; Fri, 13 May 2022 09:53:06 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id x8so4604500pgr.4 for ; Fri, 13 May 2022 09:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=AUV1xEazjWXY63tfW7HNmR3TtmSUkdVdBcreZvOq/Dw=; b=SU1Y5UeYFEIiSvMSa7oSYvsdj5jyUJnf3NY38OUjCQASpT4Z3aAcq4PZ7LFqBQnkRB CbpHiDuaHHvIYSCP0vwq6hA/6Qed4I0YURCe/v7MGM8BQsLY3GvqZVKXKPjQZojDMPYO GkPZFbbIrrnEWxUlgs3VrCrFMozz6U62PUshY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=AUV1xEazjWXY63tfW7HNmR3TtmSUkdVdBcreZvOq/Dw=; b=bPbg9IXLVor/ygIHRQ+QrmEcG9lswfoiTrlt27Y2SpQXPclIAsehXS1DHTwtXMZY6U Qtywj1FEa6x+YsmKWBXkptltTsdmyLI2LOD+MlnHXqcbZHnnNchewOIR0UmEDzkUU35e 1Szl7doKKXrpRH7ekoXTOiZeyP8hLUdFA+X/sfXhh3tYU8orzo4yVCSWqTut3jQArdy9 EvG72CJVQ/QvcqLDR3AtXiAqU5Cj2lgIW3VVEemgntirgJAFp/KosLT9tEf5sd5g0AFp r0VvoxE/fwEmqWhgtaUzIRDWzEEwEs2r4S1gtgJKQPD6bv5NAHXz9yej9cEfVXQ4/Ia/ VpZg== X-Gm-Message-State: AOAM533zFJG0qm4FLEAa87hJ1nQ/6uLmIc6nixh1YqRnooMb/WHmihvn OJ9KUCpaK8hXpFYNGDAntGwpKQ== X-Received: by 2002:a63:5513:0:b0:3c3:7bfa:c3ea with SMTP id j19-20020a635513000000b003c37bfac3eamr4648709pgb.243.1652460786017; Fri, 13 May 2022 09:53:06 -0700 (PDT) Received: from localhost ([2620:15c:11a:202:bc87:9632:bcce:8e17]) by smtp.gmail.com with UTF8SMTPSA id u14-20020a170902714e00b00160c970eeb7sm1861475plm.234.2022.05.13.09.53.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 May 2022 09:53:05 -0700 (PDT) Date: Fri, 13 May 2022 09:53:04 -0700 From: Matthias Kaehlcke To: Mike Snitzer Cc: Alasdair Kergon , Mike Snitzer , Kees Cook , James Morris , "Serge E . Hallyn" , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-raid@vger.kernel.org, Song Liu , Douglas Anderson , linux-security-module@vger.kernel.org Subject: Re: [PATCH v3 1/3] dm: Add verity helpers for LoadPin Message-ID: References: <20220504195419.1143099-1-mka@chromium.org> <20220504125404.v3.1.I3e928575a23481121e73286874c4c2bdb403355d@changeid> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 Fri, May 13, 2022 at 12:29:29PM -0400, Mike Snitzer wrote: > On Thu, May 12 2022 at 4:44P -0400, > Matthias Kaehlcke wrote: > > > On Thu, May 12, 2022 at 01:19:12PM -0400, Mike Snitzer wrote: > > > On Wed, May 11 2022 at 4:54P -0400, > > > Matthias Kaehlcke wrote: > > > > > > > Alasdar/Mike, I'd be interested in your take on adding these functions > > > > to verity/DM, to get an idea whether this series has a path forward to > > > > landing upstream. > > > > > > I'll be reviewing your patchset now. Comments inlined below. > > > > > > > On Wed, May 04, 2022 at 12:54:17PM -0700, 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 > > > > > --- > > > > > > > > > > Changes in v3: > > > > > - none > > > > > > > > > > Changes in v2: > > > > > - none > > > > > > > > > > drivers/md/Makefile | 6 +++ > > > > > 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 +++++++++++ > > > > > 5 files changed, 150 insertions(+) > > > > > create mode 100644 drivers/md/dm-verity-loadpin.c > > > > > create mode 100644 include/linux/dm-verity-loadpin.h > > > > > > > > > > diff --git a/drivers/md/Makefile b/drivers/md/Makefile > > > > > index 0454b0885b01..e12cd004d375 100644 > > > > > --- a/drivers/md/Makefile > > > > > +++ b/drivers/md/Makefile > > > > > @@ -100,6 +100,12 @@ ifeq ($(CONFIG_IMA),y) > > > > > dm-mod-objs += dm-ima.o > > > > > endif > > > > > > > > > > +ifeq ($(CONFIG_DM_VERITY),y) > > > > > +ifeq ($(CONFIG_SECURITY_LOADPIN),y) > > > > > +dm-mod-objs += dm-verity-loadpin.o > > > > > +endif > > > > > +endif > > > > > + > > > > > > Why are you extending dm-mod-objs? Why not dm-verity-objs? > > > > Sorry, I missed to address this comment in my earlier reply. > > > > I don't recall why I chose dm-mod-objs initially, agreed that > > dm-verity-objs seems a better fit. > > Yes, should be fixed even though the 3rd patch removes this change. Sure > BTW, looking at the 2nd patch's loadpin_is_fs_trusted(). Seems to me > you'd do well to pass a 'struct block_device *' to a DM helper rather > than force security/loadpin/loadpin.c to mess around with DM device > refcounting, etc. Sounds good to me. Thanks for the suggestion!