From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752643AbdDHPUi (ORCPT ); Sat, 8 Apr 2017 11:20:38 -0400 Received: from mail.kernel.org ([198.145.29.136]:42082 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751663AbdDHPUa (ORCPT ); Sat, 8 Apr 2017 11:20:30 -0400 MIME-Version: 1.0 In-Reply-To: References: <1490811363-93944-1-git-send-email-keescook@chromium.org> <1490811363-93944-5-git-send-email-keescook@chromium.org> From: Andy Lutomirski Date: Sat, 8 Apr 2017 08:20:03 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [kernel-hardening] Re: [RFC v2][PATCH 04/11] x86: Implement __arch_rare_write_begin/unmap() To: Daniel Micay Cc: Andy Lutomirski , Mathias Krause , Thomas Gleixner , Kees Cook , "kernel-hardening@lists.openwall.com" , Mark Rutland , Hoeun Ryu , PaX Team , Emese Revfy , Russell King , X86 ML , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Peter Zijlstra Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 8, 2017 at 12:33 AM, Daniel Micay wrote: > The > submitted code is aimed at rare writes to globals, but this feature is > more than that and design decisions shouldn't be based on just the > short term. Then, if you disagree with a proposed design, *explain why* in a standalone manner. Say what future uses a different design would have. > I actually care a lot more about 64-bit ARM support than I do x86, but > using a portable API for pax_open_kernel (for the simple uses at > least) is separate from choosing the underlying implementation. There > might not be a great way to do it on the architectures I care about > but that doesn't need to hinder x86. It's really not that much code... > A weaker/slower implementation for x86 also encourages the same > elsewhere. No one has explained how CR0.WP is weaker or slower than my proposal. Here's what I'm proposing: At boot, choose a random address A. Create an mm_struct that has a single VMA starting at A that represents the kernel's rarely-written section. Compute O = (A - VA of rarely-written section). To do a rare write, use_mm() the mm, write to (VA + O), then unuse_mm(). This should work on any arch that has an MMU that allows this type of aliasing and that doesn't have PA-based protections on the rarely-written section. It'll be considerably slower than CR0.WP on a current x86 kernel, but, with PCID landed, it shouldn't be much slower. It has the added benefit that writes to non-rare-write data using the rare-write primitive will fail. --Andy From mboxrd@z Thu Jan 1 00:00:00 1970 From: luto@kernel.org (Andy Lutomirski) Date: Sat, 8 Apr 2017 08:20:03 -0700 Subject: [kernel-hardening] Re: [RFC v2][PATCH 04/11] x86: Implement __arch_rare_write_begin/unmap() In-Reply-To: References: <1490811363-93944-1-git-send-email-keescook@chromium.org> <1490811363-93944-5-git-send-email-keescook@chromium.org> Message-ID: To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Sat, Apr 8, 2017 at 12:33 AM, Daniel Micay wrote: > The > submitted code is aimed at rare writes to globals, but this feature is > more than that and design decisions shouldn't be based on just the > short term. Then, if you disagree with a proposed design, *explain why* in a standalone manner. Say what future uses a different design would have. > I actually care a lot more about 64-bit ARM support than I do x86, but > using a portable API for pax_open_kernel (for the simple uses at > least) is separate from choosing the underlying implementation. There > might not be a great way to do it on the architectures I care about > but that doesn't need to hinder x86. It's really not that much code... > A weaker/slower implementation for x86 also encourages the same > elsewhere. No one has explained how CR0.WP is weaker or slower than my proposal. Here's what I'm proposing: At boot, choose a random address A. Create an mm_struct that has a single VMA starting at A that represents the kernel's rarely-written section. Compute O = (A - VA of rarely-written section). To do a rare write, use_mm() the mm, write to (VA + O), then unuse_mm(). This should work on any arch that has an MMU that allows this type of aliasing and that doesn't have PA-based protections on the rarely-written section. It'll be considerably slower than CR0.WP on a current x86 kernel, but, with PCID landed, it shouldn't be much slower. It has the added benefit that writes to non-rare-write data using the rare-write primitive will fail. --Andy From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: References: <1490811363-93944-1-git-send-email-keescook@chromium.org> <1490811363-93944-5-git-send-email-keescook@chromium.org> From: Andy Lutomirski Date: Sat, 8 Apr 2017 08:20:03 -0700 Message-ID: Content-Type: text/plain; charset=UTF-8 Subject: Re: [kernel-hardening] Re: [RFC v2][PATCH 04/11] x86: Implement __arch_rare_write_begin/unmap() To: Daniel Micay Cc: Andy Lutomirski , Mathias Krause , Thomas Gleixner , Kees Cook , "kernel-hardening@lists.openwall.com" , Mark Rutland , Hoeun Ryu , PaX Team , Emese Revfy , Russell King , X86 ML , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Peter Zijlstra List-ID: On Sat, Apr 8, 2017 at 12:33 AM, Daniel Micay wrote: > The > submitted code is aimed at rare writes to globals, but this feature is > more than that and design decisions shouldn't be based on just the > short term. Then, if you disagree with a proposed design, *explain why* in a standalone manner. Say what future uses a different design would have. > I actually care a lot more about 64-bit ARM support than I do x86, but > using a portable API for pax_open_kernel (for the simple uses at > least) is separate from choosing the underlying implementation. There > might not be a great way to do it on the architectures I care about > but that doesn't need to hinder x86. It's really not that much code... > A weaker/slower implementation for x86 also encourages the same > elsewhere. No one has explained how CR0.WP is weaker or slower than my proposal. Here's what I'm proposing: At boot, choose a random address A. Create an mm_struct that has a single VMA starting at A that represents the kernel's rarely-written section. Compute O = (A - VA of rarely-written section). To do a rare write, use_mm() the mm, write to (VA + O), then unuse_mm(). This should work on any arch that has an MMU that allows this type of aliasing and that doesn't have PA-based protections on the rarely-written section. It'll be considerably slower than CR0.WP on a current x86 kernel, but, with PCID landed, it shouldn't be much slower. It has the added benefit that writes to non-rare-write data using the rare-write primitive will fail. --Andy