Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp902053ybd; Wed, 26 Jun 2019 07:53:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqz+Gtnpv/AUJVObyVP6WPaSNDkt3mKYJ3mop9tDfgRViYPsRY3Obl2G/hmjOGEnLbMkkB5R X-Received: by 2002:a63:f146:: with SMTP id o6mr3256264pgk.179.1561560792024; Wed, 26 Jun 2019 07:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561560792; cv=none; d=google.com; s=arc-20160816; b=Il3CxednIuiHIeABvw4F4iAwmS3LN5qB6R8mQ4GRIYiqkTlDpawfBCXeeMgfCtD5+L akIY+DIqRch1chluTt4LZFigGHd94HBuQtSE+slnEdLwS/WI7XEY0zMml7kRycZJTq/b ErMIWs2CecoQ1IJpKSxcBny2u379QdO1fXhc3gzKSHu1rJJ8X3uRgJo3ikBD3JB7IvU8 slFFSa2BgQZHQQ5mF1vDOMSSjZ8oC6MCo9vtCJ0K/3mdlM4mNdUTiycqeqol8VQ1zVJN V4Lc1SxshcIXs8I+npN8AQlh95BRggu1rLa7AWZcmTHU0i38RDgDLoMDVYEJN0oHHGPb OMPA== 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; bh=77FGPkr1h7fgLWA20IPrEcI6VZbUWwwzhVnnTpYSm8E=; b=VObfmL1EFaFyZ6kpon+Pjdbkvx3uWrL+es6ZU9aPWKMtkjRXJXbcAQHis2FKjDUFQZ 82oveHOtDd9pdv1+QYkp8qhGjN6rHt1ZpS7jZpnWSxeIJFzgnPt/ofMadGBnHKfuq7Jf bjQEQ1LloBL7KW/HfzBIS3668bp8h2xNvfoMwv4n+qXSh94lqiIC33/+WKFc8KaOFOrd Vw/p9be5WjBYbvhEsj/SUTkSD6vlKc0SBv+fZ/8AXfMd6Ftyst82UK9F0IYrVLDPnRvg SU9GP9HLa3sXU0RHG4U3EJe/RTNy+gJ4na0Jnz5CG1j4hVj6bqyPXKidL1/3+XZMiSPe ioFA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o24si3605215pll.280.2019.06.26.07.52.56; Wed, 26 Jun 2019 07:53:12 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728160AbfFZOwj (ORCPT + 99 others); Wed, 26 Jun 2019 10:52:39 -0400 Received: from mx1.redhat.com ([209.132.183.28]:32822 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726484AbfFZOwi (ORCPT ); Wed, 26 Jun 2019 10:52:38 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A728681DEC; Wed, 26 Jun 2019 14:52:24 +0000 (UTC) Received: from treble (ovpn-126-66.rdu2.redhat.com [10.10.126.66]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C1A2560BE5; Wed, 26 Jun 2019 14:52:09 +0000 (UTC) Date: Wed, 26 Jun 2019 09:52:06 -0500 From: Josh Poimboeuf To: Thomas Gleixner Cc: Petr Mladek , Miroslav Benes , Steven Rostedt , 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 Message-ID: <20190626145206.vqp4nivxva4oshvw@treble> References: <20190614170408.1b1162dc@gandalf.local.home> <20190626133721.ea2iuqqu4to2jpbv@pathway.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 26 Jun 2019 14:52:38 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 26, 2019 at 04:44:45PM +0200, Thomas Gleixner wrote: > 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. Looks good to me as well, Petr can you post a proper patch? -- Josh