Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2808285ybk; Mon, 18 May 2020 08:24:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyafPH03cYxjqBAWLzBnOrChOntVoN1EqyjgRUfF1wExBkq0gD6MHaY46oXOXjfksOtqOVr X-Received: by 2002:a50:f40e:: with SMTP id r14mr13298244edm.241.1589815440464; Mon, 18 May 2020 08:24:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589815440; cv=none; d=google.com; s=arc-20160816; b=D4Y+OeQ0YgphDEg+gpw2831DMa4frVjw8y042CL+TmbI3zmd7CVhrK+SmCfW2NV29V 4ckU0RZNt0RYXxM0PkdeXSoiQU2E4vc/NUEW+arzqv3txQsephdcLEQrW4O6SnduQJRA SipLUlVHLXOuRh1XCRbOF3gvkW7wTN/irv2oqgkAdKTFCUHtT3WmtcCWwTlv4yxxYuLc S1a8uYRr9eso98bsENYasiegqJif/OxP1xCQqlcmG9+Muk7IDA41iv47nCBWRpJnOtai Nf3l68P/OUqUPGLNX7vhxthVUzDjvj/vUpvWMmbMeR98ygcfrpCr1rkKG5okAkDL9HY8 STiQ== 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:dkim-signature; bh=8eIa0Vhcalrg30hExhgbFyLNmHPU3sV6rgHITb5pZ5w=; b=IaH6EBsjUwZpPW2Jmvlw9d8iKHEcBWopLgPkfZfainjgYHBckpjqDNPtzTm0pjxNpL p9CeFIIy3UDlI7WpN1UNxMxU7okHVLiAOqBeJzyuteqXLfNuT0tXS2YKtVSlcHBkcbFx fLsUjnkuyE/WL2eI9UmB1ZxaHMFNY75OsPj5cmH3hxJqYHBVa9g1rw0iSk0j9zB3hRlP kCtXWdMLzZ4LmwDmSTyOebUoXmWTR/fh35/vtQ7iyj3gVYanrrAOdOR7E33dW4SK8IlY REuBnxlX5Ldl+dOlHXljHS+CVkdSyba/L49KaZEUhpLrxypEp9Y5LBCrq65MPIBzWFuz 9Fgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=htaIZ7s8; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p2si3986506ejn.494.2020.05.18.08.23.36; Mon, 18 May 2020 08:24:00 -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; dkim=pass header.i=@chromium.org header.s=google header.b=htaIZ7s8; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728338AbgERPVL (ORCPT + 99 others); Mon, 18 May 2020 11:21:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727942AbgERPVL (ORCPT ); Mon, 18 May 2020 11:21:11 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E630C05BD0B for ; Mon, 18 May 2020 08:21:11 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id y18so5099257pfl.9 for ; Mon, 18 May 2020 08:21:11 -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:content-transfer-encoding:in-reply-to; bh=8eIa0Vhcalrg30hExhgbFyLNmHPU3sV6rgHITb5pZ5w=; b=htaIZ7s8kHdd9JhXfpJr62T+PbcWV0P9HH48JxCHos2qCOwdAffTSsVfouROZN6Mcx OsT1n9x1239rkbG6hdpojAEmxPN0Ini8eKc3MOs0rk/oWTZl1F9JjZbGrWGPiJf+w5zL YtiyZ9HL2YUsIAekksROIFa5+16FSNv2M8/J8= 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=8eIa0Vhcalrg30hExhgbFyLNmHPU3sV6rgHITb5pZ5w=; b=Tz2yA+KrIUq4pHih7j4fuBglzhCaEa6wv5VNBqj0s2QpWZsBt6geri10JTikhMF+9Q Rys8jNUlh7gyLi661BshlbjqgenR14ObxAcFAnDutOxUzR1cbu/Y7+eRwuMr5rwFNWsa Erqx882dqm7285mz/tT9X3tw6BRuApaOfyvnJ3t1yIeBlx6JqIoLY3nBOHrZL3EHFmUw 5CoDCwbkiPrzwA++CZVooR80uCnJlEU8XWMCUvkZBXDktmk4QRzYqVxwoQQn3EViJYkK l/WfkkAE3b0mNmXiSaBKUxNik2jKGNnYhPVYfypJuvTCeufgn8/W/ZYQ0KAgW+hzPanV qk3w== X-Gm-Message-State: AOAM530oxH264HTgYIsL/Iemz4433HqqNN4owZJmo0c3ORa+YSaAkFj7 NJ3pqzQOsAs2c5EY5fJseSuEsw== X-Received: by 2002:a63:1415:: with SMTP id u21mr15114423pgl.366.1589815270596; Mon, 18 May 2020 08:21:10 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id h7sm6207978pgg.17.2020.05.18.08.21.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 08:21:09 -0700 (PDT) Date: Mon, 18 May 2020 08:21:08 -0700 From: Kees Cook To: Mimi Zohar Cc: Christoph Hellwig , Luis Chamberlain , 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: <202005180820.46CEF3C2@keescook> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1589805462.5111.107.camel@linux.ibm.com> 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: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! :) -- Kees Cook