Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp5937927ybp; Tue, 15 Oct 2019 07:16:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqyYwmQT9PJwMIMiXZE5qcYbMb1D6WJ5M8wRjPgcGkdHMZrq0Q6iojG+otYXny0jcDBE8070 X-Received: by 2002:a05:6402:3051:: with SMTP id bu17mr33505704edb.4.1571149015674; Tue, 15 Oct 2019 07:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571149015; cv=none; d=google.com; s=arc-20160816; b=NWPQ3d1CKVxbCAbjXqpQYXC/jUqke26vjutkANKh0wtUiLg9Jf/Eck31C2ydyRzAn9 5mIsy4xcynz8g4rrs/Vp/Wr2wxnQ9ykdK4IM1qnwT65OPOao+HkdUf1uQt3lEeeLK82w o1jp6sLSbc4hdCgn39mYc8Oq+nKO00RFXHdhIM69CJNDQveJnQdM5q7s8SDU0+sgEFA9 TtMf6nGYnBVMQPWLO2y7oyxSZiBqKdfduyOulVnLvXb+QBm0KGWQRGKpM6cs4NLMh6a+ 73rlncXODc2qx0QnYg9FOhLodd4mjMEZqbvR8APAdpycRmvoMOqEP4t+J5wdEuQ7Acmx j2Yg== 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=wRLQvv2DtH1xE3exNnLDUfY/t2ChDkaQOTQLNQzo8bA=; b=YSgVcP9v/UihRka9goDbYO3mSR9hHjrJdkTofIybVZUFYVg4ehUCrwEfuKnfJ82lwW wTvGpz9sOpLXd2R9L3IJGK2+ZtqRIuATW9e1UhiyxfO0ZIGIbcs71b5SIJMOvgnt4x08 YpdXS1piTiCNRp13Y2jkq+TGFUGfGeACn1MB/d+p78QR3SvqNY4U2mAX099vrSSfYx2c Qz6Y1wMtCbmR/0CPK6597sL7Lzvb+R56Glnco+dqV8VG91WzxnxuwWDjb7scbmaVEKMy pYfLHS1EuRu9bI6OjGHX6PFN3Xkkp5161ZJuWvyLO6I7V/cEBZht6EU06+clMpiS2aFK HZLg== 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 y71si14218030ede.135.2019.10.15.07.16.31; Tue, 15 Oct 2019 07:16:55 -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 S1732589AbfJOONr (ORCPT + 99 others); Tue, 15 Oct 2019 10:13:47 -0400 Received: from mx2.suse.de ([195.135.220.15]:44588 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732500AbfJOONq (ORCPT ); Tue, 15 Oct 2019 10:13:46 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 30A43B450; Tue, 15 Oct 2019 14:13:44 +0000 (UTC) Date: Tue, 15 Oct 2019 16:13:41 +0200 (CEST) From: Miroslav Benes To: Peter Zijlstra cc: Jessica Yu , Steven Rostedt , 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, live-patching@vger.kernel.org Subject: Re: [PATCH v3 5/6] x86/ftrace: Use text_poke() In-Reply-To: <20191015135634.GK2328@hirez.programming.kicks-ass.net> Message-ID: 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> <20191015130739.GA23565@linux-8ccs> <20191015135634.GK2328@hirez.programming.kicks-ass.net> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ live-patching ML CCed ] On Tue, 15 Oct 2019, Peter Zijlstra wrote: > On Tue, Oct 15, 2019 at 03:07:40PM +0200, Jessica Yu wrote: > > > > The fact that it is executable; also the fact that you do it right after > > > we mark it ro. Flipping the memory protections back and forth is just > > > really poor everything. > > > > > > Once this ftrace thing is sorted, we'll change x86 to _refuse_ to make > > > executable (kernel) memory writable. > > > > Not sure if relevant, but just thought I'd clarify: IIRC, > > klp_module_coming() is not poking the coming module, but it calls > > module_enable_ro() on itself (the livepatch module) so it can apply > > relocations and such on the new code, which lives inside the livepatch > > module, and it needs to possibly do this numerous times over the > > lifetime of the patch module for any coming module it is responsible > > for patching (i.e., call module_enable_ro() on the patch module, not > > necessarily the coming module). So I am not be sure why > > klp_module_coming() should be moved before complete_formation(). I > > hope I'm remembering the details correctly, livepatch folks feel free > > to chime in if I'm incorrect here. > > You mean it does module_disable_ro() ? That would be broken and it needs > to be fixed. Can some livepatch person explain what it does and why? Yes, it does. klp_module_coming() calls module_disable_ro() on all patching modules which patch the coming module in order to call apply_relocate_add(). New (patching) code for a module can be relocated only when the relevant module is loaded. Miroslav