Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp876979ybk; Wed, 13 May 2020 15:50:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDoAED0Sv80tk1J/4TSfHJBqXyoNuokyX4ByTOTOkQHVWhvcYKwWzqXc5nDpF7OeILOHBM X-Received: by 2002:a17:906:1dce:: with SMTP id v14mr1303665ejh.244.1589410211384; Wed, 13 May 2020 15:50:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589410211; cv=none; d=google.com; s=arc-20160816; b=Z/L7OhGNw0RwAjJ4Qmkoe028mH6gSjia8oJoySNQGvOxf5aSAyUNxGLllT5vIG3ZJt QncPvzxUSS87wzpn71XRQy4IYs4qiDvMDLJ+CSnjq8dGvAfafpGH6PDyOSB7X7kSsTkh QXCWzM3JAHtwYncYO1fPbIixypTF8r2B8pCavg8ee9dCP5zCwrx3YO9J/XBBin/CwuP+ K4al/tfNm7Qp1R4+pAQEkThf1WzTev3vits2PnnbG5SYGCPezcmpQry+hHohY4WB2uZZ ZKHw38aEjt8PGZnTr3M3fPipAt4nb5gnFnpu/n5Cyy3Kma5LpOeeOlTNSzfSYrUH5kje z+PA== 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=H+AfxUaMnhwNQoaeoLBhnhy670cA4ggBoeJoS1eRurw=; b=h4Dhb5bvCbYAdl1OhUTWcE4XZWFRejqwhS6NbLqbFThTdtWjDnfKPk1FMgjlrSjxQm y4EG1yQ/yTgvafsejIFEGYEyDa8WmDbtJIQ4xiULk2WScup7aV55iobPGGenLS11gsZj hcMg8Jnhn7qmy0CdpW62iwZEHTCE7QXd8hW5QOnaOAIjgiN/K+yAgDNP90Q6UFfgH7i3 k8/97bK+p2zyZpqwTpzFT9mYBgfIPhmdn+x0nG7R0JwrZ/g8JZFlNGOMAkyh9N7EcWC2 J7EOTzIdDrWw0XVlI6116xn2ln+i8srpPgQ9SuwZ3EbO54IaZI4DhaZOtK6ZjrRDNvnV n3Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=JGD7HQd4; 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 by25si710010ejb.413.2020.05.13.15.49.48; Wed, 13 May 2020 15:50:11 -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=JGD7HQd4; 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 S1731718AbgEMWsQ (ORCPT + 99 others); Wed, 13 May 2020 18:48:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58198 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1731649AbgEMWsO (ORCPT ); Wed, 13 May 2020 18:48:14 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E4DDC061A0F for ; Wed, 13 May 2020 15:48:14 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id g11so407356plp.1 for ; Wed, 13 May 2020 15:48:14 -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=H+AfxUaMnhwNQoaeoLBhnhy670cA4ggBoeJoS1eRurw=; b=JGD7HQd4cFtwAgY6blAgbXdG6kcGmAAG1VWu80Jyf2foqmg/CPidgYdJYYyspMDrP4 /EVgNm2nMhqtWEvVGt5m0mjK4HAef18Jhth28pHYJDCID+v52/KeMHGrvvt4kUngLxIi v69i+/VoYcfURFZw1kflWQB7jS9mJAyZnR3NM= 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=H+AfxUaMnhwNQoaeoLBhnhy670cA4ggBoeJoS1eRurw=; b=YaPB0BF4D+NJ3AScTKgmu0GutqpwpsaMRrpaam97/Pr79MhNHmMYS/E52smzhkCb4Y 5uf3IQaNnZIf3zLazcpAwm61mt9Muy605BMwTGwYqz7QIs86yrckUcmHUA6rjri3pnxB jGziV7NSd1VLUE9WGlW4ojhhcaEW4FAra66eynYTQT3qta03QUWZLkorMaR6NXKafZOU hC9UrGrb7jMeQaz+82ZxM1dpLvZTPz1GmFzvJi0G7fF5ci7FeKRa+JkXnKPGWNpjBie5 reGeu2l/902zCgZdjzDOV8ZQPM3JB32gVv4k7WkNuhxmv4Wf64XLm++Mjax567bNlDda XOcA== X-Gm-Message-State: AOAM530VYgzSilSwwcFAi4lixVgPAriRUPHh32JL/MAwsQuVbDN6Ha5t nEoO3pABKSdu6PJ3j0vJih7x+A== X-Received: by 2002:a17:902:465:: with SMTP id 92mr1264035ple.227.1589410093370; Wed, 13 May 2020 15:48:13 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id f64sm16806846pjd.5.2020.05.13.15.48.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 13 May 2020 15:48:12 -0700 (PDT) Subject: Re: [PATCH v5 1/7] fs: introduce kernel_pread_file* support To: Mimi Zohar , Luis Chamberlain Cc: Greg Kroah-Hartman , David Brown , Alexander Viro , Shuah Khan , bjorn.andersson@linaro.org, Shuah Khan , Arnd Bergmann , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-fsdevel@vger.kernel.org, BCM Kernel Feedback , Olof Johansson , Andrew Morton , Dan Carpenter , Colin Ian King , Kees Cook , Takashi Iwai , linux-kselftest@vger.kernel.org, Andy Gross , linux-security-module , linux-integrity References: <20200508002739.19360-1-scott.branden@broadcom.com> <20200508002739.19360-2-scott.branden@broadcom.com> <1589395153.5098.158.camel@kernel.org> <0e6b5f65-8c61-b02e-7d35-b4ae52aebcf3@broadcom.com> <1589396593.5098.166.camel@kernel.org> <1589398747.5098.178.camel@kernel.org> <1589404814.5098.185.camel@kernel.org> <20200513212847.GT11244@42.do-not-panic.com> <1589407924.5098.208.camel@kernel.org> From: Scott Branden Message-ID: Date: Wed, 13 May 2020 15:48:08 -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: <1589407924.5098.208.camel@kernel.org> 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 On 2020-05-13 3:12 p.m., Mimi Zohar wrote: > On Wed, 2020-05-13 at 21:28 +0000, Luis Chamberlain wrote: >> On Wed, May 13, 2020 at 05:20:14PM -0400, Mimi Zohar wrote: >>> On Wed, 2020-05-13 at 12:41 -0700, Scott Branden wrote: >>>> On 2020-05-13 12:39 p.m., Mimi Zohar wrote: >>>>> On Wed, 2020-05-13 at 12:18 -0700, Scott Branden wrote: >>>>>> On 2020-05-13 12:03 p.m., Mimi Zohar wrote: >>>>>>> On Wed, 2020-05-13 at 11:53 -0700, Scott Branden wrote: >>>>>> Even if the kernel successfully verified the firmware file signature it >>>>>> would just be wasting its time.  The kernel in these use cases is not always >>>>>> trusted.  The device needs to authenticate the firmware image itself. >>>>> There are also environments where the kernel is trusted and limits the >>>>> firmware being provided to the device to one which they signed. >>>>> >>>>>>> The device firmware is being downloaded piecemeal from somewhere and >>>>>>> won't be measured? >>>>>> It doesn't need to be measured for current driver needs. >>>>> Sure the device doesn't need the kernel measuring the firmware, but >>>>> hardened environments do measure firmware. >>>>> >>>>>> If someone has such need the infrastructure could be added to the kernel >>>>>> at a later date.  Existing functionality is not broken in any way by >>>>>> this patch series. >>>>> Wow!  You're saying that your patch set takes precedence over the >>>>> existing expectations and can break them. >>>> Huh? I said existing functionality is NOT broken by this patch series. >>> Assuming a system is configured to measure and appraise firmware >>> (rules below), with this change the firmware file will not be properly >>> measured and will fail signature verification. So no existing functionality has been broken. >>> >>> Sample IMA policy rules: >>> measure func=FIRMWARE_CHECK >>> appraise func=FIRMWARE_CHECK appraise_type=imasig >> Would a pre and post lsm hook for pread do it? > IMA currently measures and verifies the firmware file signature on the > post hook.  The file is read once into a buffer.  With this change, > IMA would need to be on the pre hook, to read the entire file, > calculating the file hash and verifying the file signature.  Basically > the firmware would be read once for IMA and again for the device. The entire file may not fit into available memory to measure and verify.  Hence the reason for a partial read. Is there some way we could add a flag when calling the request_firmware_into_buf to indicate it is ok that the data requested does not need to be measured? > Mimi