Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2334547ybp; Thu, 10 Oct 2019 06:03:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqycVV9vab5l+CLSyejzADLdCOAf/KQrzhMyLN1X1p/n98DRXE7eM7ZhkjUTLZ3cA059+Pva X-Received: by 2002:a17:906:a459:: with SMTP id cb25mr7820727ejb.63.1570712587301; Thu, 10 Oct 2019 06:03:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570712587; cv=none; d=google.com; s=arc-20160816; b=NT4lmuLAPoqieFj9SSylaZ9p37XNmG+k5zEPf5iL8hHagWIBhwnW8PVAejLnFeeFAO 34yhs+Wv25FRin/V0VkG11THYrRn0l2EYvG446fT3zTedMmjvt/Q3L8v8yQH2rDDQIRM +MAkcfPphEAwlw4olzlqTWbk6E+2e8DTzoGNHIzG5IotswcCrWoNkaT9sWjtsgsvHcDQ mFbPYeIJLOhrvtg1RQcvC2vJV1/P0VejnsH9/2seOSrLkAX2j6iZ/x6Q4Vy0yxUgT6nr 2+QZgVvSxNtVYnP5Z7DUANi2xi7FKTbM3352hXSBY3kln8ISBBwPtW7P95D+V/YR9Aj+ I5NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=Woku6LGeAjgkAIdr12T3kbM/suG3wm+AN86ZOI+RSPE=; b=m2WvXrHlTFE1CyHCDciEKlkp0IVJdDeyAtvTWYlF9slIL/2xaNfWsSZS+duvQNOy87 2IU59+CL9YbGm5Z65vryPMK+xTghOJ2LI8bCTPttcPXwdaXrGlPp04dmrR4EF+yayKvJ 480YBmYkCOfG6cZzwjbPHdeFsJS9XH603RVFWJP9/d5rpGQEbLa1LdMadxMbLiqCB61j ukz2Jz+g46hAK0/NFE/rx+vLSEg75tWwYWRT4+eP483RPrQW4vYGDKQrhcgpdxlgYvOw uF/Jq2rFrpgMbP2UjD9d8iVqB466QDJCzHxUkZVaMjl4zS9/jUqV/LTed39IBMnIcGQX +MDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h53si3811016edh.147.2019.10.10.06.02.31; Thu, 10 Oct 2019 06:03:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387894AbfJJM6t (ORCPT + 99 others); Thu, 10 Oct 2019 08:58:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:52434 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387764AbfJJM6t (ORCPT ); Thu, 10 Oct 2019 08:58:49 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5F23A2067B; Thu, 10 Oct 2019 12:58:48 +0000 (UTC) Date: Thu, 10 Oct 2019 08:58:46 -0400 From: Steven Rostedt To: LKML , Jessica Yu Cc: Peter Zijlstra , Ingo Molnar Subject: Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write Message-ID: <20191010085846.2e7cc625@gandalf.local.home> In-Reply-To: <20191009223638.60b78727@oasis.local.home> References: <20191009223638.60b78727@oasis.local.home> X-Mailer: Claws Mail 3.17.3 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 9 Oct 2019 22:36:38 -0400 Steven Rostedt wrote: > --- a/kernel/module.c > +++ b/kernel/module.c > @@ -2029,6 +2029,37 @@ static void module_enable_nx(const struct module *mod) > frob_writable_data(&mod->init_layout, set_memory_nx); > } > Also, if you are worried about these being used anywhere else, we can add: > +void set_module_text_rw(const struct module *mod) > +{ > + if (!rodata_enabled) > + return; > + > + mutex_lock(&module_mutex); > + if (mod->state == MODULE_STATE_UNFORMED) if (mod->state == MODULE_STATE_UNFORMED || mod->state == MODULE_STATE_LIVE) As this will keep it from being used on modules that are executing. -- Steve > + goto out; > + > + frob_text(&mod->core_layout, set_memory_rw); > + frob_text(&mod->init_layout, set_memory_rw); > +out: > + mutex_unlock(&module_mutex); > +} > + > +void set_module_text_ro(const struct module *mod) > +{ > + if (!rodata_enabled) > + return; > + > + mutex_lock(&module_mutex); > + if (mod->state == MODULE_STATE_UNFORMED || > + mod->state == MODULE_STATE_GOING) > + goto out; > + > + frob_text(&mod->core_layout, set_memory_ro); > + frob_text(&mod->init_layout, set_memory_ro); > +out: > + mutex_unlock(&module_mutex); > +} > +