Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp2343992imm; Thu, 21 Jun 2018 10:55:21 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ4NbDvsKf89qjF+BzloXeYahmkvy8FbU8DSTPPQqSoSayqHs4aC8KLEAxC1+vI9BeAcv41 X-Received: by 2002:a62:d6d2:: with SMTP id a79-v6mr28681877pfl.87.1529603721714; Thu, 21 Jun 2018 10:55:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529603721; cv=none; d=google.com; s=arc-20160816; b=WAbCRrmLOjd5pY0unkTFyq+3sMno2hrSLr0LdmdjwQPNsgwZpQ3oHKkAjn4BnqcvSk RM5mDHaGIvMuqfYa5uFyIwhgfxt4KVwK08+QpnMESRHdw6poA0zlaNwFt9RXmdqUonOR scCDo5UQx6icEltLEs9DArQxuxCk26W1a1TkEvyntL2q4RCn6rsK3omoV4W9Il1Zv8p2 0aShefB9oWzlmGY59Sh6HlpjSPYAUurfCMzNEnHG8woA2fcdbOpRvAaUDqeDdJ5HYCC1 wbCCYbMa9Pydv8BaDkbOnKQ11i2NIyMntlAF5VXUSYqJ0UK94v8KQvlK0l1oaPvOjb1l AKsA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:arc-authentication-results; bh=50HStILxW46beYBu9MTv1byQnvUb3xFG5UYQIqyzMuI=; b=05TMj6X0Jybpy/500SnUHf3XzNxZ6Rq5LtE8TB1GCzWT1u2AL2ZDguLZAVpn8whs9+ oWrC2foPs5GrOxNO6oKCHLgMXdupCqYs7sEuB5W0ZkTiiCNY1NI5p9yuzXDjvI9clttK UJU8i9QmB0/92kuPg/epiqwdShbx0ZstCRMYQLBOeBPVIlqaSY3gjsTxnlmV/IORkSFv ggypHIkOb4M+cvmY+QKbTZW6NcfGgphMbfyz0oKgbw0+iLpgN1ws17MxiiazA+0f1p47 yY9dYFQe5FiHFHsIQ1bSooWO9wr3YgC8F+fsNsdbyzmTxoP8idbZ9RK9STWh3Q1Xs/56 4K0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@agner.ch header.s=dkim header.b=OZ9N2LG5; 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 k12-v6si4360348pgo.405.2018.06.21.10.55.06; Thu, 21 Jun 2018 10:55:21 -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=@agner.ch header.s=dkim header.b=OZ9N2LG5; 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 S932891AbeFURyN (ORCPT + 99 others); Thu, 21 Jun 2018 13:54:13 -0400 Received: from mail.kmu-office.ch ([178.209.48.109]:36914 "EHLO mail.kmu-office.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753725AbeFURyM (ORCPT ); Thu, 21 Jun 2018 13:54:12 -0400 Received: from webmail.kmu-office.ch (unknown [IPv6:2a02:418:6a02::a3]) by mail.kmu-office.ch (Postfix) with ESMTPSA id 453E75C019E; Thu, 21 Jun 2018 19:54:11 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=agner.ch; s=dkim; t=1529603651; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=50HStILxW46beYBu9MTv1byQnvUb3xFG5UYQIqyzMuI=; b=OZ9N2LG5FhGsPWCpc9VZuIxNTGA26jQOaOmlOAkRTHezfqsvvu5I94EwyEi6xn49NiBMt3 5zmzILTCZ5ILklhDEQ1y7C9YlQHfXf5pWN/ND33VpfxLvAZihzlxQzxOB8EE2lp+hM+3Us B2TfUBOE2UTsn3pzoiP0czkzIEht8iI= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Date: Thu, 21 Jun 2018 19:54:10 +0200 From: Stefan Agner To: Steven Rostedt Cc: LKML , linux-arm-kernel@lists.infradead.org, Russell King - ARM Linux , abelvesa@linux.com, Abhishek Sagar , Ingo Molnar Subject: Re: [PATCH] ARM: ftrace: Only set kernel memory back to read-only after boot In-Reply-To: <20180621125025.25b70bb9@gandalf.local.home> References: <20180621124710.453ee0ae@gandalf.local.home> <20180621125025.25b70bb9@gandalf.local.home> Message-ID: <704c501ac97ff4ca0d469183b293e0b5@agner.ch> X-Sender: stefan@agner.ch User-Agent: Roundcube Webmail/1.3.4 X-Spamd-Result: default: False [-2.55 / 15.00]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; TAGGED_RCPT(0.00)[]; MIME_GOOD(-0.10)[text/plain]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_SEVEN(0.00)[7]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[]; TO_DN_SOME(0.00)[]; RCVD_COUNT_ZERO(0.00)[0]; ASN(0.00)[asn:29691, ipnet:2a02:418::/29, country:CH]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-2.45)[97.51%]; ARC_NA(0.00)[] Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21.06.2018 18:50, Steven Rostedt wrote: > On Thu, 21 Jun 2018 12:47:10 -0400 > Steven Rostedt wrote: > >> From: Steven Rostedt (VMware) >> >> Dynamic ftrace requires modifying the code segments that are usually >> set to read-only. To do this, a per arch function is called both before >> and after the ftrace modifications are performed. The "before" function >> will set kernel code text to read-write to allow for ftrace to make the >> modifications, and the "after" function will set the kernel code text >> back to "read-only" to keep the kernel code text protected. >> >> The issue happens when dynamic ftrace is tested at boot up. The test is >> done before the kernel code text has been set to read-only. But the >> "before" and "after" calls are still performed. The "after" call will >> change the kernel code text to read-only prematurely, and other boot >> code that expects this code to be read-write will fail. >> >> The solution is to add a variable that is set when the kernel code text >> is expected to be converted to read-only, and make the ftrace "before" >> and "after" calls do nothing if that variable is not yet set. This is >> similar to the x86 solution from commit 162396309745 ("ftrace, x86: >> make kernel text writable only for conversions"). >> >> Reported-by: Stefan Agner >> Tested-by: Stefan Agner >> Link: http://lkml.kernel.org/r/20180620212906.24b7b66e@vmware.local.home >> Signed-off-by: Steven Rostedt (VMware) >> --- > > Perhaps I should have Cc'd stable too? > As it is self tests only which are broken probably not super important. But then, the fix is also rather clean and safe IMHO, so why not. -- Stefan