From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753218AbdK0ShX (ORCPT ); Mon, 27 Nov 2017 13:37:23 -0500 Received: from mail-ua0-f182.google.com ([209.85.217.182]:39366 "EHLO mail-ua0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752986AbdK0ShV (ORCPT ); Mon, 27 Nov 2017 13:37:21 -0500 X-Google-Smtp-Source: AGs4zMYBuBOLfwDSbWbYBsGIozC8f27ioxbop/SSFlzCMsp20S9MK4WBUiMTZxXv7hQ5+xHt9/pV5l+jA8EEUP2MY2M= MIME-Version: 1.0 In-Reply-To: <07d101b3-d17a-7781-f05e-96738e6d6848@linux.intel.com> References: <20171126231403.657575796@linutronix.de> <20171126232414.313869499@linutronix.de> <07d101b3-d17a-7781-f05e-96738e6d6848@linux.intel.com> From: Kees Cook Date: Mon, 27 Nov 2017 10:37:19 -0800 Message-ID: Subject: Re: [patch V2 1/5] x86/kaiser: Respect disabled CPU features To: Dave Hansen Cc: Thomas Gleixner , LKML , Andy Lutomirski , Ingo Molnar , Borislav Petkov , Brian Gerst , Denys Vlasenko , "H. Peter Anvin" , Josh Poimboeuf , Linus Torvalds , Peter Zijlstra , Rik van Riel , Daniel Gruss , Hugh Dickins , Linux-MM , michael.schwarz@iaik.tugraz.at, moritz.lipp@iaik.tugraz.at, richard.fellner@student.tugraz.at 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 Mon, Nov 27, 2017 at 10:11 AM, Dave Hansen wrote: >> --- a/arch/x86/include/asm/pgtable_64.h >> +++ b/arch/x86/include/asm/pgtable_64.h >> @@ -222,7 +222,8 @@ static inline pgd_t kaiser_set_shadow_pg >> * wrong CR3 value, userspace will crash >> * instead of running. >> */ >> - pgd.pgd |= _PAGE_NX; >> + if (__supported_pte_mask & _PAGE_NX) >> + pgd.pgd |= _PAGE_NX; >> } > > Thanks for catching that. It's definitely a bug. Although, > practically, it's hard to hit, right? I think everything 64-bit > supports NX unless the hypervisor disabled it or something. There was a very narrow window where x86_64 machines were made without NX. :( This is reflected in x86_report_nx(), though maybe we should add a "OMG, why?" when 64-bit but no NX. ;) -Kees -- Kees Cook Pixel Security