Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp635040ybr; Fri, 22 May 2020 15:26:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfviZ4Rgr6Z2HhDRuUqln6laQ9bFpSJbd6WPyPguLEb30whC03rIlbJtueFWDAlOMV4pO+ X-Received: by 2002:a17:906:1857:: with SMTP id w23mr10304584eje.273.1590186400576; Fri, 22 May 2020 15:26:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590186400; cv=none; d=google.com; s=arc-20160816; b=hJJxee3XU4WgEFPYYvF7ua4+K2LRcWiuyDdfj1naKcZ5of3i36wCXcvwd3rgBb7pFx SWJu6FuchHTZV1IKZhGEck7wpRmQlUdKOQXGuDgp5xPt2PNqClCgs3zNwGTF0kbPk8wb K3RfYFzYbRdS5c6sMnITByPVtbk84zHS7o2uU8hC/d707UViJ+dMrflIBf/4SmzEoiV5 2MBZHduPLAf7R/zR4lCiLd4al9OAK+kXxe+5RWTGYATYAx1lkrCiZTosRenk8VVkHRco 0xWK0wPUtHRbwv6f3fIW3QKnJwazPQDL7rO0sAS/mH6M9+tEfGZ1DVCu38KonQOy9Wjx SaqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=ztKgl+m2bwsAuJakJyGkItSpIGs0CjL1QD7hydh2kOo=; b=suYJhhOlxQUaUh32GYznQP0KtPIo/DTggoeIw6BjsMuOPK3ayOD7EyX3AMnRKIO0ct 10Tp7nA+r6OozLpcLffB07EnzlhXOmd3+ogNvO84H3nOi/2Im5K5Gv19DcdkwCAlIMOj YJMk2Bedog2FsyE/GPdqP0+Q8OyMk0EMVblmCy0nXAiIoToS6iZFVu3ufMweY/CERNja Lhhio9CTr/6c0iTW8yFtS19qCknpFVbcdWOtUDmgJaqrbF6mv3fNVBcagaLZJ8xcRDz2 gE27UpDKrtDkGR+JUkKXYYnCC/qS9cQZCzEFqvmWZOXIcOF+hqAWrPPIqKceLGBpdBL6 z/Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="Y/Hbo0rn"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j93si5252416edd.447.2020.05.22.15.26.18; Fri, 22 May 2020 15:26:40 -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=@broadcom.com header.s=google header.b="Y/Hbo0rn"; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731211AbgEVWYs (ORCPT + 99 others); Fri, 22 May 2020 18:24:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731160AbgEVWYr (ORCPT ); Fri, 22 May 2020 18:24:47 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 030BCC08C5C2 for ; Fri, 22 May 2020 15:24:47 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id u5so5659604pgn.5 for ; Fri, 22 May 2020 15:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=ztKgl+m2bwsAuJakJyGkItSpIGs0CjL1QD7hydh2kOo=; b=Y/Hbo0rnxy6mClHRHFWRhUyxj1FRJT69aFwW3tY3fm3oVu6EODCaV6cZ/pbEy2J4Xp 5SqSYpicqXhNkkxvb94CERQ10mQiHBfSX/Rac+QDLBTz0rt5MReojcoJ8+Ykua9ccq4e eIsrhNUpOJWulxVbDeRZjq1LzV2AlyBxgkCa8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=ztKgl+m2bwsAuJakJyGkItSpIGs0CjL1QD7hydh2kOo=; b=qrEAFOcTPkChFi8ZKvPXMTa+CVMHZK2oIWeIXYtO+1Sn71WMzuZDuG1qMD8dBgpAEP SlSH0CCBdUqzZgENgEkk/fJKn+05rwEEPBIgmcbNEGaRwIEE0ytSQ4Z5oZ9A4WTjxFy7 9rOou9M4SxVgOkAMe3thDEUr+XbNvI8v6lQyVylZIv5sf3kdMCK5w8rSYV3x9VtOMG1x 6ixcHJyN7bxJL/wZ4CCpwWOeLjcGNdZYhWoEkO9KC9M+epOqBxhX6PXbJ/WGI+D4eSm2 EVzjewaLLgu/5AnrxNw00vmFyga5OxZe5wXylZIlpgsNuPmLjjEE7bmnip9kJOdGAms7 YV+w== X-Gm-Message-State: AOAM530GlYtUBnZxLT7rp2KZR/MacqB0P8cxOZv15eRS9RhX1yaU5TV/ grenK/cCw+UuRxeaqE2w/UGpqwd1FMp6K0rJHCNL+aL9/CBgpfwmn+Qhs4GuiBl+al19p6viQZg lm7VTN2jliAJYrMVKew+MQutGArTARLKbY7hBjF1tY62yKI2btImflvnMjJMuBlC56k3EiX10M6 bSaoB3XLnn X-Received: by 2002:a63:111e:: with SMTP id g30mr15317955pgl.446.1590186285979; Fri, 22 May 2020 15:24:45 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id l3sm7861934pjb.39.2020.05.22.15.24.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 May 2020 15:24:44 -0700 (PDT) Subject: Re: [PATCH 0/3] fs: reduce export usage of kerne_read*() calls To: Mimi Zohar , Christoph Hellwig , Luis Chamberlain Cc: viro@zeniv.linux.org.uk, gregkh@linuxfoundation.org, rafael@kernel.org, ebiederm@xmission.com, jeyu@kernel.org, jmorris@namei.org, keescook@chromium.org, paul@paul-moore.com, stephen.smalley.work@gmail.com, eparis@parisplace.org, nayna@linux.ibm.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 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> From: Scott Branden Message-ID: <7525ca03-def7-dfe2-80a9-25270cb0ae05@broadcom.com> Date: Fri, 22 May 2020 15:24:32 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <1589805462.5111.107.camel@linux.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Mimi, On 2020-05-18 5:37 a.m., 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. The entire file may be very large and not fit into a buffer. Hence one of the reasons for a partial read of the file. For security purposes, you need to change your code to limit the amount of data it reads into a buffer at one time to not consume or run out of much memory. > > Mimi Scott