Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2224390ybh; Fri, 17 Jul 2020 12:17:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyFSJSCr9mxMZXbBfz7752occAB4CxhXzMIM+gOs76U7tzjTXR2hDtqCj7qCYPf9yGbAa0 X-Received: by 2002:a50:a451:: with SMTP id v17mr10267776edb.256.1595013474739; Fri, 17 Jul 2020 12:17:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595013474; cv=none; d=google.com; s=arc-20160816; b=Om9zKgFCEx6PtzYKrnbYwIBEUToEHD+dxTjhWCUFgI8Ww/bdAOVOTswaTC09qgb/3y pcAmExmmK63LUpR5qalc270YR/XYu/4t84skXUBhn93wwBqzjtR/+gZROUYlVld9zMYn K3l+MQpfdUZyD/SITOYOKADAbvE2JGZ3mYIefKvSWiSb7latQDOgSEogkWz0HbzRCMe5 cv3uLzMrnjpXii87BwBhCBtFIxmJbWOh8VYtwvl70dtkvWOfppZ8N6GoSN1mp26n48y0 tDjlum5Vspra1xRLwIc0o32dZsTkJomm7287x55B8s6LMLksTMDA5njiRIYn+I7mVCPP 3M/w== 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=n8O46usBchtSHCfeAGHh+h7YSR1FpLP9i8w8Jhlo/5Y=; b=qPJvmgZDehJfSbfOnyKJxP+T5+GM4lJj2qxbcXJYQ8C2yD1iyAGL/CqQHV4L0kjaFR IxLX1zT822DLnPWrz80ZU5VUNPvFgMastra3LqLyKekRTpvmQqQFJbX/oclJz5sU6Rwm XlBIbjmf7rsINutNwq6Pdx+KReSiA8mk+LEBmNqMiuOw357uyXFxssn6I15SmBYqwsEl bcuk7iw01B39IvqvRvhZJPUwR19xvin0v1U0V9RS34VuSn1Ki9dM4chv3KRSKUlJrEgM a4+HxJKRNGaJYd3tNdMsEptIiazQNDWCHdwcoIEckN4IxP+JTAMHr811DJzH2CgiRyp8 fUPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=XDpuU1+C; 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 w22si5543706eju.670.2020.07.17.12.17.30; Fri, 17 Jul 2020 12:17:54 -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=XDpuU1+C; 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 S1728268AbgGQTRP (ORCPT + 99 others); Fri, 17 Jul 2020 15:17:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60544 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728188AbgGQTRN (ORCPT ); Fri, 17 Jul 2020 15:17:13 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2DCAEC0619D6 for ; Fri, 17 Jul 2020 12:17:13 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id f7so12242258wrw.1 for ; Fri, 17 Jul 2020 12:17:13 -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=n8O46usBchtSHCfeAGHh+h7YSR1FpLP9i8w8Jhlo/5Y=; b=XDpuU1+Cv3dWz7jVTTP8WHIGTi6YuyjOI3T1FZiEYrnsIlj8mcFQqfDnFTKRRrzH9u TbgxilEMUrpQH10WRSdgftDDsNich8CEV9HlaQGZkMotTF3a63pgDPRx94nodIuu2eGI cWOWVG3LI4mCZv7N7Q78cSbu7w1XxUq5xTA8I= 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=n8O46usBchtSHCfeAGHh+h7YSR1FpLP9i8w8Jhlo/5Y=; b=k/LotenQh/o7dGe+lRqjnwrXXqi2D7O7pp8kNCXOcU0xNYPyPKSzx4G6t/EXzwdXUP uRL4sQucexXZhdI+gr7YVJ+xGOXHra9g/kxY3a2R3jJQY6p08wd9774Wgtr8q+A9AcL1 zw+GkmDwBHxlevF2f4TTZUqgN2BlP+ceaIcIUWqnX6ExZLPvVe560ql6p1TQ+Z8dTSrV eDE7RT1lF9q2eaKur/Z5LgSoaY8hSqyyT55YIvWhT4luH3/4YFE3qwUN9/B85pMU8QOq Dkz5guFo9bMCAjG32MSuOvb8n/zg6P4K+i9fnXUjP3gHA6CYR04kM4wvMBakBG8VnTr1 +O5A== X-Gm-Message-State: AOAM530IbCyQbjsTSEgBeS3F6D0CEPSCMjYNiFelW9KeyIgXdUDay7kF djyYJ+IpwjsQQhHDHQV98+iKJFP2TD6grISGRzeVic9RscGRHX7eOxWOOGMMhqZwtaFtW5e9LFg 0xSi1ZZb/smXYjnz5P3u+AT3HPFc2Mh5eb+tmyC/awEMhy5LQ1fAS63Cxm3FuBum9j26tvoW/uQ jfwnNok72/ X-Received: by 2002:adf:f608:: with SMTP id t8mr11981560wrp.308.1595013431346; Fri, 17 Jul 2020 12:17:11 -0700 (PDT) Received: from [10.136.13.65] ([192.19.228.250]) by smtp.gmail.com with ESMTPSA id 133sm16372350wme.5.2020.07.17.12.17.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 17 Jul 2020 12:17:10 -0700 (PDT) Subject: Re: [PATCH 00/13] Introduce partial kernel_read_file() support To: Kees Cook Cc: Mimi Zohar , Matthew Wilcox , James Morris , Luis Chamberlain , Greg Kroah-Hartman , "Rafael J. Wysocki" , Alexander Viro , Jessica Yu , Dmitry Kasatkin , "Serge E. Hallyn" , Casey Schaufler , "Eric W. Biederman" , Peter Zijlstra , Matthew Garrett , David Howells , Mauro Carvalho Chehab , Randy Dunlap , "Joel Fernandes (Google)" , KP Singh , Dave Olsthoorn , Hans de Goede , Peter Jones , Andrew Morton , Stephen Boyd , Paul Moore , Stephen Smalley , linux-security-module@vger.kernel.org, linux-integrity@vger.kernel.org, selinux@vger.kernel.org, linux-fsdevel@vger.kernel.org, kexec@lists.infradead.org, linux-kernel@vger.kernel.org References: <20200717174309.1164575-1-keescook@chromium.org> From: Scott Branden Message-ID: <8de85fc3-9f31-fc59-abc1-29f43fb90988@broadcom.com> Date: Fri, 17 Jul 2020 12:17:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20200717174309.1164575-1-keescook@chromium.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 Hi Kees, Thanks for sending out.  This looks different than your other patch series. We should get the first 5 patches accepted now though as they are simple cleanups and fixes.  That will reduce the number of outstanding patches in the series. At first glance the issue with the changes after that is the existing API assumes it has read the whole file and failed if it did not. Now, if the file is larger than the amount requested there is no indication? On 2020-07-17 10:42 a.m., Kees Cook wrote: > Hi, > > Here's my attempt at clearing the path to partial read support in > kernel_read_file(), which fixes a number of issues along the way. I'm > still fighting with the firmware test suite (it doesn't seem to pass > for me even in stock v5.7... ?) But I don't want to block Scott's work[1] > any this week, so here's the series as it is currently. > > The primary difference to Scott's approach is to avoid adding a new set of > functions and just adapt the existing APIs to deal with "offset". Also, > the fixes for the enum are first in the series so they can be backported > without the header file relocation. > > I'll keep poking at the firmware tests... > > -Kees > > [1] https://lore.kernel.org/lkml/202007161415.10D015477@keescook/ > > Kees Cook (12): > firmware_loader: EFI firmware loader must handle pre-allocated buffer > fs/kernel_read_file: Remove FIRMWARE_PREALLOC_BUFFER enum > fs/kernel_read_file: Remove FIRMWARE_EFI_EMBEDDED enum > fs/kernel_read_file: Split into separate source file > fs/kernel_read_file: Remove redundant size argument > fs/kernel_read_file: Switch buffer size arg to size_t > fs/kernel_read_file: Add file_size output argument > LSM: Introduce kernel_post_load_data() hook > firmware_loader: Use security_post_load_data() > module: Call security_kernel_post_load_data() > LSM: Add "contents" flag to kernel_read_file hook > fs/kernel_file_read: Add "offset" arg for partial reads > > Scott Branden (1): > fs/kernel_read_file: Split into separate include file > > drivers/base/firmware_loader/fallback.c | 8 +- > .../base/firmware_loader/fallback_platform.c | 12 +- > drivers/base/firmware_loader/main.c | 13 +- > fs/Makefile | 3 +- > fs/exec.c | 132 +----------- > fs/kernel_read_file.c | 189 ++++++++++++++++++ > include/linux/fs.h | 39 ---- > include/linux/ima.h | 19 +- > include/linux/kernel_read_file.h | 55 +++++ > include/linux/lsm_hook_defs.h | 6 +- > include/linux/lsm_hooks.h | 12 ++ > include/linux/security.h | 19 +- > kernel/kexec.c | 2 +- > kernel/kexec_file.c | 18 +- > kernel/module.c | 24 ++- > security/integrity/digsig.c | 8 +- > security/integrity/ima/ima_fs.c | 9 +- > security/integrity/ima/ima_main.c | 58 ++++-- > security/integrity/ima/ima_policy.c | 1 + > security/loadpin/loadpin.c | 17 +- > security/security.c | 26 ++- > security/selinux/hooks.c | 8 +- > 22 files changed, 432 insertions(+), 246 deletions(-) > create mode 100644 fs/kernel_read_file.c > create mode 100644 include/linux/kernel_read_file.h >