From: Yu-cheng Yu Subject: Re: [RFC PATCH 3/3] Prevent user from writing to IBT bitmap. Date: Mon, 01 Jul 2019 12:48:56 -0700 Message-ID: References: <20190628194158.2431-1-yu-cheng.yu@intel.com> <20190628194158.2431-3-yu-cheng.yu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org To: Andy Lutomirski Cc: X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , "open list:DOCUMENTATION" , Linux-MM , linux-arch , Linux API , Arnd Bergmann , Balbir Singh , Borislav Petkov , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H.J. Lu" , Jann Horn , Jonathan Corbet , Kees Cook , Mike Kravetz List-Id: linux-api@vger.kernel.org On Sat, 2019-06-29 at 16:44 -0700, Andy Lutomirski wrote: > On Fri, Jun 28, 2019 at 12:50 PM Yu-cheng Yu wrote: > > > > The IBT bitmap is visiable from user-mode, but not writable. > > > > Signed-off-by: Yu-cheng Yu > > > > --- > > arch/x86/mm/fault.c | 7 +++++++ > > 1 file changed, 7 insertions(+) > > > > diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c > > index 59f4f66e4f2e..231196abb62e 100644 > > --- a/arch/x86/mm/fault.c > > +++ b/arch/x86/mm/fault.c > > @@ -1454,6 +1454,13 @@ void do_user_addr_fault(struct pt_regs *regs, > > * we can handle it.. > > */ > > good_area: > > +#define USER_MODE_WRITE (FAULT_FLAG_WRITE | FAULT_FLAG_USER) > > + if (((flags & USER_MODE_WRITE) == USER_MODE_WRITE) && > > + (vma->vm_flags & VM_IBT)) { > > + bad_area_access_error(regs, hw_error_code, address, vma); > > + return; > > + } > > + > > Just make the VMA have VM_WRITE and VM_MAYWRITE clear. No new code > like this should be required. Ok, I will work on that. Thanks, Yu-cheng