Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6308891ybp; Tue, 15 Oct 2019 12:54:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqwDWI5+QIBhH2cvy7MOk0QMq2nHoSjjJhpIOj3sTEjtzga6g1rtxUv/ZGaHy44Sfj3ofKXS X-Received: by 2002:a17:906:19cf:: with SMTP id h15mr37145301ejd.184.1571169267915; Tue, 15 Oct 2019 12:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571169267; cv=none; d=google.com; s=arc-20160816; b=fgmIccD4wvxqwmorTnB/AO4kwCPi/RMgXIkQ3DD8lJY9Arvam+LdtScILspyN/yMuO eTVUPmAO2Wl6t17owqTjGeJuU1nKrIHHs+AhRoyt5CvAaRT/Q+8WwIIFSgCyXn8v9e2t 6Ni+gSRuQ4x5kJwJcyrDRkGYGKp81ciN8zxQD3tH7x/40lkewl7jC+R8fRHbvPWa201b Vav5NFhZI5leGp4KrP3FZSXlq7l0oa5Ut6uu2Nn+jJ7Mcfhtb2cpzbFEAC5i9SV6gFwr j79ousO96eMl1bxsNL1mIoEF/imgSHtDJug2swQP3kJKB2Qhimgfwlq878hXr+bGau2I 5vsA== 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=gnBHGUEsp1+Xl2dVhQ1oX2tEjJXM39WpcQAUSxy0S5s=; b=Ad45gq0AY3/S1UYlXOSexaAxew9chxumkyFNdY029TlLA0CMcURTfC9B4fA3z1w9xV KtOXM6zY28ZA06NdfF82/GSqe4v+mVMHSw0EtrKyiIk2qnQf4wln6Dxii9t01nAmdK+L mxRTa1NnvTqeloSm1KM1qwcwbmolv06m81eUV0S2rnzFlOV7pi7qzNt5/3M8ZJ1rgssX omp/X0bh9wPdfGo180jW4R/yd6VNbItmVuq7eohTsfVVkhsGPk8AYYVXDyRSKRz3vNqv kjH8PuZK8UgrTTdcf5L942YKCQgSrz+c7kEgGPyKfHfsaIom1mrLi7QyjxbOllZURLSR iVLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=keT8Xy6w; 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 ci22si14393756ejb.162.2019.10.15.12.54.04; Tue, 15 Oct 2019 12:54:27 -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=keT8Xy6w; 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 S1727471AbfJOQJV (ORCPT + 99 others); Tue, 15 Oct 2019 12:09:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:43090 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726333AbfJOQJU (ORCPT ); Tue, 15 Oct 2019 12:09:20 -0400 Received: from linux-8ccs (ip5f5adbbb.dynamic.kabel-deutschland.de [95.90.219.187]) (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 3C99720640; Tue, 15 Oct 2019 16:09:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571155759; bh=lymXH+CPJkzOEgsYwzTlX/oqBJpN6j+gCshs086u74w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=keT8Xy6ws5k0dTABCEb/07xm4QdknpNXD7BlPsuKOrr5mu1hvDUp+kNr0xR/HbDAV QXm9pJmMjmHPQOVe/NQe13Zw2/KClK+0q8wj/hWA7sTgTTbs+lQg+esvwuvWpj7UUG WAjTjWb+5Bi/Q9WAv/m2pFZPL94VohATMMdvYaqo= Date: Tue, 15 Oct 2019 18:09:13 +0200 From: Jessica Yu To: Steven Rostedt Cc: Peter Zijlstra , x86@kernel.org, linux-kernel@vger.kernel.org, mhiramat@kernel.org, bristot@redhat.com, jbaron@akamai.com, torvalds@linux-foundation.org, tglx@linutronix.de, mingo@kernel.org, namit@vmware.com, hpa@zytor.com, luto@kernel.org, ard.biesheuvel@linaro.org, jpoimboe@redhat.com Subject: Re: [PATCH v3 5/6] x86/ftrace: Use text_poke() Message-ID: <20191015160912.GB21110@linux-8ccs> References: <20191007081945.10951536.8@infradead.org> <20191008104335.6fcd78c9@gandalf.local.home> <20191009224135.2dcf7767@oasis.local.home> <20191010092054.GR2311@hirez.programming.kicks-ass.net> <20191010091956.48fbcf42@gandalf.local.home> <20191010140513.GT2311@hirez.programming.kicks-ass.net> <20191010115449.22044b53@gandalf.local.home> <20191010172819.GS2328@hirez.programming.kicks-ass.net> <20191011125903.GN2359@hirez.programming.kicks-ass.net> <20191015092802.5c9aea5e@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20191015092802.5c9aea5e@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 [15/10/19 09:28 -0400]: >On Fri, 11 Oct 2019 14:59:03 +0200 >Peter Zijlstra wrote: > >> On Thu, Oct 10, 2019 at 07:28:19PM +0200, Peter Zijlstra wrote: >> >> > Really the best solution is to move all the poking into >> > ftrace_module_init(), before we mark it RO+X. That's what I'm going to >> > do for jump_label and static_call as well, I just need to add that extra >> > notifier callback. >> >> OK, so I started writing that patch... or rather, I wrote the patch and >> started on the Changelog when I ran into trouble describing why we need >> it. >> >> That is, I'm struggling to explain why we cannot flip >> prepare_coming_module() and complete_formation(). >> >> Yes, it breaks ftrace, but I'm thinking that is all it breaks. So let me >> see if we can cure that. > >You are mainly worried about making text that is executable into >read-write again. What if we kept my one patch that just changed the >module in ftrace_module_enable() from read-only to read-write, but >before we ever set it executable. > >Jessica, would this patch break anything? > >It moves the setting of the module execution to after calling both >ftrace_module_enable() and klp_module_coming(). > >This would make it possible to do the module code and still keep with >the no executable code becoming writable. > >-- Steve > >diff --git a/kernel/module.c b/kernel/module.c >index ff2d7359a418..6e2fd40a6ed9 100644 >--- a/kernel/module.c >+++ b/kernel/module.c >@@ -3728,7 +3728,6 @@ static int complete_formation(struct module *mod, struct load_info *info) > > module_enable_ro(mod, false); > module_enable_nx(mod); >- module_enable_x(mod); > > /* Mark state as coming so strong_try_module_get() ignores us, > * but kallsyms etc. can see us. */ >@@ -3751,6 +3750,11 @@ static int prepare_coming_module(struct module *mod) > if (err) > return err; > >+ /* Make module executable after ftrace is enabled */ >+ mutex_lock(&module_mutex); >+ module_enable_x(mod); >+ mutex_unlock(&module_mutex); >+ > blocking_notifier_call_chain(&module_notify_list, > MODULE_STATE_COMING, mod); > return 0; As long as we enable x before parse_args(), which this patch does, then I don't think this change would break anything.