Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5277072imm; Sun, 26 Aug 2018 15:31:26 -0700 (PDT) X-Google-Smtp-Source: ANB0VdalKOyUqIgg/QFsYiC0A5ugygAFg2Xo8ZFb9YVkqkqftrOqGj9Ny0/6imeE/VrsGk9Kc+Zu X-Received: by 2002:a63:2acc:: with SMTP id q195-v6mr9712523pgq.291.1535322686821; Sun, 26 Aug 2018 15:31:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535322686; cv=none; d=google.com; s=arc-20160816; b=s/jn9ElPyoxlGSLBfupXyELhVYQ5FareXQpwlrIaj9/IONEcyCqodboq45ejTmUE+e vc6CkpYWbYlfH1wApGNbUIDCTVk6igc/YKLxD8jO8pQ/1jN2F/PKDL6dg0eLhToV1xjC 3PbuuV0Eu511kx5dR+3TwyAt9BsGhL+zudAmrMUOYod7FsCnehB+4JPPICSuLcq1QqlR R08Lst7XyYcUUytQSs+wxppchx3JcPFTv+YvhG1qSwOg5H7+hfMrRete3PJhjVqdRET/ eoQKAeOmf0UWxmBdw6ffMDFMZEs48avRgGbXYu0jVsATjqI9nrAiz9lA0UTPyvF12tyR oTqA== 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 :arc-authentication-results; bh=O7p8kO3p8z7dEv5dtS72z5MSDZzJ8qRx+UY80J2Tma4=; b=NgbaOFFO6CkALVZSbuRB4H+dV7HeVWUzvWYHxIQdYJCjohW/u135jvnY4TC0t+16v3 iuJPG9Vtyb8xv6V4RgF0JHKXLtij+7/GkyiZ7hcazvPKAw9j0Ncccr9yNyJ67lA6aoO+ pqGN52Ybi7QLqtb9gbWrLCYo369RRLv5uw6qVZQSi9umqF9gy4xGcSJnloWjbeenaMoA aCvIVufoYtUmpNgOhEhxYNd9qN25YzOeRKyhgoXxkqQvWgeIdvnIMHbMsctdSbMBV+8U zDHxwgIOHWfydLVraNZUcL2qNKa2T4vkvLdNK9dj9k7ncYyvjoq4yMTBtKmeZgxyOXqp hrQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="fAZB/L7T"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r6-v6si11838519pgp.591.2018.08.26.15.31.10; Sun, 26 Aug 2018 15:31:26 -0700 (PDT) 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=@google.com header.s=20161025 header.b="fAZB/L7T"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727026AbeH0COB (ORCPT + 99 others); Sun, 26 Aug 2018 22:14:01 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:39746 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726802AbeH0COB (ORCPT ); Sun, 26 Aug 2018 22:14:01 -0400 Received: by mail-oi0-f66.google.com with SMTP id c190-v6so24114021oig.6 for ; Sun, 26 Aug 2018 15:30:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=O7p8kO3p8z7dEv5dtS72z5MSDZzJ8qRx+UY80J2Tma4=; b=fAZB/L7TXZSLTboeLraK7flX4INdYKvIctXH5B+KsEHDb0O3GIjVLIvWv+QHnZvOx+ Gc6RYTw0wRWpv8xCo455uX8+DH3t8B5gpwL7+46ncIVNLY0z76iNPmPTcO6SJ0sssqbm K9hRjZcNmzrhNDQNSGIdsZdi3ANpjhyX2QuDtQcYqcx9xCvpTHZ0VXQAUxP5aETI0a/X clCjwQpKG5iRMQLMS22FLQZ6BjrHZy49tz6bbhclV3oJAoeLQ8rKtbVaAoDGZ/XpdK3g PphTQMSSQE3TF5i+AdSiymY4Dit3ezmNTXsjyJer98zuU2WgkoX11UhhbL3i7ioOys+w HC5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=O7p8kO3p8z7dEv5dtS72z5MSDZzJ8qRx+UY80J2Tma4=; b=oTNlr9a7ilaAP2bEe3BC6Izb81pJjcIFquUO5ieJ3f44fCqresAWUZqI3BTHfmHghW KAkr+Bc5laoasdzppf0sKeDn9SKRsOC7w3np+FHIrRp+D4XpQXOROG0HCpQU902pnzl9 wiccvkQkGsUOx13LINDWfb0Lg/gXd5U7dgGEV7XLE35TNMIJysm0VPtlUDYAQSq+M+Yn ws1pqyZ17v2hAMj5yUxic6RKEIORPr8Xr+ihajwhjltXBnpGFdch1J/QcNF+pDFkuzbr 67fseJT4/MGLxR9riJG+cVAtjNpDNOnyZs38K3U+29OzGS8rH/acyIFXR5fZGh0yIJ4o mOhg== X-Gm-Message-State: APzg51DucY5eq7Jcj3c9lCduoFidDDfLGEHFG5QWqT5b7+bPS7VDRVHl dHCKQI87nLHteWV+giA/qnRSv6P7yWOmO8lVz7+kGQ== X-Received: by 2002:aca:4204:: with SMTP id p4-v6mr9465189oia.242.1535322604623; Sun, 26 Aug 2018 15:30:04 -0700 (PDT) MIME-Version: 1.0 References: <20180822153012.173508681@infradead.org> <20180823133958.GA1496@brain-police> <20180824084717.GK24124@hirez.programming.kicks-ass.net> <20180824180438.GS24124@hirez.programming.kicks-ass.net> <56A9902F-44BE-4520-A17C-26650FCC3A11@gmail.com> <9A38D3F4-2F75-401D-8B4D-83A844C9061B@gmail.com> <8E0D8C66-6F21-4890-8984-B6B3082D4CC5@gmail.com> <20180826112341.f77a528763e297cbc36058fa@kernel.org> <952A64F0-90B3-4E2F-B410-7E20BE90D617@amacapital.net> In-Reply-To: From: Jann Horn Date: Mon, 27 Aug 2018 00:29:37 +0200 Message-ID: Subject: Re: TLB flushes on fixmap changes To: Kees Cook , Andy Lutomirski Cc: Thomas Gleixner , Andy Lutomirski , mhiramat@kernel.org, Nadav Amit , Linus Torvalds , Paolo Bonzini , jkosina@suse.cz, Peter Zijlstra , Will Deacon , benh@au1.ibm.com, npiggin@gmail.com, "the arch/x86 maintainers" , Borislav Petkov , Rik van Riel , Adin Scannell , Dave Hansen , kernel list , Linux-MM , "David S. Miller" , Martin Schwidefsky , Michael Ellerman 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 Mon, Aug 27, 2018 at 12:11 AM Kees Cook wrote: > > On Sun, Aug 26, 2018 at 1:15 PM, Thomas Gleixner wrote: > > On Sun, 26 Aug 2018, Andy Lutomirski wrote: > >> > On Aug 26, 2018, at 9:47 AM, Kees Cook wrote: > >> >> On Sun, Aug 26, 2018 at 7:20 AM, Andy Lutomirski wrote: > >> >>> I tried to convince Ingo to use this method for doing "write rarely" > >> >>> and he soundly rejected it. :) I've always liked this because AFAICT, > >> >>> it's local to the CPU. I had proposed it in > >> >>> https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?h=kspp/write-rarely&id=9ab0cb2618ebbc51f830ceaa06b7d2182fe1a52d > >> >> > >> >> Ingo, can you clarify why you hate it? I personally would rather use CR3, but CR0 seems like a fine first step, at least for text_poke. > >> > > >> > Sorry, it looks like it was tglx, not Ingo: > >> > > >> > https://lkml.kernel.org/r/alpine.DEB.2.20.1704071048360.1716@nanos > >> > > >> > This thread is long, and one thing that I think went unanswered was > >> > "why do we want this to be fast?" the answer is: for doing page table > >> > updates. Page tables are becoming a bigger target for attacks now, and > >> > it's be nice if they could stay read-only unless they're getting > >> > updated (with something like this). > >> > > >> > > >> It kind of sounds like tglx would prefer the CR3 approach. And indeed my > >> patch has a serious problem wrt the NMI code. > > > > That's exactly the problem I have with CR0. It leaves everything and some > > more writeable for any code which can interrupt that section. > > I thought the point was that the implementation I suggested was > NMI-proof? (And in reading Documentation/preempt-locking.txt it sounds > like disabling interrupts is redundant to preempt_disable()? But I > don't understand how; it looks like the preempt stuff is advisory?) Where are you dealing with NMIs? local_irq_disable() disables the interrupt flag, but Non-Maskable Interrupts can still come in. As far as I know, the only way to block those is to artificially generate an NMI yourself (Xen does that sometimes). Otherwise, you have to twiddle CR0.WP in the NMI handler entry/exit code.