From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4EED3C282E1 for ; Mon, 22 Apr 2019 22:23:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1AE2020811 for ; Mon, 22 Apr 2019 22:23:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Vl0fYQ0U" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727413AbfDVWXr (ORCPT ); Mon, 22 Apr 2019 18:23:47 -0400 Received: from mail-vk1-f193.google.com ([209.85.221.193]:41881 "EHLO mail-vk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727274AbfDVWXq (ORCPT ); Mon, 22 Apr 2019 18:23:46 -0400 Received: by mail-vk1-f193.google.com with SMTP id d15so2752951vka.8 for ; Mon, 22 Apr 2019 15:23:45 -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=Apsh13b43ex5kM603MFVFBzVRJeAAR6IMS53yCHVuRM=; b=Vl0fYQ0UCHGtndl0jafErZw5vqbDAq4DrFX3SfBAIMhEhneL9rXawPTcud8fgV5g3D W/sHE49ARVD9KYD5FloU01n2RfA2pTgnKMthR4SE5EVifhT+Zv7f89iMoQqyLkH17UHR Ufjeoo3iZe8A1ywqY/dQX9OJ6hQY+RdFMicuSiIFmS2kjW0kxDgF0PQchZJoFDeQwLJ4 Bu9iNZw8/m1h5Vvq6bsIi0oFDRabTh4fUKE/VXZ1BpEeHCWZiVc862ytrlz+nAaTR+Cp kF/vZydc6r2yg2X0nSiZbBoPzLhOuIzzabOzb88ffPr/VLLo66HUZNIe7JxAbYTKUz7T O38g== 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=Apsh13b43ex5kM603MFVFBzVRJeAAR6IMS53yCHVuRM=; b=iVgAJbYU+yN0K4r6wat1/ubuam7lPcsHSMhA1pUVKrQHu/gBFANwB7cjXLpy03EP2s rhf1XchLVDjabVoSc+nxHiui7Rd5qd9o2WULgvewGYb9N3OdI+auBF87UJFoXFx+HPhX GiKm6Lffo67XfzVx/TuXab2YIqyRIG9+kglCU9wkohb7uf0mXyKKzd1AekdQIzXg3+LE diJJRVOXr6JOSNgOHtrx8seO3n7llYuQu3Q7o48VcQ4/0YFY15Tz2xY/CTxutshdsTD+ 2VJMLpX8t8m/g6MEnQZ5pq6AHZM8GMnH+ChBfhnq1plQPSjiTKnVyFNVQR5prjXqW0I6 CVVg== X-Gm-Message-State: APjAAAVet67OlQlGsHBPeDX5w7soI7jkOm5KPqRfu4+0MAPRz/jGmx1n vxSF1ZERBGgygbjCrCrwYRZxluZtAxpB1PP1UklVIQ== X-Google-Smtp-Source: APXvYqxiq50qJu8wanUuH+yOCTaJNMUpHEhGXVEwCujnFscJAmlLegU3s6VeZj+61I7iVGG+tUCCywSMlxsTtse/mUo= X-Received: by 2002:a1f:2e07:: with SMTP id u7mr11692664vku.44.1555971825052; Mon, 22 Apr 2019 15:23:45 -0700 (PDT) MIME-Version: 1.0 References: <20190417161042.GA43453@gmail.com> <20190417170918.GA68678@gmail.com> <56A175F6-E5DA-4BBD-B244-53B786F27B7F@gmail.com> <20190417172632.GA95485@gmail.com> <063753CC-5D83-4789-B594-019048DE22D9@gmail.com> <8f9d059d-e720-cd24-faa6-45493fc012e0@oracle.com> In-Reply-To: <8f9d059d-e720-cd24-faa6-45493fc012e0@oracle.com> From: Kees Cook Date: Mon, 22 Apr 2019 15:23:32 -0700 Message-ID: Subject: Re: [RFC PATCH v9 03/13] mm: Add support for eXclusive Page Frame Ownership (XPFO) To: Khalid Aziz Cc: Andy Lutomirski , Linus Torvalds , Thomas Gleixner , Nadav Amit , Ingo Molnar , Juerg Haefliger , Tycho Andersen , Julian Stecklina , Konrad Rzeszutek Wilk , Juerg Haefliger , deepa.srinivasan@oracle.com, chris hyser , Tyler Hicks , David Woodhouse , Andrew Cooper , Jon Masters , Boris Ostrovsky , iommu , X86 ML , "linux-alpha@vger.kernel.org" , "open list:DOCUMENTATION" , Linux List Kernel Mailing , Linux-MM , LSM List , Khalid Aziz , Andrew Morton , Peter Zijlstra , Dave Hansen , Borislav Petkov , "H. Peter Anvin" , Arjan van de Ven , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: On Thu, Apr 18, 2019 at 7:35 AM Khalid Aziz wrote: > > On 4/17/19 11:41 PM, Kees Cook wrote: > > On Wed, Apr 17, 2019 at 11:41 PM Andy Lutomirski wrote: > >> I don't think this type of NX goof was ever the argument for XPFO. > >> The main argument I've heard is that a malicious user program writes a > >> ROP payload into user memory (regular anonymous user memory) and then > >> gets the kernel to erroneously set RSP (*not* RIP) to point there. > > > > Well, more than just ROP. Any of the various attack primitives. The NX > > stuff is about moving RIP: SMEP-bypassing. But there is still basic > > SMAP-bypassing for putting a malicious structure in userspace and > > having the kernel access it via the linear mapping, etc. > > > >> I find this argument fairly weak for a couple reasons. First, if > >> we're worried about this, let's do in-kernel CFI, not XPFO, to > > > > CFI is getting much closer. Getting the kernel happy under Clang, LTO, > > and CFI is under active development. (It's functional for arm64 > > already, and pieces have been getting upstreamed.) > > > > CFI theoretically offers protection with fairly low overhead. I have not > played much with CFI in clang. I agree with Linus that probability of > bugs in XPFO implementation itself is a cause of concern. If CFI in > Clang can provide us the same level of protection as XPFO does, I > wouldn't want to push for an expensive change like XPFO. > > If Clang/CFI can't get us there for extended period of time, does it > make sense to continue to poke at XPFO? Well, I think CFI will certainly vastly narrow the execution paths available to an attacker, but what I continue to see XPFO useful for is stopping attacks that need to locate something in memory. (i.e. not ret2dir but, like, read2dir.) It's arguable that such attacks would just use heap, stack, etc to hold such things, but the linear map remains relatively easy to find/target. But I agree: the protection is getting more and more narrow (especially with CFI coming down the pipe), and if it's still a 28% hit, that's not going to be tenable for anyone but the truly paranoid. :) All that said, there isn't a very good backward-edge CFI protection (i.e. ROP defense) on x86 in Clang. The forward-edge looks decent, but requires LTO, etc. My point is there is still a long path to gaining CFI in upstream. -- Kees Cook