From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756211AbdCXJwY (ORCPT ); Fri, 24 Mar 2017 05:52:24 -0400 Received: from mail-it0-f45.google.com ([209.85.214.45]:33560 "EHLO mail-it0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755280AbdCXJwQ (ORCPT ); Fri, 24 Mar 2017 05:52:16 -0400 MIME-Version: 1.0 In-Reply-To: <20170324094656.r2nln4vbidj5jhqt@pd.tnic> References: <1490331592-31860-1-git-send-email-bhe@redhat.com> <20170324080833.GA15200@gmail.com> <20170324083451.GC30442@x1> <20170324084609.GA6807@dhcp-128-65.nay.redhat.com> <20170324092433.GA3237@gmail.com> <20170324094034.2afxgg43wlezdka5@pd.tnic> <20170324094656.r2nln4vbidj5jhqt@pd.tnic> From: Ard Biesheuvel Date: Fri, 24 Mar 2017 09:52:09 +0000 Message-ID: Subject: Re: [PATCH v2] x86/mm/KASLR: EFI region is mistakenly included into KASLR VA space for randomization To: Borislav Petkov Cc: Ingo Molnar , Dave Young , Baoquan He , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "x86@kernel.org" , "linux-efi@vger.kernel.org" , Thomas Garnier , Kees Cook , Andrew Morton , Masahiro Yamada , Bhupesh Sharma 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 24 March 2017 at 09:46, Borislav Petkov wrote: > On Fri, Mar 24, 2017 at 09:42:40AM +0000, Ard Biesheuvel wrote: >> That is a different matter. If the regions are only mapped while >> runtime services invocations are in progress (as we do on ARM), I am >> not sure if it matters that much, given how rarely that occurs in >> normal use. > > Question is, is there anything worth protecting with ASLR or we don't > care? I wanna say, we should randomize just in case, especially as it > shouldn't be that expensive to do. > Well, given that in many cases, these pages are mapped R+W+X, I would say that there is a risk involved in having these data structures at fixed offsets. Since UEFI v2.6, we have a new firmware table that describes strict permission attributes for these regions, so everything can be mapped writable or executable but never both. (Sai wired up the support for this for x86 in v4.10) > Also, how does the whole EFI-in-the-kexec-ed-kernel work on ARM? Runtime > services get mapped on-demand in the kexec-ed kernel too? > Yes. On ARM, we use an ordinary mm_struct and just do a switch_mm() with preemption disabled. So there is no need to reserve kernel VA ranges, all UEFI runtime mappings are in the user area. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ard Biesheuvel Subject: Re: [PATCH v2] x86/mm/KASLR: EFI region is mistakenly included into KASLR VA space for randomization Date: Fri, 24 Mar 2017 09:52:09 +0000 Message-ID: References: <1490331592-31860-1-git-send-email-bhe@redhat.com> <20170324080833.GA15200@gmail.com> <20170324083451.GC30442@x1> <20170324084609.GA6807@dhcp-128-65.nay.redhat.com> <20170324092433.GA3237@gmail.com> <20170324094034.2afxgg43wlezdka5@pd.tnic> <20170324094656.r2nln4vbidj5jhqt@pd.tnic> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Return-path: In-Reply-To: <20170324094656.r2nln4vbidj5jhqt-fF5Pk5pvG8Y@public.gmane.org> Sender: linux-efi-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Borislav Petkov Cc: Ingo Molnar , Dave Young , Baoquan He , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "stable-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , "x86-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org" , "linux-efi-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , Thomas Garnier , Kees Cook , Andrew Morton , Masahiro Yamada , Bhupesh Sharma List-Id: linux-efi@vger.kernel.org On 24 March 2017 at 09:46, Borislav Petkov wrote: > On Fri, Mar 24, 2017 at 09:42:40AM +0000, Ard Biesheuvel wrote: >> That is a different matter. If the regions are only mapped while >> runtime services invocations are in progress (as we do on ARM), I am >> not sure if it matters that much, given how rarely that occurs in >> normal use. > > Question is, is there anything worth protecting with ASLR or we don't > care? I wanna say, we should randomize just in case, especially as it > shouldn't be that expensive to do. > Well, given that in many cases, these pages are mapped R+W+X, I would say that there is a risk involved in having these data structures at fixed offsets. Since UEFI v2.6, we have a new firmware table that describes strict permission attributes for these regions, so everything can be mapped writable or executable but never both. (Sai wired up the support for this for x86 in v4.10) > Also, how does the whole EFI-in-the-kexec-ed-kernel work on ARM? Runtime > services get mapped on-demand in the kexec-ed kernel too? > Yes. On ARM, we use an ordinary mm_struct and just do a switch_mm() with preemption disabled. So there is no need to reserve kernel VA ranges, all UEFI runtime mappings are in the user area.