Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp16840ybt; Tue, 7 Jul 2020 14:47:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzmxyNs4dxFTPyypIOdbgcYpEf6+pgdON8Q49TuaJQrx0ghav5acagQvWdZaG/2hWc1Dhui X-Received: by 2002:a17:906:6959:: with SMTP id c25mr48444470ejs.375.1594158423774; Tue, 07 Jul 2020 14:47:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594158423; cv=none; d=google.com; s=arc-20160816; b=DSQ+W4reIiBvItFZBCjN72rMUDiPV+WK5xvEhqDdkkj2aTNeYL8G0+nj7Kr2SVAGh9 WBphGZYiZk4aRXMlpaq2QCnxBGe4Rhe8zD7ZqCgcfJ5CGYQl54yrdlCh5vr8ED13lJ3Q 78FuPw8v4Jlu9HygCnpjdETTvGI7dx4sHVLaWHMwPcvRJaYr+YfZYh99iSrDWiHzsAk/ symlw3X/qzHGIW5pVyKqE/XM3TfIk5/y7x2JAVtBIuURxhMMqyDNSPTurBBL3Ba4f0ME FZeYKRqQ4j65U3/xe5AdxAhEA7Sd1Iz+24739N8Ok7PBwUqlUqQ/Ajj2ETIc6K2FVy45 0DlQ== 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=+X2Xhmqqsv0iqlLQQgWOIh/h4XwKHm7DRSh8jQWFnII=; b=0hXodR07vvPIsVAex2pPqXi0QAnmL8zPTXiI/pQkUFnXPEi9uPqWtT3x8f7tpzaph6 Q5GmehvuT6DHF/i4j75tAFMNxiop8zWi2UkFbibeu27D/saQ4zbdvjmNlpIrUAxulmTk DalkxMMDC8tk8hBYyrb5VKqb3YeLsa7ajs9j0t89j/ewIkUQJaadcWGFonEG7VqfRd81 jKvuBNjWOa8VGRwSzv3mB6LrXaFCiPKXvyjvuMXKs04iMhpkXnkornDsGlyfUsRY6o+i yblzVXgIaneoc3OaxjxSUqnWgE6gp3lt27faf0Yp2DdZ1A26dgEhXBM3CxkqwmXJVDFh rYLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=c1U9uUkd; 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 m27si15088601eja.699.2020.07.07.14.46.40; Tue, 07 Jul 2020 14:47:03 -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=c1U9uUkd; 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 S1729043AbgGGVpP (ORCPT + 99 others); Tue, 7 Jul 2020 17:45:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726273AbgGGVpO (ORCPT ); Tue, 7 Jul 2020 17:45:14 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3249C061755 for ; Tue, 7 Jul 2020 14:45:14 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id b92so241696pjc.4 for ; Tue, 07 Jul 2020 14:45:14 -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=+X2Xhmqqsv0iqlLQQgWOIh/h4XwKHm7DRSh8jQWFnII=; b=c1U9uUkdrkhW1asUELPte2OOBTvNiETRx3xLuK0Jg7I453xkG+Y+lWevjhbk9Q33v8 +8X4WBO3m2tBmVN1D8DLJqjiJ6rP34+a4QGgzHsR8v8VD2UN/8nVX4qAgNARioPhUATW V+FlQoeq3bNgrBvlSUJvyTH63wOE59cHAsydM= 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=+X2Xhmqqsv0iqlLQQgWOIh/h4XwKHm7DRSh8jQWFnII=; b=MO3s9N5s1FJMeh6u9mOHhlIltWVhVUxAPRkOntvimqV2bqep+olWJfEZR9fZIUgA4v NflCuDdbClJkl74KhbYHO/dXomLpTwz9c6HjzlNOqonLs6gujpDRbwOUuEiET02P0+p2 O8UHdpu4VKbkZygeDuIaJ9atZqE8D9QHH9MlUKXnvziQrd3oH4bpmK6aQn3k/Ie8nLRc U8Q1f4xOrpEfI4zqNusHRxiZosk0Lhjl0Vax50QmwJlqWKOw6mmp25ahbcjIMSYE3bi7 xp2nWwMV+vxtTV209Ehm1c7D0A7Xzkgen9WNlLk3Ma13qN27gSnhQjWjDYYRu6B7/6bX 54xQ== X-Gm-Message-State: AOAM531XCgEwz5md7zE2SlFr4D7KDSqXw4DOMblef8LylLn7MjKEPFVx UVLA7GgPPoJaMNla/yNuoy6N9w== X-Received: by 2002:a17:90a:234c:: with SMTP id f70mr6654067pje.13.1594158313261; Tue, 07 Jul 2020 14:45:13 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id c134sm8777846pfc.115.2020.07.07.14.45.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jul 2020 14:45:11 -0700 (PDT) Date: Tue, 7 Jul 2020 14:45:10 -0700 From: Kees Cook To: Mimi Zohar Cc: James Morris , Luis Chamberlain , Scott Branden , 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 , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Subject: Re: [PATCH 0/4] Fix misused kernel_read_file() enums Message-ID: <202007071433.55488B0C@keescook> References: <20200707081926.3688096-1-keescook@chromium.org> <1594136164.23056.76.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: <1594136164.23056.76.camel@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jul 07, 2020 at 11:36:04AM -0400, Mimi Zohar wrote: > Hi Kees, > > On Tue, 2020-07-07 at 01:19 -0700, Kees Cook wrote: > > Hi, > > > > In looking for closely at the additions that got made to the > > kernel_read_file() enums, I noticed that FIRMWARE_PREALLOC_BUFFER > > and FIRMWARE_EFI_EMBEDDED were added, but they are not appropriate > > *kinds* of files for the LSM to reason about. They are a "how" and > > "where", respectively. Remove these improper aliases and refactor the > > code to adapt to the changes. > > Thank you for adding the missing calls and the firmware pre allocated > buffer comment update. > > > > > Additionally adds in missing calls to security_kernel_post_read_file() > > in the platform firmware fallback path (to match the sysfs firmware > > fallback path) and in module loading. I considered entirely removing > > security_kernel_post_read_file() hook since it is technically unused, > > but IMA probably wants to be able to measure EFI-stored firmware images, > > so I wired it up and matched it for modules, in case anyone wants to > > move the module signature checks out of the module core and into an LSM > > to avoid the current layering violations. > > IMa has always verified kernel module signatures. ?Recently appended Right, but not through the kernel_post_read_file() hook, nor via out-of-band hooks in kernel/module.c. I was just meaning that future work could be done here to regularize module_sig_check() into an actual LSM (which could, in theory, be extended to kexec() to avoid code duplication there, as kimage_validate_signature() has some overlap with mod_verify_sig()). into a bit more normal of an LSM. As far as IMA and regularizing things, though, what about fixing IMA to not manually stack: $ grep -B3 ima_ security/security.c ret = call_int_hook(bprm_check_security, 0, bprm); if (ret) return ret; return ima_bprm_check(bprm); -- ret = call_int_hook(file_mprotect, 0, vma, reqprot, prot); if (ret) return ret; return ima_file_mprotect(vma, prot); ... Can IMA implement a hook-last method to join the regular stacking routines? > kernel module signature support was added to IMA. ?The same appended > signature format is also being used to sign and verify the kexec > kernel image. > > With IMA's new kernel module appended signature support and patch 4/4 > in this series, IMA won't be limit to the finit_module syscall, but > could support the init_module syscall as well. Exactly. > > This touches several trees, and I suspect it would be best to go through > > James's LSM tree. > > Sure. Is this an "Acked-by"? :) -- Kees Cook