From patchwork Wed Apr 2 22:10:19 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rabin Vincent X-Patchwork-Id: 3930841 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9405A9F357 for ; Wed, 2 Apr 2014 22:11:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CC7F720266 for ; Wed, 2 Apr 2014 22:11:49 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CE6AF2024D for ; Wed, 2 Apr 2014 22:11:48 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WVTNh-0000Wb-Qf; Wed, 02 Apr 2014 22:11:37 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WVTNf-0001EF-D2; Wed, 02 Apr 2014 22:11:35 +0000 Received: from mail-la0-x230.google.com ([2a00:1450:4010:c03::230]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WVTNI-0001Cr-JA for linux-arm-kernel@lists.infradead.org; Wed, 02 Apr 2014 22:11:13 +0000 Received: by mail-la0-f48.google.com with SMTP id gf5so669745lab.7 for ; Wed, 02 Apr 2014 15:10:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id; bh=JhHofUswBMyFWDXPPMtqd3ftWKnRHj8G8uWUeSE8d2s=; b=oEXHtfX5pQUkeuiYC2Ytq3JdqdrtePx5h+g8cH3/d49dsV0ilcR/FOQGnBnhe8ajt0 TuRWsZndc06R0RbFwizCB0VYNzBVyBW4+y8lrmM3iRt9TnMgzW6fZFx+n7g1oCKCTxav gFpOQNKwcBxUW9L6Gz/0lXYX3E/hN0eh6/YpmlVU2ZrxtGChQff+9SZ/rosMxVKs2dph RIBnc3pt4t1bpih2c+cwjz3/ypWE1YfmL0ASry9x7txTromD5e6j6W/RLSWK7c0Y5SuS 5PV1kZ2/Mf66xtosEEenlhooB4gi4kidLPv05TnEUH3RlWSjwLxVhae8E8pPW7FcqQDY VDgQ== X-Received: by 10.152.30.41 with SMTP id p9mr1536578lah.26.1396476644998; Wed, 02 Apr 2014 15:10:44 -0700 (PDT) Received: from localhost.localdomain (217-211-190-200-no39.tbcn.telia.com. [217.211.190.200]) by mx.google.com with ESMTPSA id x4sm2214709lbn.2.2014.04.02.15.10.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Apr 2014 15:10:44 -0700 (PDT) From: Rabin Vincent To: linux-arm-kernel@lists.infradead.org Subject: [PATCH] arm: ftrace: work with CONFIG_DEBUG_SET_MODULE_RONX Date: Thu, 3 Apr 2014 00:10:19 +0200 Message-Id: <1396476619-15386-1-git-send-email-rabin@rab.in> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140402_181112_774573_F89592B0 X-CRM114-Status: GOOD ( 10.80 ) X-Spam-Score: -1.9 (-) Cc: Rabin Vincent , linux-kernel@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Make ftrace work with CONFIG_DEBUG_SET_MODULE_RONX by making module text writable around the place where ftrace does its work, like it is done on x86 in the patch which introduced CONFIG_DEBUG_SET_MODULE_RONX, 84e1c6bb38eb ("x86: Add RO/NX protection for loadable kernel modules"). Signed-off-by: Rabin Vincent Tested-by: Mitchel Humpherys Tested-by: Kees Cook --- arch/arm/kernel/ftrace.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/arch/arm/kernel/ftrace.c b/arch/arm/kernel/ftrace.c index 34e5664..70ce654 100644 --- a/arch/arm/kernel/ftrace.c +++ b/arch/arm/kernel/ftrace.c @@ -14,6 +14,7 @@ #include #include +#include #include #include @@ -63,6 +64,18 @@ static unsigned long adjust_address(struct dyn_ftrace *rec, unsigned long addr) } #endif +int ftrace_arch_code_modify_prepare(void) +{ + set_all_modules_text_rw(); + return 0; +} + +int ftrace_arch_code_modify_post_process(void) +{ + set_all_modules_text_ro(); + return 0; +} + static unsigned long ftrace_call_replace(unsigned long pc, unsigned long addr) { return arm_gen_branch_link(pc, addr);