Date: Wed, 6 Feb 2019 12:41:08 -0500 From: Steven Rostedt Subject: Re: [PATCH 08/17] x86/ftrace: set trampoline pages as executable Message-ID: <20190206124108.07eef568@gandalf.local.home> In-Reply-To: <5DFA1E3C-A335-4C4B-A86F-904A6CF6D871@gmail.com> References: <20190117003259.23141-1-rick.p.edgecombe@intel.com> <20190117003259.23141-9-rick.p.edgecombe@intel.com> <20190206112213.2ec9dd5c@gandalf.local.home> <5DFA1E3C-A335-4C4B-A86F-904A6CF6D871@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: Nadav Amit Cc: Rick Edgecombe , Andy Lutomirski , Ingo Molnar , LKML , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Borislav Petkov , Dave Hansen , Peter Zijlstra , Damian Tometzki , linux-integrity , LSM List , Andrew Morton , Kernel Hardening , Linux-MM , Will Deacon , Ard Biesheuvel , Kristen Carlson Accardi , deneen.t.dock@intel.com List-ID: On Wed, 6 Feb 2019 09:33:35 -0800 Nadav Amit wrote: > >> /* Copy ftrace_caller onto the trampoline memory */ > >> ret = probe_kernel_read(trampoline, (void *)start_offset, size); > >> @@ -818,6 +820,13 @@ create_trampoline(struct ftrace_ops *ops, unsigned int *tramp_size) > >> /* ALLOC_TRAMP flags lets us know we created it */ > >> ops->flags |= FTRACE_OPS_FL_ALLOC_TRAMP; > >> > >> + /* > >> + * Module allocation needs to be completed by making the page > >> + * executable. The page is still writable, which is a security hazard, > >> + * but anyhow ftrace breaks W^X completely. > >> + */ > > > > Perhaps we should set the page to non writable after the page is > > updated? And set it to writable only when we need to update it. > > You remember that I sent you a patch that changed all these writes into > text_poke() and you said that I should defer it until this series is merged? > And I notice that it is set to RO after this call anyway. -- Steve