Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp6076356ybp; Tue, 8 Oct 2019 12:39:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqxEh73qacHC6Nvvtoe35ad3tUYkQleDNFEgcKKgogpImg0g5x6HnmlFBwLXl0cav82Cr6B0 X-Received: by 2002:aa7:d692:: with SMTP id d18mr34957110edr.95.1570563593274; Tue, 08 Oct 2019 12:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570563593; cv=none; d=google.com; s=arc-20160816; b=vSeEbt3ULawgvUov01IT81jX6qV06cjojk0b7j/907P08Eb+jqSYOP1KAayUkUcbNE mYv30AQT8d1tw9jPTg6hAqNzw+Fl99MLM5DUv1hZKj7FJ2Ox87e21leWX8tP1muub5S2 1O2/QhD/CWo/RAKHzGftxQgeRKICuufv+yDoxLnWHSAXR3sppAxDyHzFFxqR5ZXrCudI 5tQ2aL9J8oV7K92l5YGRY7+brsn0elLwDG05lJvqLF0pvR6PyF5+o8VxslQIsea0ULCf qqGlPgNjIhTZTxAXadfHArdV/+YD3HNYwjTZ7a6nqW+rKgDVHwitov+uAarAHXJXnBcJ p2Ag== 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=/x3mjIbpDFHElk+HecE6hb/YvkXGUt6H6EPBk2cEcz0=; b=ERNLsNiUeLmxf9vBMKCqOKWRAjBnTfzz8Nkpa81VeyQRr2yltnmM0rmOyhAgaYbmW5 8iB68SWBX8A3oT/o4NjplfcrYXaP6WdU83PXF99jRk6+SojmUiYQV4CgjiWlwaAU4jhC 06JuZHPG/mwxnwzN/LD42LCw9lO3E6X0g9CcaYHDYZkAHvp3EJMENPEk974YxnaIVqIx Y2khZh4olkbOqxy2430v/ohwJYn14Gy/DZJIZzQkzIlWV7wDBeMJahrR2aWuW8CNoItJ fckLULNoGEyZ4cTv2nM/r4JWXUFH/XCDPk19X3Ja8hciQPgEX4+W7j7llUdv325T/f4C TO7w== 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 u11si9230870ejr.234.2019.10.08.12.39.27; Tue, 08 Oct 2019 12:39:53 -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 S1730465AbfJHTfh (ORCPT + 99 others); Tue, 8 Oct 2019 15:35:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:41000 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729602AbfJHTfh (ORCPT ); Tue, 8 Oct 2019 15:35:37 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 130508553D; Tue, 8 Oct 2019 19:35:37 +0000 (UTC) Received: from redhat.com (dhcp-17-119.bos.redhat.com [10.18.17.119]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 221D810013A1; Tue, 8 Oct 2019 19:35:36 +0000 (UTC) Date: Tue, 8 Oct 2019 15:35:34 -0400 From: Joe Lawrence To: Miroslav Benes Cc: rostedt@goodmis.org, mingo@redhat.com, jpoimboe@redhat.com, jikos@kernel.org, pmladek@suse.com, linux-kernel@vger.kernel.org, live-patching@vger.kernel.org Subject: Re: [PATCH 0/3] ftrace: Introduce PERMANENT ftrace_ops flag Message-ID: <20191008193534.GA16675@redhat.com> References: <20191007081714.20259-1-mbenes@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191007081714.20259-1-mbenes@suse.cz> User-Agent: Mutt/1.12.1 (2019-06-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 08 Oct 2019 19:35:37 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 07, 2019 at 10:17:11AM +0200, Miroslav Benes wrote: > Livepatch uses ftrace for redirection to new patched functions. It is > thus directly affected by ftrace sysctl knobs such as ftrace_enabled. > Setting ftrace_enabled to 0 also disables all live patched functions. It > is not a problem per se, because only administrator can set sysctl > values, but it still may be surprising. > > Introduce PERMANENT ftrace_ops flag to amend this. If the > FTRACE_OPS_FL_PERMANENT is set, the tracing of the function is not > disabled. Such ftrace_ops can still be unregistered in a standard way. > > The patch set passes ftrace and livepatch kselftests. > > Miroslav Benes (3): > ftrace: Make test_rec_ops_needs_regs() generic > ftrace: Introduce PERMANENT ftrace_ops flag > livepatch: Use FTRACE_OPS_FL_PERMANENT > > Documentation/trace/ftrace-uses.rst | 6 ++++ > Documentation/trace/ftrace.rst | 2 ++ > include/linux/ftrace.h | 8 +++-- > kernel/livepatch/patch.c | 3 +- > kernel/trace/ftrace.c | 47 ++++++++++++++++++++++++----- > 5 files changed, 55 insertions(+), 11 deletions(-) > > -- > 2.23.0 > Hi Miroslav, I wonder if the opposite would be more intuitive: when ftrace_enabled is not set, don't allow livepatches to register ftrace filters and likewise, don't allow ftrace_enabled to be unset if any livepatches are already registered. I guess you could make an argument either way, but just offering another option. Perhaps livepatches should follow similar behavior of other ftrace clients (like perf probes?) As for the approach in this patchset, is it consistent that livepatches loaded after setting ftrace_enabled to 0 will successfully load, but not execute their new code... but then when ftrace_enabled is toggled, the new livepatch code remains on? For example: 1 - Turn ftrace_enabled off and load the /proc/cmdline livepatch test case, note that it reports a success patching transition, but doesn't run new its code: % dmesg -C % sysctl kernel.ftrace_enabled=0 kernel.ftrace_enabled = 0 % insmod lib/livepatch/test_klp_livepatch.ko % echo $? 0 % dmesg [ 450.579980] livepatch: enabling patch 'test_klp_livepatch' [ 450.581243] livepatch: 'test_klp_livepatch': starting patching transition [ 451.942971] livepatch: 'test_klp_livepatch': patching complete % cat /proc/cmdline BOOT_IMAGE=(hd0,msdos1)/boot/vmlinuz-5.4.0-rc2+ root=UUID=c42bb089-b5c1-4e17-82bd-132f55bee54c ro console=ttyS0 console=ttyS0,115200n8 no_timer_check net.ifnames=0 crashkernel=auto 2 - Turn ftrace_enabled on and see that the livepatch now works: % sysctl kernel.ftrace_enabled=1 kernel.ftrace_enabled = 1 % cat /proc/cmdline test_klp_livepatch: this has been live patched 3 - Turn ftrace_enabled off and see that it's still enabled: % sysctl kernel.ftrace_enabled=0 kernel.ftrace_enabled = 0 % cat /proc/cmdline test_klp_livepatch: this has been live patched Steps 2 and 3 match the behavior described by the patchset, but I was particularly wondering what you thought about step 1. IMHO, I would expect step 1 to fully enable the livepatch, or at the very least, not report a patch transition (though that may confuse userspace tools waiting for that report). Thanks, -- Joe