Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp561709ybt; Wed, 8 Jul 2020 06:33:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxEEO5k8meTWGFVM2PXhg9Ltbar4zA/WBZmUo/yJwLHtd7t9cEfg33MNK0YiXy+9LOjRLMK X-Received: by 2002:a50:8c06:: with SMTP id p6mr27796060edp.146.1594215188679; Wed, 08 Jul 2020 06:33:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594215188; cv=none; d=google.com; s=arc-20160816; b=Z5uVlC4N+DWzaeZFzGWiE0CrNa1ctvSHZDP63AyVumYR1eUjXgYXr92+r8C38v7hLJ HJRzeGv9kJemy1JDNmDN9sec75yZr0ZY3dBDLX1OOYUtS7MJX4jm4Kiw+5WUME4H7tTH V61fMvGT7SwaPa9+JMGzeeIFaJl9g/RcQ7P1taOft8sXvhNaMzofyLkFxk1jNP5Bi0Qs q9dBK6cvfJxm2a67SsYM0+PZDzz2GRRa0IYTwYcuECLlZ8YUifaOam+ychhaCv+sF5Tn yGCPz68/Hs6ymB14+8jpD5cVLt05Xo4XB23zhE1tDEC6xg42yPiO1J9kyz1Fi71hAm3E ZMRg== 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-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=e2kkDUoiBt2aGKTCH92DsaO6ZhZViiUD4MWP53eNHvI=; b=CYIRSxLDsY6MnyTYLf6qkZGg4aNSpeyKFAOA7w++MDvbLSAd+O4D4Vlc9YUN8jms/z S3JQUucbsGqge8FlclxSukBVmLCfaRrMzYfz0oQUC1KX1GkjayHSez4Zf0jTCL42QEDo 6vGFBDMsqhlu7p9hGbza4ZMky5YWinfmWf0n62VFNAuewlvW9WRkgk92qgMWUmKLz2lD c6mDXmcqitrvOrEOmFJmzbFU2XPJIWRKk43p9+wBa+BZ0T211Z8yHsx7AkQgfltpexpr dlrZ2RakfRT9Div3EvrNMwd4PTbbh++GkYb2L98Vd1gNxq/nPF0SWJkmVFAlcv/a2Vqo nonA== ARC-Authentication-Results: i=1; mx.google.com; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p7si17135724ejy.206.2020.07.08.06.32.42; Wed, 08 Jul 2020 06:33:08 -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; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729589AbgGHNaI (ORCPT + 99 others); Wed, 8 Jul 2020 09:30:08 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40809 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728148AbgGHNaH (ORCPT ); Wed, 8 Jul 2020 09:30:07 -0400 Received: by mail-pg1-f193.google.com with SMTP id e18so21675335pgn.7; Wed, 08 Jul 2020 06:30:07 -0700 (PDT) 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:in-reply-to; bh=e2kkDUoiBt2aGKTCH92DsaO6ZhZViiUD4MWP53eNHvI=; b=n39aKhQotuqV5MKXJG0SQUzSwwhsAioRVl8qIKBI6leBlkcbcq3FL+pctYWCg1t9Dv kjRAO0PbB6+51BCVCkjS3By1JrWiA3lHDbOHsKJF8IaMfwNT14Ahz/+tePd/0rkHBsgb EWAS4iRunOh3YBMbxPbxCgYuPOGsWnm5diB1WrF/2KhzDmYvQ7e/d79KeQdZDT0VLZFC jawLO64TaLxGGsEZR1n93xetrqtcSwcqsvApZ4MtZ/N76XfHabVvSG6QY96kdHTcFJhq hLP6LSARpNx4pn3eQGiKrugayWoCJaq9BDMdODhrxLj3yh9BcVwY5OGpWrPBnujET7Pc Pq3A== X-Gm-Message-State: AOAM531rGsw2F0NERbskBqSzckQrD8QsfYtISNsrNrJotCp8FkHDQjrl I9+60mZFYNjrHvy9XPeNCIlCKYudSZJ5ag== X-Received: by 2002:aa7:848b:: with SMTP id u11mr38991115pfn.72.1594215006485; Wed, 08 Jul 2020 06:30:06 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id g63sm5672881pje.14.2020.07.08.06.30.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 06:30:04 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 2C8AA401AE; Wed, 8 Jul 2020 13:30:04 +0000 (UTC) Date: Wed, 8 Jul 2020 13:30:04 +0000 From: Luis Chamberlain To: Hans de Goede Cc: Kees Cook , James Morris , Mimi Zohar , 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 , 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: <20200708133004.GG4332@42.do-not-panic.com> References: <20200707081926.3688096-1-keescook@chromium.org> <3c01073b-c422-dd97-0677-c16fe1158907@redhat.com> <20200708115517.GF4332@42.do-not-panic.com> <8766279d-0ebe-1f64-c590-4a71a733609b@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <8766279d-0ebe-1f64-c590-4a71a733609b@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jul 08, 2020 at 01:58:47PM +0200, Hans de Goede wrote: > Hi, > > On 7/8/20 1:55 PM, Luis Chamberlain wrote: > > On Wed, Jul 08, 2020 at 01:37:41PM +0200, Hans de Goede wrote: > > > Hi, > > > > > > On 7/8/20 1:01 PM, Hans de Goede wrote: > > > > Hi, > > > > > > > > On 7/7/20 10:19 AM, 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. > > > > > > > > > > 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. > > > > > > > > > > This touches several trees, and I suspect it would be best to go through > > > > > James's LSM tree. > > > > > > > > > > Thanks! > > > > > > > > > > > > I've done some quick tests on this series to make sure that > > > > the efi embedded-firmware support did not regress. > > > > That still works fine, so this series is; > > > > > > > > Tested-by: Hans de Goede > > > > > > I made a mistake during testing I was not actually running the > > > kernel with the patches added. > > > > > > After fixing that I did find a problem, patch 4/4: > > > "module: Add hook for security_kernel_post_read_file()" > > > > > > Breaks module-loading for me. This is with the 4 patches > > > on top of 5.8.0-rc4, so this might just be because I'm > > > not using the right base. > > > > > > With patch 4/4 reverted things work fine for me. > > > > > > So, please only add my Tested-by to patches 1-3. > > > > BTW is there any testing covered by the selftests for the firmware > > laoder which would have caputured this? If not can you extend > > it with something to capture this case you ran into? > > This was not a firmware-loading issue. For me in my tests, > which were limited to 1 device, patch 4/4, which only touches > the module-loading code, stopped module loading from working. > > Since my test device has / on an eMMC and the kernel config > I'm using has mmc-block as a module, things just hung in the > initrd since no modules could be loaded, so I did not debug > this any further. Dropping patch 4/4 from my local tree > solved this. Thanks Hans! Kees, would test_kmod.c and the respective selftest would have picked this issue up? Luis