Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751544AbdGRLPU (ORCPT ); Tue, 18 Jul 2017 07:15:20 -0400 Received: from mx2.suse.de ([195.135.220.15]:54380 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751358AbdGRLPS (ORCPT ); Tue, 18 Jul 2017 07:15:18 -0400 Date: Tue, 18 Jul 2017 13:15:16 +0200 (CEST) From: Miroslav Benes To: Josh Poimboeuf cc: Joe Lawrence , live-patching@vger.kernel.org, linux-kernel@vger.kernel.org, Jessica Yu , Jiri Kosina , Petr Mladek , Chris J Arges Subject: Re: [PATCH] livepatch: add (un)patch hooks In-Reply-To: <20170714014640.nhoowbrleu6kdka2@treble> Message-ID: References: <1499868600-10176-1-git-send-email-joe.lawrence@redhat.com> <1499868600-10176-2-git-send-email-joe.lawrence@redhat.com> <20170714014640.nhoowbrleu6kdka2@treble> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2119 Lines: 46 On Thu, 13 Jul 2017, Josh Poimboeuf wrote: > On Wed, Jul 12, 2017 at 10:10:00AM -0400, Joe Lawrence wrote: > > When the livepatch core executes klp_(un)patch_object, call out to a > > livepatch-module specified array of callback hooks. These hooks provide > > a notification mechanism for livepatch modules when klp_objects are > > (un)patching. This may be most interesting when another kernel module > > is a klp_object target and the livepatch module needs to execute code > > after the target is loaded, but before its module_init code is run. > > And it's also useful for vmlinux. Patch module load/unload is separate > from enable/disable, so the module init/exit functions can't be used for > patch-specific changes (e.g., global data changes). I admit that I don't understand this, which is probably the reason for my question. Why do we need it when we have module notifiers and module init/exit functions in the kernel? Petr described different possible scenarios and they can be solved either in init/exit function of a patch module or in a module notifier which the patch module can register. If there is a difference, it should be mentioned in the documentation and in the changelog. > > The patch-hook executes right before patching objects and the > > unpatch-hook executes right after unpatching objects. > > > > Signed-off-by: Joe Lawrence > > Thanks for posting it. We found this to be a useful feature in the > past, not quite as useful as shadow data, but still good to have for > certain cases. > > Instead of "load hooks" I think it would be more accurate to call them > "enable/disable hooks". (Maybe "callbacks" would be better than > "hooks"? Not sure...) > > Even better, we might want to be specific: "pre enable hooks" and "post > disable hooks". (Or "pre patch hooks" and "post unpatch hooks"?) > Because we might eventually decide we need the corresponding "post > enable hooks" and "pre disable hooks" as well. And this is what I'm worried about. I think we don't want to have hooks sprinkled here and there in the code. Thanks, Miroslav