Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp484130ybf; Fri, 28 Feb 2020 01:45:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxpMrd34KN5emBKpJ5MKHxn7i17Fx7ff3zsnLfcnsTcpcIzCuiFjMCNUD3Y02OsoriTQJs/ X-Received: by 2002:aca:2114:: with SMTP id 20mr2517457oiz.9.1582883145076; Fri, 28 Feb 2020 01:45:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582883145; cv=none; d=google.com; s=arc-20160816; b=qA7qLEL0OlsU8lRzael6MBJdi1kFjjgGaQ3WMFrMZr1UK36neeGfvoyd2BFt4VNFjA ydamY3ZpcAz5umKyT9U0fZ4DjKKAY697eCIAc4WBrRygVz7nKoo+tJU6bJgtBz0tZeEZ kGy/GMvS5cHIQ2ehZ7FpOYEdXppVvoc6v4ZezVEOgjJx3q4wSnk4U+yyuPS53lwhPDSY oO65BqTHCnqGvJy9ICdBi6h/wGsmKHcg1C58kXHNK6DHC2eZeDTbVaw/OE3EyQtjzDYh jaWVUwq/UzVY7z3+rk/hrCdFt4ScIm+TRjgdYVfMmkWgZ9Vc7IAa+RjI9SjPVsTsr90R U8VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=GPXn1hVxaDrYsh+Zp432WMILCLmYX7D2alWc8rcJT74=; b=O8gZHSmFAD+IRCkShy5aTPcj/7lVu00RcLWrlXsA+u4QPojBGbmkMNF4GcWoTIZkAh rSQnYiu+Gwn4IN7raQCJFq2tEKk2eV4xbtcjjKdAHMnMSe+DGytyRepSHKqaOlgBb9Mw gnDd929DdgnO3S6UNrQhYcT+NT4jZjbNioYYaYF/AGbIoMAfBrxY0qH1Dhg00YtLuorQ YeL+ShzD/T/Cad/PJg5lfmoR0nI8Uu1pK5kw2PSkPpYMz3w1vnGcpXaOajot1h8Pye5Y FD+ksyLOasatkoBFQTPpL9BTzelPueXvxmL0lrYmuJu6KlFm49DSlwl1V+Zwi/8q0pTm ByaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DDFiZ942; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id q124si1559726oig.228.2020.02.28.01.45.33; Fri, 28 Feb 2020 01:45:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DDFiZ942; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1727018AbgB1JoW (ORCPT + 99 others); Fri, 28 Feb 2020 04:44:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:54344 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbgB1JoW (ORCPT ); Fri, 28 Feb 2020 04:44:22 -0500 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0BC12246B7 for ; Fri, 28 Feb 2020 09:44:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1582883061; bh=EY3N5ARkuQ2Fmd9dLsdkczWCpYQSSmA2gTdVVcCS6/A=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=DDFiZ942ndAh4/uGo+flTje203xmGj7xn0NowQTvbLbY7+SQw33rROqAa5nibZGrJ XSfWGSTyfiKZL0a/vmlhmTKqCMrKbN0PCcuo98GLBVV3e1/LvTfdH9HmiR3rLlzYTC VtsGWYbncN4LRy5rVHDyA/PhCjVwK2G2KjwRXL1A= Received: by mail-wm1-f51.google.com with SMTP id z12so2468487wmi.4 for ; Fri, 28 Feb 2020 01:44:20 -0800 (PST) X-Gm-Message-State: APjAAAXElwFVwpV+TLe1bU2kpoardPvQ/mCEbjuelR3kgaOGbykSdnZC zmYPgEvHnJdPAQM/LXXT91ye10rIqfZgYzdKYj67fg== X-Received: by 2002:a7b:c4cc:: with SMTP id g12mr4334566wmk.68.1582883059353; Fri, 28 Feb 2020 01:44:19 -0800 (PST) MIME-Version: 1.0 References: <20200217113947.2070436-1-javierm@redhat.com> <0fd1b499-3a5e-c78e-0279-186a4c424217@redhat.com> <5c60e016-fb30-b33d-39c6-ea30a4f777cb@redhat.com> <30819cad-1a00-1ea7-13cf-d1d15c0fa96c@redhat.com> <0d8e7525-545d-23d5-dace-6804833447d2@redhat.com> In-Reply-To: <0d8e7525-545d-23d5-dace-6804833447d2@redhat.com> From: Ard Biesheuvel Date: Fri, 28 Feb 2020 10:44:08 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RESEND PATCH v2] efi: Only print errors about failing to get certs if EFI vars are found To: David Hildenbrand Cc: Javier Martinez Canillas , Linux Kernel Mailing List , linux-efi , Hans de Goede , Eric Richter , James Morris , Michael Ellerman , Mimi Zohar , Nayna Jain , "Serge E. Hallyn" , YueHaibing , linux-security-module Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 28 Feb 2020 at 10:43, David Hildenbrand wrote: > > On 28.02.20 10:39, Ard Biesheuvel wrote: > > On Fri, 28 Feb 2020 at 10:35, David Hildenbrand wrote: > >> > >> On 28.02.20 10:31, David Hildenbrand wrote: > >>> On 28.02.20 10:19, David Hildenbrand wrote: > >>>> On 17.02.20 12:39, Javier Martinez Canillas wrote: > >>>>> If CONFIG_LOAD_UEFI_KEYS is enabled, the kernel attempts to load the certs > >>>>> from the db, dbx and MokListRT EFI variables into the appropriate keyrings. > >>>>> > >>>>> But it just assumes that the variables will be present and prints an error > >>>>> if the certs can't be loaded, even when is possible that the variables may > >>>>> not exist. For example the MokListRT variable will only be present if shim > >>>>> is used. > >>>>> > >>>>> So only print an error message about failing to get the certs list from an > >>>>> EFI variable if this is found. Otherwise these printed errors just pollute > >>>>> the kernel log ring buffer with confusing messages like the following: > >>>>> > >>>>> [ 5.427251] Couldn't get size: 0x800000000000000e > >>>>> [ 5.427261] MODSIGN: Couldn't get UEFI db list > >>>>> [ 5.428012] Couldn't get size: 0x800000000000000e > >>>>> [ 5.428023] Couldn't get UEFI MokListRT > >>>>> > >>>>> Reported-by: Hans de Goede > >>>>> Signed-off-by: Javier Martinez Canillas > >>>>> Tested-by: Hans de Goede > >>>> > >>>> This patch seems to break a very basic x86-64 QEMU setup (booting > >>>> upstream kernel with a F31 initrd - are you running basic boot tests?). > >>>> Luckily, it only took me 5 minutes to identify this patch. Reverting > >>>> this patch from linux-next fixes it for me. > >>>> > >>>> > >>>> [ 1.042766] Loaded X.509 cert 'Build time autogenerated kernel key: 6625d6e34255935276d2c9851e2458909a4bcd69' > >>>> [ 1.044314] zswap: loaded using pool lzo/zbud > >>>> [ 1.045663] Key type ._fscrypt registered > >>>> [ 1.046154] Key type .fscrypt registered > >>>> [ 1.046524] Key type fscrypt-provisioning registered > >>>> [ 1.051178] Key type big_key registered > >>>> [ 1.055108] Key type encrypted registered > >>>> [ 1.055513] BUG: kernel NULL pointer dereference, address: 0000000000000000 > >>>> [ 1.056172] #PF: supervisor instruction fetch in kernel mode > >>>> [ 1.056706] #PF: error_code(0x0010) - not-present page > >>>> [ 1.057367] PGD 0 P4D 0 > >>>> [ 1.057729] Oops: 0010 [#1] SMP NOPTI > >>>> [ 1.058249] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.6.0-rc3-next-20200228+ #79 > >>>> [ 1.059167] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.4 > >>>> [ 1.060230] RIP: 0010:0x0 > >>>> [ 1.060478] Code: Bad RIP value. > >>>> [ 1.060786] RSP: 0018:ffffbc7880637d98 EFLAGS: 00010246 > >>>> [ 1.061281] RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffffbc7880637dc8 > >>>> [ 1.061954] RDX: 0000000000000000 RSI: ffffbc7880637df0 RDI: ffffffffa73c40be > >>>> [ 1.062611] RBP: ffffbc7880637e20 R08: ffffbc7880637dac R09: ffffa0238f4ba6c0 > >>>> [ 1.063278] R10: 0000000000000000 R11: 0000000000000001 R12: 0000000000000000 > >>>> [ 1.063956] R13: ffffa024bdd6f660 R14: 0000000000000000 R15: 0000000000000000 > >>>> [ 1.064609] FS: 0000000000000000(0000) GS:ffffa023fdd00000(0000) knlGS:0000000000000000 > >>>> [ 1.065360] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > >>>> [ 1.065900] CR2: ffffffffffffffd6 CR3: 00000000b1610000 CR4: 00000000000006e0 > >>>> [ 1.066562] Call Trace: > >>>> [ 1.066803] load_uefi_certs+0xc8/0x2bb > >>>> [ 1.067171] ? get_cert_list+0xfb/0xfb > >>>> [ 1.067523] do_one_initcall+0x5d/0x2f0 > >>>> [ 1.067894] ? rcu_read_lock_sched_held+0x52/0x80 > >>>> [ 1.068337] kernel_init_freeable+0x243/0x2c2 > >>>> [ 1.068751] ? rest_init+0x23a/0x23a > >>>> [ 1.069095] kernel_init+0xa/0x106 > >>>> [ 1.069416] ret_from_fork+0x27/0x50 > >>>> [ 1.069759] Modules linked in: > >>>> [ 1.070050] CR2: 0000000000000000 > >>>> [ 1.070361] ---[ end trace fcce9bb4feb21d99 ]--- > >>>> > >>>> > >>> > >>> Sorry, wrong mail identified, the patch is actually > >>> > >>> commit 6b75d54d5258ccd655387a00bbe1b00f92f4d965 > >>> Author: Ard Biesheuvel > >>> Date: Sun Feb 16 19:46:25 2020 +0100 > >>> > >>> integrity: Check properly whether EFI GetVariable() is available > >>> > >>> Testing the value of the efi.get_variable function pointer is not > >>> > >>> which made it work. (not even able to find that patch on lkml ...) > >> > >> To clarify for Ard, your patch breaks a basic QEMU setup (see above, > >> NULL pointer dereference). Reverting your patch from linux-next makes it > >> work again. > >> > > > > Does this fix it? > > > > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > > index 41269a95ff85..d1746a579c99 100644 > > --- a/drivers/firmware/efi/efi.c > > +++ b/drivers/firmware/efi/efi.c > > @@ -300,12 +300,12 @@ static int __init efisubsys_init(void) > > { > > int error; > > > > - if (!efi_enabled(EFI_BOOT)) > > - return 0; > > - > > if (!efi_enabled(EFI_RUNTIME_SERVICES)) > > efi.runtime_supported_mask = 0; > > > > + if (!efi_enabled(EFI_BOOT)) > > + return 0; > > + > > if (efi.runtime_supported_mask) { > > /* > > * Since we process only one efi_runtime_service() at a time, an > > > > Yes, does the trick! > Thanks, David. I'll get this out and into -next asap.