Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp490240ybt; Wed, 8 Jul 2020 04:59:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJylSoV08NRcV7k/9j3mAbO8VKSf3tB4jZkOG+CXNwJSCHXDFnezl5r39SmGuLk8f06S3xH1 X-Received: by 2002:aa7:c305:: with SMTP id l5mr62008491edq.163.1594209589485; Wed, 08 Jul 2020 04:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594209589; cv=none; d=google.com; s=arc-20160816; b=UGpSJlfn+PDz3mL0ojHxGeGndSaUt859FZFt80Gjnd2QOP03cfVCT1LzTRZuFA/rHn PkJIETtKiW8DJzNMiRXUwhFvEdsTIv/IY0V1Y4+qGypwKIEjsGukSc8r3cZLw/c+kO6b 7hgZW6sWK2yFrpl8KOTXUERI5WdkllvKvmoQt86Y7Bf9lCPCh5IWUjSLKOjqRW+UUP2O t4uP67AxN0Edz1qOdMp6srC6qeSFtgTfrmtwbY2qkRaXLVydH4X9vv9osABzkz1mE9TS IaGlbiqcGb5j4PKVxnI06GNZVjmZ1mCCzpADU5Mb0X1TxsfwXr7Wh+UB1MtZmnpThEt7 ruVQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=QkevNhBGyNEaCjar4U2+U0onC84LFT4MZtwJK+TdKxE=; b=UMH0JrrcR/PU4Gnk29TFt3Pq70PqJY8i8UGhbyiEnWo0PRzpzV0I3hGAv28IbafNJD 682kvWUK/xscYWmMdaGv9v5QaofzRw6HSiNA9uMjSCj7lnHnaDIHqnS6/gcyCwuOrk/3 meVYkr0gYSVD0f21JF4P8vaZqD62vl/qDoEWil7Mvf9m0mkSAiLeNpo8BA4scF8+/TTi zp2NAD5p+0cPQdyrmqx/VaojB0e/a3QZrNCHTmF7nCNNs2yJAnyzZykspyZOryc0RQVm mNVYHBJE4+lgPTE48IjPUJ+RJPjaJbyygeo8zyq/7EHtN4k9pfq8aRf7wM4oa8JPTZ+g 4WKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="hc/oiexZ"; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b3si17907238edn.338.2020.07.08.04.59.26; Wed, 08 Jul 2020 04:59:49 -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=@redhat.com header.s=mimecast20190719 header.b="hc/oiexZ"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728895AbgGHL6y (ORCPT + 99 others); Wed, 8 Jul 2020 07:58:54 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:38485 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728858AbgGHL6y (ORCPT ); Wed, 8 Jul 2020 07:58:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594209532; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QkevNhBGyNEaCjar4U2+U0onC84LFT4MZtwJK+TdKxE=; b=hc/oiexZ9wvLLn9/+IX22A+iVwsLJjfD+Usu6Pc2RLctUx5T9STVJhzettkDB9Xe88k0XW eoCBMsI6EFedwjLE8/DXTq5XPQbWusTjoZy2RJH9ts5otgLIWaYEndGASChObGStyJUR8h 1wf/sC8XdXrhOP1bC3oFLqfYzeflYNw= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-475-yhihAH8CPOqQqUUgmWBAUg-1; Wed, 08 Jul 2020 07:58:51 -0400 X-MC-Unique: yhihAH8CPOqQqUUgmWBAUg-1 Received: by mail-ed1-f72.google.com with SMTP id x20so58862463edr.20 for ; Wed, 08 Jul 2020 04:58:50 -0700 (PDT) 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-language :content-transfer-encoding; bh=QkevNhBGyNEaCjar4U2+U0onC84LFT4MZtwJK+TdKxE=; b=jNZt1+jzn+QMCBkZesSql9RaW/dI6v1GmoHZf1g64iT1wNTxPiMgXDH9C3L2pb/QcS eS+mvdBttJ/RRrOxyMA81yhRoCXcOVrShlV7N6SCXnbXoBhIy3VSHcK6FLB0VEyfLpan ke635T3zlnDxEri3fdo+ReUr7nfEgzuweGMBQ5XXbBV6jlbs1FzslMkf7kNo2HZRNr3R kQIozTEm1Nc/o/9pArNIm+3QjI6i7AxeKO9dxilIH6s4BWkGF8x4uRGXVuMvvhGEQsvm HZModr7Pw2Fm2NZIQX2ZWUoYV3dWHTfKVbDetTVnUSDyGHmqmzDt9jiNnPCe86KIPwla ebRQ== X-Gm-Message-State: AOAM530gcn8juUchtZAZ8C/D4RWbbNlpS476l4pCIs3vewoYN9IFhAuq QLn2awvEoCU0g83HrGeMBLEzMvN1FniAjhDFCQEqY6qnz3sgNl1Se3Nr80U9y2nZ+0VHM6K0vrq wTetxJf3j6ZGRu7s9v96cJWyC X-Received: by 2002:a17:906:12cd:: with SMTP id l13mr52498671ejb.96.1594209529422; Wed, 08 Jul 2020 04:58:49 -0700 (PDT) X-Received: by 2002:a17:906:12cd:: with SMTP id l13mr52498652ejb.96.1594209529173; Wed, 08 Jul 2020 04:58:49 -0700 (PDT) Received: from x1.localdomain (2001-1c00-0c0c-fe00-d2ea-f29d-118b-24dc.cable.dynamic.v6.ziggo.nl. [2001:1c00:c0c:fe00:d2ea:f29d:118b:24dc]) by smtp.gmail.com with ESMTPSA id u2sm28953481edq.29.2020.07.08.04.58.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 08 Jul 2020 04:58:48 -0700 (PDT) Subject: Re: [PATCH 0/4] Fix misused kernel_read_file() enums To: Luis Chamberlain 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 References: <20200707081926.3688096-1-keescook@chromium.org> <3c01073b-c422-dd97-0677-c16fe1158907@redhat.com> <20200708115517.GF4332@42.do-not-panic.com> From: Hans de Goede Message-ID: <8766279d-0ebe-1f64-c590-4a71a733609b@redhat.com> Date: Wed, 8 Jul 2020 13:58:47 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200708115517.GF4332@42.do-not-panic.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Regards, Hans