Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp738803ybg; Tue, 28 Jul 2020 18:21:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUhRA9416UFRcY9vWmEjyc0vzjYG3Y7J67k5EMeY/I72EQW+VWuxIGOedhH4lmHS1oZ4Im X-Received: by 2002:a17:906:9618:: with SMTP id s24mr17123114ejx.53.1595985672582; Tue, 28 Jul 2020 18:21:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595985672; cv=none; d=google.com; s=arc-20160816; b=Kn0zPefzvIA0qPTuBFENjRufNzjb+GFfkMYp1jCJzB9xUXLYlWAcqGPeoO/nmX/dqJ 5Y2V/Y/h5foHka7Dxs+qR7Bld9v9faJZauag+sJy0MDAN6GTiCztSf+oJ+qMCFQnG+RJ 3RGcvcymnUjcMd8ZDVn16i6n6a4MojS03Y9VhDZg3H6gMxlSGAMoAGUZlDfnE32MwiZ9 ueRaDJRZglpbkfD2xtgUKiVABXjN0PfumjGZR9d0jOmbclDqBRAw5JilqbaHwV3gPS74 lERjmrz5Q+p/39ZTWweDwgZsffc3avCbrDtemeFLkZ7p9mn091ONBw2cgzaMCkPC7+cA hGkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=eDz3jy7eZdANBgDM2Qg5Gfk+gkOF0GMv74gm4dMaCys=; b=C+SygTxSO+7oc7nA6HDbWdYmLHc9V6jgLN0Omg2Q2r7PvWLDgqKdHvTb0YJ1m98KOq 0QtZwObl2sly+L8y5G4gTFcNEyDrhnTtbijiEp1BFQTDhnPJwi/HosjjsFvR7jD5oARw mgqqu60D8wvDrcj7Z86wjWqvOTsRp+Wa2BVbeE0MwsEzxqMUmnJCTuKcjUE/m+zU6DGH deQSBM9LxlE2LvqfvhheCXnTw17M51/jLHm98qopZ8YngT18efGmViPy8+Z7EUv2EUl7 NKzHtvrLhk7UkfbgGuHepacmxY+VtCDV/Dt+q9UN2kEnTPBh0/fJC/DcHtvruUAM2t++ OPew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si152117ejd.265.2020.07.28.18.20.50; Tue, 28 Jul 2020 18:21:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730278AbgG2BUn (ORCPT + 99 others); Tue, 28 Jul 2020 21:20:43 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:45221 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728364AbgG2BUn (ORCPT ); Tue, 28 Jul 2020 21:20:43 -0400 Received: by mail-io1-f68.google.com with SMTP id e64so22806868iof.12; Tue, 28 Jul 2020 18:20:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=eDz3jy7eZdANBgDM2Qg5Gfk+gkOF0GMv74gm4dMaCys=; b=DYxIhqM5r1lwQWn/oKu/GHM+beVzgKZcX8IUieyrIqTKyQf4ZOLZF0X9eHy+30/6D+ V5b5rXdLxfMYaU4E3ti4rorDvefFn6zX42GgcLZ3rAcKm2OFY0awRai/XHS+t5d/dUB1 K1SFjls1NDqpB5XdQUSdLlvEnRu+PQJXBMQ1NPnNCoRI9Xh1d+FvO7mQA8t4UT2zwrEL drWnuKc++9l6s1Hzst8AQyxUWRixeEJU6Enyw5z/RKXELH9cr0wsHcUQsrkPRg9WIQuN 1IkMVebhRCBuQP4qRMlyAsEzoTcT+18PwgsAFa4tpT0tmpxvnOdMburq/NaIZnzYSJ4C 0jpg== X-Gm-Message-State: AOAM5324jdTQZPILmDKynnE9jmhuvKnUWBG1DUFEWfVmGedA9ZnINrFT 1Uk6KXrimev8xL3AReTsvC0= X-Received: by 2002:a05:6602:24d5:: with SMTP id h21mr28941626ioe.108.1595985641893; Tue, 28 Jul 2020 18:20:41 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id x185sm230006iof.41.2020.07.28.18.20.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Jul 2020 18:20:40 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id F384D40945; Wed, 29 Jul 2020 01:20:39 +0000 (UTC) Date: Wed, 29 Jul 2020 01:20:39 +0000 From: Luis Chamberlain To: Kees Cook Cc: Mimi Zohar , Christoph Hellwig , viro@zeniv.linux.org.uk, gregkh@linuxfoundation.org, rafael@kernel.org, ebiederm@xmission.com, jeyu@kernel.org, jmorris@namei.org, paul@paul-moore.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, nayna@linux.ibm.com, scott.branden@broadcom.com, dan.carpenter@oracle.com, skhan@linuxfoundation.org, geert@linux-m68k.org, tglx@linutronix.de, bauerman@linux.ibm.com, dhowells@redhat.com, linux-integrity@vger.kernel.org, linux-fsdevel@vger.kernel.org, kexec@lists.infradead.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 0/3] fs: reduce export usage of kerne_read*() calls Message-ID: <20200729012039.GN4332@42.do-not-panic.com> References: <20200513152108.25669-1-mcgrof@kernel.org> <20200513181736.GA24342@infradead.org> <20200515212933.GD11244@42.do-not-panic.com> <20200518062255.GB15641@infradead.org> <1589805462.5111.107.camel@linux.ibm.com> <202005180820.46CEF3C2@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202005180820.46CEF3C2@keescook> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 18, 2020 at 08:21:08AM -0700, Kees Cook wrote: > On Mon, May 18, 2020 at 08:37:42AM -0400, Mimi Zohar wrote: > > Hi Christoph, > > > > On Sun, 2020-05-17 at 23:22 -0700, Christoph Hellwig wrote: > > > On Fri, May 15, 2020 at 09:29:33PM +0000, Luis Chamberlain wrote: > > > > On Wed, May 13, 2020 at 11:17:36AM -0700, Christoph Hellwig wrote: > > > > > Can you also move kernel_read_* out of fs.h? That header gets pulled > > > > > in just about everywhere and doesn't really need function not related > > > > > to the general fs interface. > > > > > > > > Sure, where should I dump these? > > > > > > Maybe a new linux/kernel_read_file.h? Bonus points for a small top > > > of the file comment explaining the point of the interface, which I > > > still don't get :) > > > > Instead of rolling your own method of having the kernel read a file, > > which requires call specific security hooks, this interface provides a > > single generic set of pre and post security hooks.??The > > kernel_read_file_id enumeration permits the security hook to > > differentiate between callers. > > > > To comply with secure and trusted boot concepts, a file cannot be > > accessible to the caller until after it has been measured and/or the > > integrity (hash/signature) appraised. > > > > In some cases, the file was previously read twice, first to measure > > and/or appraise the file and then read again into a buffer for > > use.??This interface reads the file into a buffer once, calls the > > generic post security hook, before providing the buffer to the caller. > > ?(Note using firmware pre-allocated memory might be an issue.) > > > > Partial reading firmware will result in needing to pre-read the entire > > file, most likely on the security pre hook. > > Well described! :) Since you're moving all this stuff, it woudl be good if you can add this as part of new kdoc as well. Luis