Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2162859ybh; Fri, 17 Jul 2020 10:46:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+m8RZ7niTeyVyw4fizQ6uW7JNawAmA1t7D1OTynSDAB7zrpiZznmvS1bkVa2Ih7w1gupI X-Received: by 2002:a17:906:ce43:: with SMTP id se3mr9479646ejb.543.1595007971392; Fri, 17 Jul 2020 10:46:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595007971; cv=none; d=google.com; s=arc-20160816; b=tWG6MH3obmQ+YAKZ5+Et1s9QhI7PFCm5dk9SwSdowwiPrHXtA5qnG36vjwsirawOML uXCSMWFc984P7yYT7cXMPg7FaKJ5dgEELl57tXr+B1MZkasCL6uFVQjlsNUdsF9AAJwb Df5Zsbv2SPy60ZLnyvnKcIJLefCQIioiya9mzEVjBsDy5dldly8LuUmzwMS1fgy4aQpD jJsGHtrOFo4dGGggnYIPC/f60yr1DgH8QcE6haElVc6finFkNFBwsA1MBxCuMBwHZLE8 Ag6PbRyJSnGtcA/oKYeQH02p15pCO5Fsc7vp5gP0NNCEgzGfrckCDkCtfmgCFg2VTSj/ g5cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=wV1gvV23mO4MSWHgMeM+r7999nuQAFQGTkfq3zyvhrU=; b=0GlIRQMFLdHqzPHTmApsDQaui7AUG/LnCeffMvX3uzg+sc2ispEaVsOj5zY9bqTafT QxYtJEbPq8nz/S74o+rt25ZDo4/0sniUSBsnVEm3m34UrdnbUkDU/RHaVdomkbbULYW5 GYepnWdozLNwfWG0oAovqQlVE3eXRG6B7EeftNCcqQXyWJqeevIyz5a2Xw3FyRH2O7RS +Ji4pe/fgIG9O+BgG0Jtewvw+LFYOz0UN1sZxqcUlSnWAM9ahnuSjmZeLX13kEikuGtm 3HogaptjQxjZaW/vfAKoVjPZi8qVxEYOAGGjLat6eYnQCErNuSeU/GhxQ4mGBywJNeR4 xQhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=TkI+hwhy; 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 r26si5872936edp.538.2020.07.17.10.45.48; Fri, 17 Jul 2020 10:46: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=@chromium.org header.s=google header.b=TkI+hwhy; 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 S1726256AbgGQRnQ (ORCPT + 99 others); Fri, 17 Jul 2020 13:43:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbgGQRnP (ORCPT ); Fri, 17 Jul 2020 13:43:15 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06563C0619D2 for ; Fri, 17 Jul 2020 10:43:14 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id gc9so6888461pjb.2 for ; Fri, 17 Jul 2020 10:43:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wV1gvV23mO4MSWHgMeM+r7999nuQAFQGTkfq3zyvhrU=; b=TkI+hwhyWG7WZvnJTwRRMikLIXphh/PU89bCIE8P6SFs0SaHpCf4VAcMkSYIWejrmC UHjYj/pWqealOdMvuvGnbGyDGiR092Y/coL6eRwohd6FSkw/1x0lTSsWwdlxAmTbJF9z MG+bnlBW3Pz3hPqkiZYjpkgP2T6E3WFs4nd00= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wV1gvV23mO4MSWHgMeM+r7999nuQAFQGTkfq3zyvhrU=; b=c5Prjf+GBUIbV+MP9+R41TMnOr4KXK0dfVGWaYs5nCknQyyriT8R8BNDTKnGmvCXoq jsFgvN2vlLcSrs+eLmhqdD+jqvAStDm29xAAyuFkhprKq+nBzzT2TI2Jr0pvObjcprDN JwfBBAMhnjjRGXuWfD+8BIDpqPusS9nlGz/XjdtTRq9DXzJ/4/ik6PIqhfF0iXSUUgES lA+bFPuq6t8Ad5tyRdaiKbkn8Iq0KsEOcrw/bBgObiPXGwArzirlgTmIwgze16Y86lM4 374LlMiObX4VseFwkM2jrHoCtKATbXm7GurLkYysEuoLytob31/2KuJePBbeGkeo75LD kGEg== X-Gm-Message-State: AOAM5318nF2cPt7a8eeFdXKaDDUEpfE+zFMN9JclYMS73sB5yuTcEETw vRq4ZSwb9yXExZBV8AChuxZGfQ== X-Received: by 2002:a17:90b:1386:: with SMTP id hr6mr10767858pjb.93.1595007794310; Fri, 17 Jul 2020 10:43:14 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 21sm8245611pfu.124.2020.07.17.10.43.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 10:43:13 -0700 (PDT) From: Kees Cook To: Scott Branden Cc: Kees Cook , 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 Subject: [PATCH 00/13] Introduce partial kernel_read_file() support Date: Fri, 17 Jul 2020 10:42:55 -0700 Message-Id: <20200717174309.1164575-1-keescook@chromium.org> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 2.25.1