Received: by 10.223.185.116 with SMTP id b49csp1057353wrg; Fri, 16 Feb 2018 11:37:56 -0800 (PST) X-Google-Smtp-Source: AH8x226jvYrujXRvBnAWUV9sr+B5KvG9JXLJSv8aDJdjuXJNC3wJdQI2sUEHDhJZ+b9rysAQkESl X-Received: by 10.99.124.66 with SMTP id l2mr5971929pgn.290.1518809876121; Fri, 16 Feb 2018 11:37:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518809876; cv=none; d=google.com; s=arc-20160816; b=b3Yt9HlqQs+vfIZlPO8ELXQZygI3BNajiM0XmdkJoiMmSYzvGHHOnxoNE5kCHmkxoh iLM76XMPCCA7LREMbOovlBeWlCqLUKzqUgxDNgHAAcPcbPNzStUndDArsOYcZud2qtrm RQtREBcxKSWRiGm9JiIwlb0eVF//+vbWqMi/UFwwsg89X/VAkk8lpMKJ7TD/msGoxlnW l40zdNa8l/FeRNUSnO3iKaZ1mU42ZFe+laZvnOuiX3G+RpmZL+TJtIgWQpIv+ZYJ5ep/ /AIUM20RiROzom1f9bwnPPcfBthNSU07c5j6kTq+F4wescyEcOYne3SEZp0WcVOOk0Qq sKrw== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=APD/4uMO9T8K4PsBdXhpKGZbxCpDu/R/wQspareLGu4=; b=qYwOzlopjgPSTJs4SjzqsOkXWDQYVhl0L7Qm8gmfj7QbPAZ1gzBLKX12Xcd4MCbMp0 l0Cia3o9Qk0OIHMu+HonfaMd7uNhenD+ejzCSbaJ6E+hHnWRj+d9c0oIRxV99CDQGAiM fXAwaWWG46K/TY71jWtizCMIGuz3zcz5murIbN6Rj5NHI9wkGyoivFh+YsqtgwMMUiT9 ZS61TH2IvZsKrfcy6W03A9j9en1nOva2HsBFY/plX1uwrlG/Wp3AWDIsHkuQHKNwuB9x PEtRtMlA7nO3YcdnrSksP0w9Ky5rGNZf8hHZhDhbcfG8Z713eLjfbxarFJ0oyKMYIEgx P8qA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Fe61/6A1; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e12si6929979pfl.142.2018.02.16.11.37.42; Fri, 16 Feb 2018 11:37:56 -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=@linaro.org header.s=google header.b=Fe61/6A1; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751334AbeBPThE (ORCPT + 99 others); Fri, 16 Feb 2018 14:37:04 -0500 Received: from mail-io0-f195.google.com ([209.85.223.195]:36635 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750830AbeBPThA (ORCPT ); Fri, 16 Feb 2018 14:37:00 -0500 Received: by mail-io0-f195.google.com with SMTP id t22so5257946iob.3 for ; Fri, 16 Feb 2018 11:37:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=APD/4uMO9T8K4PsBdXhpKGZbxCpDu/R/wQspareLGu4=; b=Fe61/6A1beN0bDHOUl2L+VO+p0gtcxE2PMJBvcd4SKbOMzJ9OBdBd5frR+pwhlddTh G3Qv3/uYjOvdl525fbLaR47i0e4pPx85zzO2bgYK74nTGLFO++t1grqlQR7rrvNiUyHZ A+zVrrYrTBSonUhZuGzt7S2AnG2qtjlWxAyA4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=APD/4uMO9T8K4PsBdXhpKGZbxCpDu/R/wQspareLGu4=; b=Of7Rp4zCK60QzSuiZO4fJ+5L6YnAl3c2r5bvLcnCGxxiWbtaAG58zGwDrHxWkTTua7 o43PwXJgntZHJdyJW+6IWYT9lO40toW72fNMzsJwKBj9UDXbqjYcB4/qT+nGUqX1mQxC WRXZ8bcdRxyj0Mfgcw/S6rCqffUF6Hcd1gWuA2p6fghlVwBcHMaZIBfT9XskTxS2irQe dp7bvxfOaBVlHn7OjuRkwYyNVWMqRa4StwBPFivuIn1/nkzNSBxhI/rRRrGkv/lSUJ47 +WwB+gweJBKu5x++rHNe5dVVqaB8wqPfq+q2ipiH+2Buc7wYyON/2U9D+PBW6oLqqnr4 dS0w== X-Gm-Message-State: APf1xPB98quiWaq4XLLYTo88VJXg3pxJUob5/j84lecqshx6pCR5v2JG jBzvXRLoY6ml069pYoYohzd9G9K4NtTNlAIaYEMG+w== X-Received: by 10.107.56.69 with SMTP id f66mr3099319ioa.170.1518809511332; Fri, 16 Feb 2018 11:31:51 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.138.209 with HTTP; Fri, 16 Feb 2018 11:31:50 -0800 (PST) In-Reply-To: <20180216192220.wljl23g533sc3oxg@redhat.com> References: <20180215182208.35003-1-joe.konno@linux.intel.com> <20180216105548.GA29042@pd.tnic> <20180216110821.GB29042@pd.tnic> <20180216184832.sqreq5zhar3jqdae@jbkonno-saint14> <20180216192220.wljl23g533sc3oxg@redhat.com> From: Ard Biesheuvel Date: Fri, 16 Feb 2018 19:31:50 +0000 Message-ID: Subject: Re: [PATCH 0/2] efivars: reading variables can generate SMIs To: Peter Jones Cc: Joe Konno , Borislav Petkov , Matthew Garrett , Ingo Molnar , Andy Lutomirski , linux-efi@vger.kernel.org, Linux Kernel Mailing List , Jeremy Kerr , Andi Kleen , Tony Luck , Benjamin Drung 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 16 February 2018 at 19:22, Peter Jones wrote: > On Fri, Feb 16, 2018 at 10:48:32AM -0800, Joe Konno wrote: >> On Fri, Feb 16, 2018 at 11:18:12AM +0000, Ard Biesheuvel wrote: >> > On 16 February 2018 at 11:08, Borislav Petkov wrote: >> > > On Fri, Feb 16, 2018 at 10:58:47AM +0000, Ard Biesheuvel wrote: >> > >> By your own reasoning above, that's a no-no as well. >> > > >> > > I'm sure we can come up with some emulation - the same way we did the >> > > BIOS emulation. >> > > >> > >> But thanks for your input. Anyone else got something constructive to contribute? >> > > >> > > The not-breaking userspace is constructive contribution. The last >> > > paragraph is my usual rant. >> > > >> > >> > Fair enough. And I am not disagreeing with you either. >> > >> > So question to Joe: is it well defined which variables may exhibit >> > this behavior? >> >> For brevity's sake, "not yet." Folks-- e.g. firmware writers and >> equipment makers-- may use SMIs more (or less) than others. So, how many >> SMIs generated by the reference shell script can, and will, vary >> platform to platform. I and my colleagues are digging into this. > > As a first guess: anything generated during boot is probably not an > SMI. Everything else is probably an SMI. In fact, I would expect that > for most systems, the entire list of things that *don't* generate an SMI > (aside from a few IBV specific variables) is all the variables in Table > 10 of the UEFI spec that don't have the NV flag. > >> > Given that UEFI variables are GUID scoped, would whitelisting certain >> > GUIDs (the ones userland currently relies on to be readable my >> > non-privileged users) and making everything else user-only solve this >> > problem as well? >> >> Perhaps. I don't want us chasing white rabbits just yet, but the >> whitelist is but one approach under consideration. We may see some other >> patches or RFCs about caching and/or shadowing variable values in >> efivarfs to reduce the number of direct EFI reads, with the goal of >> reducing how many SMIs are generated. >> >> Any obvious EFI variables that userspace tools have come to depend on-- >> those which normal, unprivileged users need to read-- are helpful inputs >> to this discussion. > > So, our big userland consumers are efibootmgr, fwupdate, and > "systemctl reboot --firmware-setup". efibootmgr and fwupdate can do the > "show the current status" half of their job as a user right now, but > they rely on root for the other half anyway. I don't think we normally > use libfwup as non-root even for reading status. So basically, the use > case from userland that this will effect looks like: > > efibootmgr -v > *scratch head* > sudo su - > efibootmgr -b 0000 -B > efibootmgr -b 0000 -c -L "fixed entry" ... > exit > > I don't feel really bad about people having to move the third line up to > the top of that. It's also not a use case you can have very much of: it > means you manually booted without any valid boot entries. fallback.efi > would have created a valid boot entry if you didn't do it manually. > > "systemctl reboot --firmware-setup" effectively runs as root in all > cases. > > The only thing we really must ensure to preserve the other workflows > is making sure creat() and open() with 0644 doesn't return an error (it > obviously won't be preserved across a reboot), because that would break > the existing tools. But I don't see anything in this patchset which > will cause that. > > tl;dr: I think changing everything to 0600 is probably completely fine, > and whitelisting is probably pointless. This is why I was leaning towards applying these patches: not breaking userland is an important rule, but it does not imply every aspect of behavior observable by userland is set in stone. In other words, I agree with Peter that making this change does not *break* userland in a way anyone is likely to care deeply about. Adding a caching layer to efivarfs for this purpose is really overkill IMHO. Also, we need this only on x86, so I'd like to see it proposed in a way that allows it to be compiled out for architectures that have no need for it.