Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1016997imu; Fri, 11 Jan 2019 13:21:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN7CUHazzb2och/FHtlhRyGvdv1HE7IPFElgzwwEQtgb2r5em/mMWfwffcJVFW3sLkyVjynX X-Received: by 2002:a63:8b41:: with SMTP id j62mr15021016pge.182.1547241698053; Fri, 11 Jan 2019 13:21:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547241698; cv=none; d=google.com; s=arc-20160816; b=Rp8/OdDdxqVWjB99Hxoz0zAEMDZgQZu1tbYmKurRXDZsLZzFAGEdYqj9+oqrWT4K70 7yCtplypbdac2W6KYG5Nvn9VaF2XiICdlHyEpy+qhqFc0KwTJARcZTEYNWxshQZgxbbS NHyEQEuT97Hhdrh9G+r60RDyxOkBJWRvDSdNs4+ffavhMambhmKjVZwJHEt8qf6uH3u3 mc6vST25wbZCPYB9pY/1bpKV+X2Plbr/XNXWBZ+etuc9N6np8Y8pEoLPPGHKd5chY1de MHAR51ZyQ9VQPXU/9/LNi0S5ln5wZs/t2BBr+d2ATks+PKq9BjZVy3N+Rr/1pccb3CXw R65Q== 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=HDU1PDMdWvZWz0lbUz1AEBxnqbWSAiRzrxve2qVj3xg=; b=D/RdZVV06YgCKapYw+SyS3y4XjcQLMClPq7vuwwXu20ofWAfSztzhn7PXogZgqdRCK qx+dHthErjbhY9rfAPVzk3WoXfHm/UbLLexkL9YASbmPuV4TeHyewSnbPbgM6T6iddfj 24ioc+SlH+m6YhvNyOBdDJHzeHxyCGg7EY6b4q5lmKyELUPAd7XIaBDEZ/DpUXdO4Iv7 dvSB7KKI81nAV2WKV7avZO4cTyUcbgkcBPMHZxosijgkrfhj1TgZRIA7L3//K/AIYrTL pMYBXjs8sXF6yaLV+k6zhBn7Y/xhnV5p1an+buB5oqGDLdQDZn2hfQkqM2vJ1vJ+WqwP 9Xtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="iS/86JjL"; 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 e7si966730pgv.499.2019.01.11.13.21.22; Fri, 11 Jan 2019 13:21:38 -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="iS/86JjL"; 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 S1726542AbfAKVGo (ORCPT + 99 others); Fri, 11 Jan 2019 16:06:44 -0500 Received: from mail.kernel.org ([198.145.29.99]:57196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726292AbfAKVGo (ORCPT ); Fri, 11 Jan 2019 16:06:44 -0500 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 84986218AE for ; Fri, 11 Jan 2019 21:06:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547240802; bh=6jQeBnq89TcqELbCmxN50WFICAEpyjYKrULbIaxa+Ck=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=iS/86JjLz3y3VpdiWB//3a4pu7zv+lE1+4CjwxgcFmTcYjtTN9DZqc3Y9whDvHuVi /vOjeFe5NY12IngK0s7qo3LyG5+/TgKVfVxMpzdXsu6KRMUTUQDT4VlkINWets9dnF 3K2zM24EfGS05oZd9UlKU2V79qZPn6J9PnL7GlOE= Received: by mail-wr1-f46.google.com with SMTP id j2so16696147wrw.1 for ; Fri, 11 Jan 2019 13:06:42 -0800 (PST) X-Gm-Message-State: AJcUukf7dJW7pZlk/aSlngYBHcY0ou5AnsMRCpddr9FAYRG7N/cQi3xi 1rBf4UWAFYxgHbWIFQPpVgaUBHRrrVxEPkClHpYSNQ== X-Received: by 2002:adf:ea81:: with SMTP id s1mr14599888wrm.309.1547240799072; Fri, 11 Jan 2019 13:06:39 -0800 (PST) MIME-Version: 1.0 References: <31fe7522-0a59-94c8-663e-049e9ad2bff6@intel.com> <7e3b2c4b-51ff-2027-3a53-8c798c2ca588@oracle.com> <8ffc77a9-6eae-7287-0ea3-56bfb61758cd@intel.com> In-Reply-To: <8ffc77a9-6eae-7287-0ea3-56bfb61758cd@intel.com> From: Andy Lutomirski Date: Fri, 11 Jan 2019 13:06:27 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH v7 00/16] Add support for eXclusive Page Frame Ownership To: Dave Hansen Cc: Khalid Aziz , Juerg Haefliger , Tycho Andersen , jsteckli@amazon.de, Andi Kleen , Linus Torvalds , liran.alon@oracle.com, Kees Cook , Konrad Rzeszutek Wilk , deepa.srinivasan@oracle.com, chris hyser , Tyler Hicks , "Woodhouse, David" , Andrew Cooper , Jon Masters , Boris Ostrovsky , kanth.ghatraju@oracle.com, Joao Martins , Jim Mattson , pradeep.vincent@oracle.com, John Haxby , Thomas Gleixner , "Kirill A. Shutemov" , Christoph Hellwig , steven.sistare@oracle.com, Kernel Hardening , Linux-MM , LKML , Andy Lutomirski , Peter Zijlstra 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, Jan 11, 2019 at 12:42 PM Dave Hansen wrote: > > >> The second process could easily have the page's old TLB entry. It could > >> abuse that entry as long as that CPU doesn't context switch > >> (switch_mm_irqs_off()) or otherwise flush the TLB entry. > > > > That is an interesting scenario. Working through this scenario, physmap > > TLB entry for a page is flushed on the local processor when the page is > > allocated to userspace, in xpfo_alloc_pages(). When the userspace passes > > page back into kernel, that page is mapped into kernel space using a va > > from kmap pool in xpfo_kmap() which can be different for each new > > mapping of the same page. The physical page is unmapped from kernel on > > the way back from kernel to userspace by xpfo_kunmap(). So two processes > > on different CPUs sharing same physical page might not be seeing the > > same virtual address for that page while they are in the kernel, as long > > as it is an address from kmap pool. ret2dir attack relies upon being > > able to craft a predictable virtual address in the kernel physmap for a > > physical page and redirect execution to that address. Does that sound right? > > All processes share one set of kernel page tables. Or, did your patches > change that somehow that I missed? > > Since they share the page tables, they implicitly share kmap*() > mappings. kmap_atomic() is not *used* by more than one CPU, but the > mapping is accessible and at least exists for all processors. > > I'm basically assuming that any entry mapped in a shared page table is > exploitable on any CPU regardless of where we logically *want* it to be > used. > > We can, very easily, have kernel mappings that are private to a given mm. Maybe this is useful here.