Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp4517334ybp; Mon, 14 Oct 2019 06:02:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsxrQOsAYPEmn6EAo5lI+I/EX0Vn0XlqwlPTZQwbByoBLRagOUDMiokV8O07fiSQn7e2X8 X-Received: by 2002:a1c:f210:: with SMTP id s16mr13707154wmc.24.1571058146547; Mon, 14 Oct 2019 06:02:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571058146; cv=none; d=google.com; s=arc-20160816; b=TbHoxoEQb44mc8xoZwMEht6JvB9f878lYbl45mMtP59lLFNQ7kva4mKfV2GBtmXUs6 SntHgihdyBQ0GKuKj0Aqod1Cdzu9O/EPND0/FoYVmmHx2ZK92QrrGTeg+WtAFGZF7Xsf 87zAJyU70qqpfcJAcLUXcKBnILabTNRJet7iQ9R14MayzmHq/v5bGISKf61+7zPuYVN6 eLBRLmgtcSZNFkg3RU1cP/gjZSo6bP31kS6BO4R9q9lhm8LQleI3YoYwFT5IXP4m7Wwz 88L/Rxt4DTb7vkD3fRwmA80mql6ntdS7RixzQm3quMqT0+3e52RfXlQZ1EvZ0kyPApJE PcRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=1CHpklShh0JrGWTUM9YmCj9GPv6zSMZFivv2whNeEPc=; b=UEpbwJIcVLcz5XcnCuRyBz7be8kDyn053xPnJrcwn1wS4V16PlTgVVmg41AL3XVgOK lFEZ3BhitZXZTArlSURh3nNgBNlFrEhOsvLFlEv5dI+xobby9JJD3cGscg1ZFhtt/yOe H1hFmbsN1k1WcHsUotG7DjQZJD6i9l6TaQDtgcJ0+3bycC5YxRIUk1RSJAlWbN4tCMyb yQMzhtxz4YTKW3nFgrG/gs1AbRe6AfBmk6FePAcw7xBinYH3tszlWXUWHayW7srQmF1E W6Wvv9swazzgWhg0CtMn4fXLcjBxfUAE95fI5gGSzilTtbCoPSfJsI5t9UEKhPlgjDm3 jaHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Ke21MA3m; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k14si12315320ede.421.2019.10.14.06.02.01; Mon, 14 Oct 2019 06:02:26 -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; dkim=pass header.i=@kernel.org header.s=default header.b=Ke21MA3m; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730537AbfJNMbZ (ORCPT + 99 others); Mon, 14 Oct 2019 08:31:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:50198 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730394AbfJNMbZ (ORCPT ); Mon, 14 Oct 2019 08:31:25 -0400 Received: from linux-8ccs (nat.nue.novell.com [195.135.221.2]) (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 D829821744; Mon, 14 Oct 2019 12:31:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571056285; bh=+LqcF8ByKwLJwZRdsiJGDCF/AwZeNuqrwRk1LUOVGiM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Ke21MA3mK/zL6DlY8zp9j7AwJiGAOen5DbtEAOSMjutmaPWJ/nwqZ9eld33r8elJI tlCTWVhSvaILV0qlwjcaxZuAmIHCdnZZaiJrPQN7Z/k6FEr4PteylCKAgEIrLdAaBC 9hogT2lVU7My4BBgTp6nhgk0JDCBn/QTU9JBH9/U= Date: Mon, 14 Oct 2019 14:31:21 +0200 From: Jessica Yu To: Steven Rostedt Cc: LKML , Peter Zijlstra , Ingo Molnar Subject: Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write Message-ID: <20191014123120.GB6525@linux-8ccs> References: <20191009223638.60b78727@oasis.local.home> <20191010085846.2e7cc625@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20191010085846.2e7cc625@gandalf.local.home> X-OS: Linux linux-8ccs 4.12.14-lp150.12.28-default x86_64 User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org +++ Steven Rostedt [10/10/19 08:58 -0400]: >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. Yeah, that'd be good. Aside from the big ftrace_module_init/enable debate, I'm fine with this patch itself (with the change above), feel free to include my Ack in case you want to include it with the rest of the ftrace text_poke stuff. Acked-by: Jessica Yu Thanks, Jessica >> + 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); >> +} >> +