From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1165214AbdEYGZs (ORCPT ); Thu, 25 May 2017 02:25:48 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:35551 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1165130AbdEYGZr (ORCPT ); Thu, 25 May 2017 02:25:47 -0400 Date: Thu, 25 May 2017 08:25:32 +0200 (CEST) From: Thomas Gleixner To: Steven Rostedt cc: Kees Cook , LKML , x86@kernel.org, Masami Hiramatsu , "Luis R. Rodriguez" , Peter Zijlstra Subject: Re: [PATCH] x86/ftrace: Make sure that ftrace trampolines are not RWX In-Reply-To: <20170524182547.5c085dc7@vmware.local.home> Message-ID: References: <20170524134728.61a896c9@vmware.local.home> <20170524182547.5c085dc7@vmware.local.home> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 24 May 2017, Steven Rostedt wrote: > The trampolines uses the module allocation, and it appears, that needs > to become rw before freeing again. Indeed. I realized that when enabling more debug options, which led to a reliable triple fault. How intuitive. > I applied this patch, and it appears to fix the bug for me. It fixes the bug, but ... > -static inline void tramp_free(void *tramp) > +static inline void tramp_free(void *tramp, int size) > { > + int npages; > + > + npages = PAGE_ALIGN(size) >> PAGE_SHIFT; For correctness sake this wants set_memory_nx(...); as well. > + set_memory_rw((unsigned long)tramp, npages); > module_memfree(tramp); > } I'll clean that up and post a V2. Thanks, tglx