Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp895046ybd; Wed, 26 Jun 2019 07:46:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+Pgo/NSwt2yh2e5kAhYT7Z+fep2JX5g1K6GdOLVVO3mFdLzE0WgPIj8GQo1+p68pOpDd1 X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr6046477plo.88.1561560389621; Wed, 26 Jun 2019 07:46:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561560389; cv=none; d=google.com; s=arc-20160816; b=qHMYWeh4NhA4k4Cnq2H1JMJ6gtxCbH+9aYDWcvkz2kpgwYdVr4A13fPXBa2wkXwIxO KZ8UZBzV7T4PdS7nJpj0mSlNpX/XikPu/phwnUZQbO5pL/ZQZPP+OFyezmCFGsv7xtuy 1TNoS5vTP1EtwTq9IPYauGdKuPExXMKC5A0SEbMuEnnMI/j0PqqhFAbjJmvo42TVHz5m LBGRgaJvygNTnFqSEZGO+BZXzn/L3x2DQxj3sIQct3sLx7n+zeVybT7bArYmlAuc/QYI yGYxAkC535mWFog6+bijZzUr9R7L+yN55HvU92yu9s/fIvWA69sHvsXAA+WnsP6B4joA IouA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=Z3VyMYhK4e3VJJt5FMxniUbF19soow9lWdKM4gWNg5c=; b=Cpp299WjXr6txddFxcfVoFNFdRfGiF3zLi5KixI97NiYXDKVe1kknIsZsX8ZBIu64R kognxBkBvYdl872NbCX7inDRVWMVWSShKV4Mgnsc+Pkd1N9gCqz5m/QV2LMquOErYUgE 7V/As8aRybssJOMfdUuSVLj5ykTcth1eodkGqhBlnkPndOlmkLxywJ3gNYXavo5ECxOm e+3YoFoLnKtE90Aoc2343Sg854jP9kjAiSnCX0v3I7kVtoJD/D0A8k+qWCZB36o4goKo 36ONpykQFbu/FCeOrT/ns66Hk+ICcO8iaN30lj5U59CScLEsNv8lB+AdgMxWVAAAJ2ce 8YzQ== 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 f16si2343637pjg.50.2019.06.26.07.46.11; Wed, 26 Jun 2019 07:46:29 -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 S1728190AbfFZOp1 (ORCPT + 99 others); Wed, 26 Jun 2019 10:45:27 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:48888 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728181AbfFZOp1 (ORCPT ); Wed, 26 Jun 2019 10:45:27 -0400 Received: from p5b06daab.dip0.t-ipconnect.de ([91.6.218.171] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1hg9AE-00046N-A6; Wed, 26 Jun 2019 16:44:46 +0200 Date: Wed, 26 Jun 2019 16:44:45 +0200 (CEST) From: Thomas Gleixner To: Petr Mladek cc: Miroslav Benes , Steven Rostedt , Josh Poimboeuf , Jessica Yu , Jiri Kosina , Joe Lawrence , linux-kernel@vger.kernel.org, live-patching@vger.kernel.org, Johannes Erdfelt , Ingo Molnar , mhiramat@kernel.org, torvalds@linux-foundation.org Subject: Re: [PATCH 1/3] module: Fix livepatch/ftrace module text permissions race In-Reply-To: <20190626133721.ea2iuqqu4to2jpbv@pathway.suse.cz> Message-ID: References: <20190614170408.1b1162dc@gandalf.local.home> <20190626133721.ea2iuqqu4to2jpbv@pathway.suse.cz> User-Agent: Alpine 2.21 (DEB 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 26 Jun 2019, Petr Mladek wrote: > On Wed 2019-06-26 10:22:45, Miroslav Benes wrote: > It is similar problem that has been solved by 2d1e38f56622b9bb5af8 > ("kprobes: Cure hotplug lock ordering issues"). This commit solved > it by always taking cpu_hotplug_lock.rw_sem before text_mutex inside. > > If we follow the lock ordering then ftrace has to take text_mutex > only when stop_machine() is not called or from code called via > stop_machine() parameter. > > This is not easy with the current design. For example, arm calls > set_all_modules_text_rw() already in ftrace_arch_code_modify_prepare(), > see arch/arm/kernel/ftrace.c. And it is called: > > + outside stop_machine() from ftrace_run_update_code() > + without stop_machine() from ftrace_module_enable() > > A conservative solution for 5.2 release would be to move text_mutex > locking from the generic kernel/trace/ftrace.c into > arch/x86/kernel/ftrace.c: > > ftrace_arch_code_modify_prepare() > ftrace_arch_code_modify_post_process() > > It should be enough to fix the original problem because > x86 is the only architecture that calls set_all_modules_text_rw() > in ftrace path and supports livepatching at the same time. Looks correct, but I've paged out all the gory details vs. lock ordering in that area. Thanks, tglx