Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp2484300ybp; Thu, 10 Oct 2019 08:04:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwg8zMGnP1DEMpavaB8dQA1NvkZtNnT7UTJNNv3dafN/2Sy92RDG28C3x2iyjCu1fQqq2WZ X-Received: by 2002:a1f:fec8:: with SMTP id l191mr5848558vki.15.1570719857554; Thu, 10 Oct 2019 08:04:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570719857; cv=none; d=google.com; s=arc-20160816; b=KMtArqK+42k8wLiS0lmLSkwxfUlD12zkU503Dz+1VoTVrlyuiTJqKUyR61sHaRcZd5 3PF01qJy5xSMEInEiBJt9MHVZcykTeqXC7CPRKRj9ZCh6A0/dxEDU36RQiUEydvsFCuh c5l5nWFhx89WBsP4dGvtNtzB8KJu7PYthQWaDe8dv2vCbNkQBxMIshE/bXPQCoY66fSu 0ke/Y9MqhbQhy8NmBDXFQiMxFI8tkr0lVaPzaLPde1hbAre/SAGyW8bwwOHDr7M7HXKC 0AD8KRgn9nIpQJ4TAgUhr1QpZc2V3KYmuzMiWGd7fwUW1lerQi6g5a8GPf0yf80Vpasd acVA== 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=kXBVAy6xafPAi+vioOC7gDY2vBWfFcF3affV2Pbf1ak=; b=OTSvlZFt/E+iV+pYLNfC7czEDM/UikIHILXEWg9zdNMX4V4g0cEwYgflD9uSbJgmpn JI22D7lcjXBTK6Lv9tef+m6128UDzpQS4X888hYJA9e2/tXATDL3J0DF63VyA9ffQ7vm FY044sMlSCK027NeeskjfeF6PrOl0762a3DlTF6uCigXyZWcNuAZrOAl4xsH8g0rbvdO dYWbCJa3Pnf21/NsPA3qJwkkX6vjqaYKFJn8W3u44ppRYvAkNr61RGJqTaNODESvXbcF cZIyRKfSa9ad8Up54THYVHpCvQJQzsN19Fq+c3SLzZVK/PuswA4bFE9ZrquRXujFrtqX 8uGA== 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 oc20si3172976ejb.260.2019.10.10.08.03.43; Thu, 10 Oct 2019 08:04:17 -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 S1726336AbfJJPD2 (ORCPT + 99 others); Thu, 10 Oct 2019 11:03:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:44486 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725862AbfJJPD2 (ORCPT ); Thu, 10 Oct 2019 11:03:28 -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 9522B206A1; Thu, 10 Oct 2019 15:03:27 +0000 (UTC) Date: Thu, 10 Oct 2019 11:03:26 -0400 From: Steven Rostedt To: Peter Zijlstra Cc: LKML , Jessica Yu , Ingo Molnar Subject: Re: [PATCH] ftrace/module: Allow ftrace to make only loaded module text read-write Message-ID: <20191010110326.75131dbf@gandalf.local.home> In-Reply-To: <20191010105515.5eba7f31@gandalf.local.home> References: <20191009223638.60b78727@oasis.local.home> <20191010073121.GN2311@hirez.programming.kicks-ass.net> <20191010093329.GI2359@hirez.programming.kicks-ass.net> <20191010093650.GJ2359@hirez.programming.kicks-ass.net> <20191010122909.GK2359@hirez.programming.kicks-ass.net> <20191010105515.5eba7f31@gandalf.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 Thu, 10 Oct 2019 10:55:15 -0400 Steven Rostedt wrote: > But we have an issue with the state of the module here, as it is still > set as MODULE_STATE_UNFORMED. Let's look at what happens if we have: > > > CPU0 CPU1 > ---- ---- > echo function > current_tracer > modprobe foo > enable foo functions to be traced > (foo function records not disabled) > echo nop > current_tracer > > disable all functions being > traced including foo functions > > arch calls set_all_modules_text_rw() > [skips UNFORMED modules, which foo still is ] > > set foo's text to read-only > foo's state to COMING > > tries to disable foo's functions > foo's text is read-only > > BUG trying to write to ro text!!! > > > Like I said, this is very subtle. It may no longer be a bug on x86 > with your patches, but it will bug on ARM or anything else that still > uses set_all_modules_text_rw() in the ftrace prepare code. I guess I should have commented this, but the big reason for the split between ftrace_module_init() and ftrace_module_enable() is that we add the nops when the module is still UNFORMED, but we only enable it when the module is COMING or beyond, and not UNFORMED. -- Steve