Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp640680ybh; Tue, 21 Jul 2020 04:28:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVZp1M1t2wGC6EBd/ddyH4YF8MWXyq59G+xkTX6Wq4zeSY4WGeUnxlq3qJLA4pup9KIL7Q X-Received: by 2002:a50:f0c6:: with SMTP id a6mr24726695edm.374.1595330899167; Tue, 21 Jul 2020 04:28:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595330899; cv=none; d=google.com; s=arc-20160816; b=zKNzJHyfVXWV7p+MnHaHVFRU0ja5+kBjCmKQyw7NcCBdTPGhJ0Suk7iRs6loGqoY0Z u/Q9obfDAWim0jVIWmJ4grzS29YQVaV5S04elIFgDCRpyVf0+Hc5/FUt5CWkegjmJmX9 mtMTc52zp1AzA06++5Pz65GZpfrROFttXTSkYxXKNbPgPtooYadei4U/rjiMPpLYFvbG LmLzODl1N09HJ9A/Rp8f5t1x9ntwAL5icX1G6fni9FSSCI2vyRffPlDI7VO5OGkWh76X UD6hJwgCiqPU3MY6BXSXF4YEZBcFpI5Kh6+NxUpgRxixSEORyzoV2tK+RHfg4ooKKZ1J 0iiw== 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=r/WBcNPr2PU78gsvXCJJv2lEcSX4U+ght+YKh3XC1V0=; b=d1AbTzNfSsfJMwRaDMU7nPgZf5w6K2o7aT8TFQHrFBjNvboQ/HuaAn0h37yZtjpSyG NX/9WpovBk8APE9lLHnvIG62iE2rYavJI3Y63F0tA0TF9uCnzCkZc8mCgbdCrZDu7k0E FHWV/3DyvOehQb4sInuMkMLhsAMSOFwr5qUdqVaIk+uGi4E1hlPOaFJxwv51fCgV0oJb IknI+jGhWLenyFNe6JVRgT6b4f7IIDPp27Qatwp4fElolgtmZl+IjhH1RzN9A7k3CX4f sWth2Kv5vlY0fmdV++oTSBwoXxz5AFkC2esEYb9TXW4SZx55EGKfYjTluySPfnBRkeSn Dgjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k18si12482345ejk.113.2020.07.21.04.27.55; Tue, 21 Jul 2020 04:28:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729476AbgGUL1l (ORCPT + 99 others); Tue, 21 Jul 2020 07:27:41 -0400 Received: from mx2.suse.de ([195.135.220.15]:34304 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726415AbgGUL1l (ORCPT ); Tue, 21 Jul 2020 07:27:41 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id ABB26AB7D; Tue, 21 Jul 2020 11:27:46 +0000 (UTC) Date: Tue, 21 Jul 2020 13:27:39 +0200 (CEST) From: Miroslav Benes To: Joe Lawrence cc: Josh Poimboeuf , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Peter Zijlstra , Randy Dunlap , nstange@suse.de Subject: Re: [PATCH] Revert "kbuild: use -flive-patching when CONFIG_LIVEPATCH is enabled" In-Reply-To: Message-ID: References: <696262e997359666afa053fe7d1a9fb2bb373964.1595010490.git.jpoimboe@redhat.com> 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 On Sun, 19 Jul 2020, Joe Lawrence wrote: > On 7/17/20 2:29 PM, Josh Poimboeuf wrote: > > Use of the new -flive-patching flag was introduced with the following > > commit: > > > > 43bd3a95c98e ("kbuild: use -flive-patching when CONFIG_LIVEPATCH is > > enabled") > > > > This flag has several drawbacks: > > > > [ ... snip ... ] > > > > - While there *is* a distro which relies on this flag for their distro > > livepatch module builds, there's not a publicly documented way to > > create safe livepatch modules with it. Its use seems to be based on > > tribal knowledge. It serves no benefit to those who don't know how to > > use it. > > > > (In fact, I believe the current livepatch documentation and samples > > are misleading and dangerous, and should be corrected. Or at least > > amended with a disclaimer. But I don't feel qualified to make such > > changes.) > > FWIW, I'm not exactly qualified to document source-based creation either, > however I have written a few of the samples and obviously the kselftest > modules. > > The samples should certainly include a disclaimer (ie, they are only for API > demonstration purposes!) and eventually it would be great if the kselftest > modules could guarantee their safety as well. I don't know quite yet how we > can automate that, but perhaps some kind of post-build sanity check could > verify that they are in fact patching what they intend to patch. That's a good idea. We should have something like that. I don't know how to make it nice. Just horrible post-build hacks that would check that modules were compiled as expected > As for a more general, long-form warning about optimizations, I grabbed > Miroslav's LPC slides from a few years back and poked around at some > IPA-optimized disassembly... Here are my notes that attempt to capture some > common cases: > > http://file.bos.redhat.com/~jolawren/klp-compiler-notes/livepatch/compiler-considerations.html > > It's not complete and I lost steam about 80% of the way through today. > :) But if it looks useful enough to add to Documentation/livepatch, we > can work on it on-list and try to steer folks into using the automated > kpatch-build, objtool (eventually) or a source-based safety checklist. It looks really useful. Could you prepare a patch and submit it, please? We could discuss it there. > The > source-based steps have been posted on-list a few times, but I think it only > needs to be formalized in a doc. Yes, I think they were. We discussed it with Nicolai to (better) document our workflow. It is currently based on klp-ccp (https://github.com/SUSE/klp-ccp), but we need a proper documentation how to prepare a live patch starting with an ordinary patch. Thanks Miroslav